Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== eAthena Script =======================================
- // Gift (npc)
- //===== By: ==================================================
- // Sehrentos
- //===== Current Version: =====================================
- // 2.6
- //===== Compatible With: =====================================
- // eAthena (SQL), rAthena (haven't tested yet)
- //===== Description: =========================================
- // Create single or multiple gift/s to a player or players.
- // - GM Panel.
- // - GM can select gift retrieve into account or character.
- // - multiple gifts.
- // - Players can choose to receive or remove gift.
- // - Players can select what gift to pickup fist (menu).
- // - Can set single gift to online players and offline.
- // - Can set single gift to online accounts and offline.
- // - Can set gifts to all players.
- // - Can set gifts to all accounts.
- // - Can set gifts to all online players only.
- // - Can set gifts to all online accounts only.
- // - Select GM level to use.
- // - Select SQL table for char.
- // - Select SQL table for this npc.
- //===== Installation: ========================================
- // 1. Go/find and Edit 'OnLoadSetup:' at the end of this file.
- // 2. Reload your server and see the changes.
- // Note: MySQL permissions for Create table needed or manual.
- //===== Additional Comments: =================================
- // You can freely use/edit this script. I hope you like it...
- //===== Updates: =============================================
- // 23-10-2011:
- // - Fixed weight check when receiving a gift.
- // 20-10-2011:
- // - Added Setup check to load configs again.
- // - Edited INSERT INTO.
- // - Edited table names.
- //============================================================
- geffen,116,110,5 script Gift 125,{
- //Check if setups are loaded.
- if(!.Setup) {
- callsub OnLoadSetup;
- }
- //Show GM Panel if player is GM.
- if(getgmlevel() >= .GMin) menu("Open Normaly",-,"Open Management",OnManagement);
- //Read attached player gifts from SQL table.
- if(select("My Account Gifts:My Character Gifts:Leave NPC") == 1) {
- set .@query, query_sql("SELECT * FROM `" + .GiftTableName$ + "` WHERE account_id="+getcharid(3), .@gift_id, .@gift_account, .@gift_char, .@gift_item, .@gift_amount); //Account gifts.
- } else if(@menu == 2) {
- set .@query, query_sql("SELECT * FROM `" + .GiftTableName$ + "` WHERE char_id="+getcharid(0), .@gift_id, .@gift_account, .@gift_char, .@gift_item, .@gift_amount); //Char gifts.
- } else goto OnLeave;
- //Check if player don't have gifts.
- if(!.@query) {
- mes "[" + strnpcinfo(1) + "]";
- mes "Sorry, but you dont have any gifts today...";
- close;
- }
- //Build menu from query arrays.
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900A Gift is received!^000000";
- mes "Please select one from the menu.";
- for(set .@i, 0; .@i < .@query; set .@i, .@i + 1) {
- set .@text$, "(" + .@gift_amount[.@i] + ") " + getitemname(.@gift_item[.@i]);
- mes .@text$;
- set .@menu$, .@menu$ + .@text$ + ":";
- }
- next;
- set .@mid,select(.@menu$); //Show menu.
- set .@mid,.@mid-1;
- //Item is now selected. Choose what you want to do with it.
- mes "[" + strnpcinfo(1) + "]";
- mes "What you like to do with (" + .@gift_amount[.@mid] + ") " + getitemname(.@gift_item[.@mid]) + "?";
- next;
- set .@Select,select("^009900Receive^000000:^ff0000Remove^000000:Nothing");
- //Receive gift selected.
- if(.@Select == 1) {
- //Check weight.
- if(checkweight(.@gift_item[.@mid], .@gift_amount[.@mid])) {
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Received: (" + .@gift_amount[.@mid] + ") " + getitemname(.@gift_item[.@mid]) + ".^000000";
- getitem .@gift_item[.@mid], .@gift_amount[.@mid]; //Give item to player.
- query_sql( "DELETE FROM `" + .GiftTableName$ + "` WHERE id = " + .@gift_id[.@mid] ); //Remove item from table.
- close;
- } else {
- //Overweight
- mes "[" + strnpcinfo(1) + "]";
- mes "^ff0000Sorry^000000 you cannot hold this amount of " + getitemname(.@gift_item[.@mid]) + "(s)";
- mes "Can you lose some more weight first?";
- close;
- }
- }
- //Remove gift selected.
- else if(.@Select == 2) {
- mes "[" + strnpcinfo(1) + "]";
- mes "Are you absolutely sure about ^ff0000Removing^000000?";
- mes "Gift: ("+.@gift_amount[.@mid]+") "+getitemname(.@gift_item[.@mid])+".";
- next;
- if(select("Yes:No") == 1) {
- mes "[" + strnpcinfo(1) + "]";
- mes "^ff0000Removed: ("+.@gift_amount[.@mid]+") "+getitemname(.@gift_item[.@mid])+".^000000";
- query_sql("DELETE FROM `" + .GiftTableName$ + "` WHERE id = " + .@gift_id[.@mid]); //Remove item from table.
- close;
- } else {
- mes "[" + strnpcinfo(1) + "]";
- mes "Lets keep the goods in a safe place for a while.";
- close;
- }
- }
- //Nothing selected.
- else {
- goto OnLeave;
- }
- //GM Panel below:
- OnManagement:
- if(getgmlevel() < .GMin) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Welcome master " + strcharinfo(0) + "!";
- mes "How can i help you today?";
- next;
- if(select("Make Gift:Nothing") != 1) goto OnLeave;
- //Make new gift.
- mes "[" + strnpcinfo(1) + "]";
- mes "Please input the item id.";
- mes "Default: 501";
- next;
- //item_id range of 501 to 30,000.
- input .@new_item, 501, 30000;
- if(select("Continue:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "How many items?";
- mes "Default: 1";
- next;
- //item quantity range of 1 to 1,000.
- input .@new_value, 1, 1000;
- if(select("Continue:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Please select type:";
- mes "1. Single Account";
- mes "2. Single Character";
- mes "3. All ^009900Online^000000 Accounts.";
- mes "4. All Accounts.";
- mes "5. All ^009900Online^000000 Players/Characters.";
- mes "6. All Players/Characters.";
- mes "7. ^ff0000Cancel.^000000";
- next;
- switch(select("Single Account:Single Character:^009900Online^000000 Accounts:All Accounts:^009900Online^000000 Characters:All Characters:Cancel"))
- {
- //Account gift
- case 1:
- mes "[" + strnpcinfo(1) + "]";
- mes "Please select input type:";
- mes "By AID or Name?";
- next;
- if(select("Account ID:Character Name") == 1)
- {
- mes "[" + strnpcinfo(1) + "]";
- mes "Write account id:";
- next;
- input .@new_account, 2000000, 10000000; //Account id range from 2m to 10m.
- set .@Query, query_sql("SELECT account_id FROM `" + .CharTableName$ + "` WHERE account_id = " + .@new_account, .@new_account);
- if(!.@Query) goto OnNotExist;
- if(select("Continue:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "AID: ^ff0000" + .@new_account + "^000000";
- mes "------------------";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Gift sending success!";
- //Create gift. <auto_id>, <account_id> <char_id> <item> <value>
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (account_id, item, value) VALUES(" + .@new_account + ", " + .@new_item + ", " + .@new_value + ")");
- }
- else
- {
- mes "[" + strnpcinfo(1) + "]";
- mes "Write player name:";
- next;
- input .@new_name$;
- set .@Query, query_sql("SELECT account_id FROM `" + .CharTableName$ + "` WHERE name = '" + .@new_name$ + "'", .@new_account);
- if(!.@Query) goto OnNotExist;
- if(select("Continue:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "AID: ^ff0000" + .@new_account + "^000000";
- mes "Name: ^ff0000"+ .@new_name$ + "^000000";
- mes "------------------";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- //Check if player is logged in.
- if(isloggedin(.@new_account)) {
- mes "[" + strnpcinfo(1) + "]";
- message .@new_name$, "New reward has been received!";
- message .@new_name$, "Talk to " + strnpcinfo(1) + "(npc) in center of Geffen town to receive your rewards.";
- message .@new_name$, "Happy gaming!!";
- mes "Gift sending success!";
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (account_id, item, value) VALUES (" + .@new_account + ", " + .@new_item + ", " + .@new_value + ")");
- } else {
- //Account was not online.
- mes "[" + strnpcinfo(1) + "]";
- mes "Gift sending success!";
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (account_id, item, value) VALUES (" + .@new_account + ", " + .@new_item + ", " + .@new_value + ")");
- }
- }
- break;
- //Character gift.
- case 2:
- mes "[" + strnpcinfo(1) + "]";
- mes "Please select input type:";
- mes "By CID or Name?";
- next;
- if(select("Character ID:Character Name") == 1)
- {
- mes "[" + strnpcinfo(1) + "]";
- mes "Write character id:";
- next;
- input .@new_char,150000, 10000000; //Char id range from 150k to 10m.
- set .@Query, query_sql("SELECT account_id, name FROM `" + .CharTableName$ + "` WHERE char_id = " + .@new_char, .@new_accountid, .@new_name$);
- if(!.@Query) goto OnNotExist;
- if(select("Continue:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "CID: ^ff0000" + .@new_char + "^000000";
- mes "Name: ^ff0000" + .@new_name$ + "^000000";
- mes "------------------";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- //Check if player is logged in.
- if(isloggedin(.@new_accountid)) {
- mes "[" + strnpcinfo(1) + "]";
- mes "Gift sending success!";
- message .@new_name$, "New Gift is received! Talk to \"Gift\" npc in center of Geffen town to receive your gift. Happy gaming!!";
- //Create gift. <auto_id>, <account_id> <char_id> <item> <value>
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (char_id, item, value) VALUES (" + .@new_char + ", " + .@new_item + ", " + .@new_value + ")");
- } else {
- //not online ask if we still give the gift.
- mes "[" + strnpcinfo(1) + "]";
- mes "The character is not online!";
- mes "Would you still like to send the gift?";
- next;
- if(select("Yes:No") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Gift sending success!";
- //Create gift. <auto_id>, <account_id> <char_id> <item> <value>
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (char_id, item, value) VALUES (" + .@new_char + ", " + .@new_item + ", " + .@new_value + ")");
- }
- }
- else
- {
- mes "[" + strnpcinfo(1) + "]";
- mes "Write player name:";
- next;
- input .@new_name$;
- set .@Query, query_sql("SELECT char_id, account_id FROM `" + .CharTableName$ + "` WHERE name = '" + .@new_name$ + "'", .@new_char, .@new_accountid);
- if(!.@Query) goto OnNotExist;
- if(select("Continue:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "CID: ^ff0000" + .@new_char + "^000000";
- mes "Name: ^ff0000"+ .@new_name$ + "^000000";
- mes "------------------";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- //Check if player is logged in.
- if(isloggedin(.@new_accountid)) {
- mes "[" + strnpcinfo(1) + "]";
- message .@new_name$, "New reward has been received!";
- message .@new_name$, "Talk to " + strnpcinfo(1) + "(npc) in center of Geffen town to receive your rewards.";
- message .@new_name$, "Happy gaming!!";
- mes "Gift sending success!";
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (char_id, item, value) VALUES (" + .@new_char + ", " + .@new_item + ", " + .@new_value + ")");
- } else {
- //not online ask if we still give the gift.
- mes "[" + strnpcinfo(1) + "]";
- mes "The character is not online!";
- mes "Would you still like to give the gift?";
- next;
- if(select("Yes:No") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Gift sending success!";
- //Create gift. <auto_id>, <account_id> <char_id> <item> <value>
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (char_id, item, value) VALUES (" + .@new_char + ", " + .@new_item + ", " + .@new_value + ")");
- }
- }
- break;
- //Register gift to all online accounts!
- case 3:
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Please hold...";
- set .@Query, query_sql("SELECT account_id FROM `" + .CharTableName$ + "` WHERE online=1",.@account);
- for(set .@i, 0; .@i < .@Query; set .@i, .@i + 1) {
- sleep2 10; //Slowdown the loop abit.
- query_sql("INSERT INTO " + .GiftTableName$ + " (account_id, item, value) VALUES (" + .@account[.@i] + ", " + .@new_item + ", " + .@new_value + ")");
- }
- mes "Gift registered to (" + .@i + ") accounts!";
- break;
- //Register gift to all accounts!
- case 4:
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Please hold...";
- set .@Query, query_sql("SELECT account_id FROM `" + .CharTableName$ + "`",.@account);
- for(set .@i, 0; .@i < .@Query; set .@i, .@i + 1) {
- sleep2 10; //Slowdown the loop abit.
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (account_id, item, value) VALUES (" + .@account[.@i] + ", " + .@new_item + ", " + .@new_value + ")");
- }
- mes "Gift registered to (" + .@i + ") accounts!";
- break;
- //Register gift to all online characters!
- case 5:
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Please hold...";
- set .@Query, query_sql("SELECT char_id FROM `" + .CharTableName$ + "` WHERE online=1",.@char);
- for(set .@i, 0; .@i < .@Query; set .@i, .@i + 1) {
- sleep2 10; //Slowdown the loop abit.
- query_sql("INSERT INTO " + .GiftTableName$ + " (char_id, item, value) VALUES (" + .@char[.@i] + ", " + .@new_item + ", " + .@new_value + ")");
- }
- mes "Gift registered to (" + .@i + ") players!";
- break;
- //Register gift to all characters!
- case 6:
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Gift is ready to go!^000000";
- mes "Item: ^ff0000" + getitemname(.@new_item) + "^000000";
- mes "Quantity: ^ff0000" + .@new_value + "^000000";
- next;
- if(select("Send Gift:Cancel") != 1) goto OnLeave;
- mes "[" + strnpcinfo(1) + "]";
- mes "Please hold...";
- set .@Query, query_sql("SELECT char_id FROM `" + .CharTableName$ + "`",.@char);
- for(set .@i, 0; .@i < .@Query; set .@i, .@i + 1) {
- sleep2 10; //Slowdown the loop abit.
- query_sql("INSERT INTO `" + .GiftTableName$ + "` (char_id, item, value) VALUES (" + .@char[.@i] + ", " + .@new_item + ", " + .@new_value + ")");
- }
- mes "Gift registered to (" + .@i + ") players!";
- break;
- //Cancel.
- Default:
- mes "[" + strnpcinfo(1) + "]";
- mes "Have a good day sir!";
- break;
- }
- close;
- OnLeave:
- mes "[" + strnpcinfo(1) + "]";
- mes "Have a good day!";
- close;
- OnNotExist:
- mes "[" + strnpcinfo(1) + "]";
- mes "This player/account does not exist!";
- close;
- //============================================================
- // Config/Edit:
- //============================================================
- OnLoadSetup:
- set .Setup, 1; //OnInit is loaded check.
- set .GMin, 60; //Minimum GM level to use gm panel.
- //Your table names:
- set .CharTableName$, "char"; //Char table name(SQL).
- set .GiftTableName$, "reward"; //Gift table name(SQL).
- //Create gift table <auto_id>, <account_id>, <char_id>, <item>, <value>
- query_sql("CREATE TABLE IF NOT EXISTS `" + .GiftTableName$ + "` (`id` INT(11) unsigned NOT NULL auto_increment, `account_id` INT(11) unsigned NOT NULL default 0, `char_id` INT(11) unsigned NOT NULL default 0, `item` SMALLINT unsigned NOT NULL default 0, `value` INT(11) unsigned NOT NULL default 0, PRIMARY KEY (`id`)) ENGINE=MyISAM");
- return;
- //Server start/load event.
- OnInit:
- callsub OnLoadSetup;
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement