· 10 years ago · Aug 31, 2016, 04:56 PM
1/*
2CREATE TABLE IF NOT EXISTS `e_npc_trade_item` (
3 `cid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
4 `name` VARCHAR(30) NOT NULL DEFAULT '',
5 `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
6 `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0',
7 PRIMARY KEY (`cid`,`nameid`,`amount`)
8) ENGINE=MyISAM;
9*/
10
11invek,137,157,6 script Pouring Hunting Event 562,{
12
13 doevent "trade_item_main::OnTalk";
14}
15
16
17- script trade_item_main -1,{
18
19 OnInit:
20 // NPC take what item ID, 0 = all items.
21 .only_one_itemid = 6024;
22 end;
23
24 OnTalk:
25 .@is_gm = ( getgmlevel() >= 99 );
26
27 switch( select(
28 "Event Details",
29 "View Top 10",
30 "Give Item to NPC",
31 ( .@is_gm ) ? "GM Reset" : ""
32 )) {
33 default:
34 mes "Event Duration: 1st September - 30th September";
35 mes " ";
36 mes "A horde of Pourings have invaded Poring Island (pay_fild04). Even though they are not aggressive monsters, a number of novices have mistakenly attacked them and fallen prey to their magical powers. Rune Midgard needs your assistance to get rid of the intruders! Each Pouring will drop '17 Carat Diamond'.";
37 next;
38 mes "All you have to do is hunt Pourings and submit as many 17 Carat Diamonds to 'Pouring Hunting Event' NPC. The top 3 players who kills the most Pouring will win grand prizes.";
39 next;
40 mes "1st Place: 200 Gaia Points!";
41 mes "2nd Place: 150 Gaia Points!";
42 mes "3rd Place: 100 Gaia Points!";
43 mes " ";
44 mes "Note: Result & Reward will be announced and distributed on 1st October.";
45 break;
46 case 2:
47 mes "Top 10 Records:";
48 query_sql( "SELECT `name`, `nameid`, SUM(`amount`) AS `total` FROM `e_npc_trade_item` "+( .only_one_itemid ? "WHERE `nameid` = "+.only_one_itemid : "" )+" GROUP BY `cid`,`nameid` ORDER BY `total` DESC LIMIT 10",.@name$,.@nameid,.@total );
49 .@size = getarraysize( .@name$ );
50 if ( .@size ) {
51 for ( .@i = 0; .@i < .@size; .@i++ ) {
52 mes "'"+.@name$[.@i]+"' - '"+getitemname( .@nameid[.@i] )+"' ["+.@total[.@i]+"]";
53 }
54 }
55 else {
56 mes "no record found.";
57 }
58 break;
59 case 3:
60 if ( !.only_one_itemid )
61 {
62 mes "Pick an items give to NPC.";
63 getinventorylist;
64 for ( .@i = 0; .@i < @inventorylist_count; .@i++ ) {
65 if ( @inventorylist_bound[.@i] <= 0
66 && @inventorylist_expire[.@i] <= 0
67 && @inventorylist_equip[.@i] <= 0
68 ) {
69 .@menu$ = .@menu$ + getitemname( @inventorylist_id[.@i] ) + " ("+@inventorylist_amount[.@i]+" left)";
70 .@count++;
71 }
72 .@menu$ = .@menu$ + ":";
73 }
74 }
75 else {
76 .@menu$ = getitemname( .only_one_itemid );
77 .@count++;
78 }
79 if ( .@count ) {
80 .@i = select( .@menu$ ) - 1;
81 mes ""+getitemname( @inventorylist_id[.@i] );
82 mes "How many will be given to NPC ?";
83 input .@amount,0,countitem( @inventorylist_id[.@i] );
84 if ( .@amount ) {
85 delitem @inventorylist_id[.@i],.@amount;
86 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 );
87 mes "Done";
88 }
89 }
90 else {
91 mes "You dont have any item available to give to NPC.";
92 }
93 break;
94 case 4:
95 mes "This action cant be undo, confirm your action?";
96 next;
97 if ( select( "Yes, confirm.","Cancel" ) == 1 ) {
98 query_sql( "TRUNCATE `e_npc_trade_item`" );
99 }
100 break;
101 }
102 close;
103}