Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- CREATE TABLE IF NOT EXISTS `ero_npc_trade_item` (
- `cid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- `name` VARCHAR(30) NOT NULL DEFAULT '',
- `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- PRIMARY KEY (`cid`,`nameid`,`amount`)
- ) ENGINE=MyISAM;
- */
- prontera,155,175,5 script Item Collector::item_collector_npc 4_F_KAFRA9,{
- doevent "trade_item_main::OnTalk";
- }
- - script trade_item_main -1,{
- OnInit:
- // Top Rank
- .top_rank = 10;
- // NPC take what item ID (empty = all items)
- setarray .itemid, 512;
- // list of not allowed items
- setarray .blacklist_itemid, 501, 502, 4001;
- .itemid_size = getarraysize(.itemid);
- for (.@i = 0; .@i < .itemid_size; .@i++) {
- .itemid$ = (.@i > 0 ? "," : "") + .itemid$ + .itemid[.@i];
- .is_allow[.itemid[.@i]] = 1;
- }
- .allow_all_item = !.itemid_size;
- .blacklist_itemid_size = getarraysize(.blacklist_itemid);
- for (.@i = 0; .@i < .blacklist_itemid_size; .@i++)
- .is_blacklist[.blacklist_itemid[.@i]] = 1;
- end;
- OnTalk:
- .@is_gm = (getgmlevel() >= 99);
- mes "^0055FF[ Item Collector ]^000000";
- mes "Do you have any used items? You may give it to me.";
- if (!.allow_all_item) {
- for (.@i = 0; .@i < .itemid_size; .@i++)
- mes "\n~ " + mesitemlink(.itemid[.@i], false);
- }
- mes " ";
- mes "I'll always remember who giveaway his items to me.";
- switch(select(
- "View Top "+.top_rank+" Rank",
- "Give Item to NPC",
- (.@is_gm) ? "^FF0000[GM]^000000 Reset Ranking" : ""
- )) {
- default:
- case 1:
- do {
- clear;
- mes "[ View Top "+.top_rank+" Rank ]";
- switch(select(
- "Any",
- "Filter by Character Name",
- (.allow_all_item) ? "":"Filter by ItemID"
- )) {
- default:
- break;
- case 2:
- .@filter_by = 1;
- mes "Enter Character Name";
- break;
- case 3:
- .@filter_by = 2;
- mes "Enter ItemID";
- break;
- }
- if (.@filter_by && .@filter_by != 3)
- input .@input$;
- .@sql$ = "SELECT `name`, `nameid`, SUM(`amount`) AS `total` "
- + "FROM `ero_npc_trade_item` "
- + "WHERE 1 = 1 "
- + (.allow_all_item ? "" : "AND `nameid` IN ("+escape_sql(.itemid$)+") ")
- + ((.@filter_by == 1) ? "AND `name` IN ("+escape_sql(.@input$)+") " : "")
- + ((.@filter_by == 2) ? "AND `nameid` IN ("+escape_sql(.@input$)+") " : "")
- + "GROUP BY `cid`, `nameid`, `name`"
- + "ORDER BY `total` DESC LIMIT "+.top_rank;
- query_sql(.@sql$, .@name$, .@nameid, .@total);
- .@size = getarraysize(.@name$);
- if (!.@size) {
- mes "no record found.";
- break;
- }
- for (.@i = 0; .@i < .@size; .@i++)
- mes "["+(.@i+1)+".] "+mesitemlink(.@nameid[.@i], false, .@name$[.@i])+" ("+F_InsertComma(.@total[.@i])+")";
- next;
- } while (true);
- break;
- case 2:
- clear;
- mes "[ Give Item to NPC ]";
- if (!.allow_all_item) {
- mes "I accept the following items:";
- for (.@i = 0; .@i < .itemid_size; .@i++)
- mes "\n~ " + mesitemlink(.itemid[.@i], false);
- }
- getinventorylist;
- for (.@i = 0; .@i < @inventorylist_count; .@i++) {
- if (@inventorylist_bound[.@i] <= 0
- && @inventorylist_expire[.@i] <= 0
- && @inventorylist_equip[.@i] <= 0
- && @inventorylist_tradable[.@i]
- && .is_blacklist[@inventorylist_id[.@i]] == 0
- && (.allow_all_item || .is_allow[@inventorylist_id[.@i]])
- ) {
- .@menu$ = .@menu$ + replacestr(getitemname(@inventorylist_id[.@i]), ":", " ") + " ("+F_InsertComma(@inventorylist_amount[.@i])+" left)";
- .@count++;
- }
- .@menu$ = .@menu$ + ":";
- }
- if (.@count)
- .@i = select(.@menu$) - 1;
- if (!@inventorylist_id[.@i]) {
- mes "Unfortunately, you dont have any item available to give to NPC.";
- close;
- }
- clear;
- mes "[ Give Item to NPC ]";
- mes "How many "+mesitemlink(@inventorylist_id[.@i], false)+" will be given to me?";
- mes "(You have "+F_InsertComma(@inventorylist_amount[.@i])+" left)";
- input .@amount, 0, @inventorylist_amount[.@i];
- clear;
- mes "[ Give Item to NPC ]";
- if (.@amount) {
- delitemidx @inventorylist_idx[.@i], .@amount;
- clear;
- mes "[ Give Item to NPC ]";
- mes "Thank you, you donated "+.@amount+"x "+mesitemlink(@inventorylist_id[.@i], false)+" to me.";
- npctalk "<Item Collector> Thank you, '"+strcharinfo(0)+"' donated "+.@amount+"x "+itemlink(@inventorylist_id[.@i], @inventorylist_refine[.@i], @inventorylist_card1[.@i], @inventorylist_card2[.@i], @inventorylist_card3[.@i], @inventorylist_card4[.@i], @inventorylist_enchantgrade[.@i])+" to me.", "item_collector_npc";
- query_sql("INSERT INTO `e_npc_trade_item` (`cid`,`name`,`nameid`,`amount`) VALUES ("+getcharid(0)+",'"+escape_sql(strcharinfo(0))+"',"+@inventorylist_id[.@i]+","+.@amount+") ON DUPLICATE KEY UPDATE `amount` = `amount` + "+.@amount);
- }
- mes "Thank for your kindness.";
- break;
- case 3:
- clear;
- mes "[ Reset Ranking ]";
- mes "This action cant be undo, confirm your action?";
- if (select("Yes, confirm.","Cancel") == 1) {
- query_sql("TRUNCATE `e_npc_trade_item`");
- clear;
- mes "[ Reset Ranking ]";
- mes "All record has been deleted.";
- }
- break;
- }
- close;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement