· 9 years ago · Nov 27, 2016, 07:28 PM
1// https://rathena.org/board/topic/107975-r-wishlist-npc/
2
3/*
4CREATE TABLE IF NOT EXISTS `e_wishlist` (
5 `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
6 `aid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
7 `nameid` INT(11) NOT NULL DEFAULT '0',
8 `amount` INT(11) NOT NULL DEFAULT '0',
9 `status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
10 PRIMARY KEY (`id`)
11) ENGINE=MyISAM;
12*/
13
14prontera,155,181,5 script WishList NPC 4_F_MAID,{
15 doevent "wishlist_main::OnTalk";
16}
17
18
19- script wishlist_main -1,{
20
21 OnTalk:
22 .@aid = getcharid(3);
23
24 mes "What item you wish to get in this month?";
25 mes "Tell me what its and you might be the lucky one to obtain it by end of this month.";
26 next;
27 switch ( select(
28 "Add New Wishlist",
29 "Claim Pending Wishlist",
30 "My Wishlist History"
31 )) {
32 case 1:
33 query_sql( "SELECT `id`,`nameid`,`amount` FROM `e_wishlist` WHERE `aid` = "+.@aid+" AND `status` = 0", .@id );
34 .@size = getarraysize( .@id );
35 if ( .@size >= .max_entry ) {
36 mes "You have already created "+.@size+" wishlist this month. Try again next month.";
37 }
38 else {
39 mes "Enter Item ID";
40 input .@nameid;
41 if ( getitemname( .@nameid ) != "null" ) {
42 mes "Enter Amount";
43 input .@amount,0,.item_max_amount;
44 if ( .@amount > 0 ) {
45 next;
46 if ( select( "Confirm","Cancel" ) == 1 ) {
47 mes "Wishlist Added.";
48 query_sql( "INSERT INTO `e_wishlist` ( `aid`,`nameid`,`amount` ) VALUES ( "+getcharid(3)+", "+.@nameid+", "+.@amount+" )" );
49 }
50 }
51 }
52 }
53 break;
54 case 2:
55 mes "Item List:";
56 query_sql( "SELECT `id`,`nameid`,`amount` FROM `e_wishlist` WHERE `aid` = "+.@aid+" AND `status` = 2", .@id, .@nameid, .@amount );
57 .@size = getarraysize( .@id );
58 for ( .@i = 0; .@i < .@size; .@i++ )
59 .@menu$ = .@menu$ + getitemname( .@nameid[.@i] ) +" - "+.@amount[.@i]+" each" + ":";
60 .@i = select( .@menu$ ) - 1;
61
62 mes "You gained "+getitemname( .@nameid[.@i] )+" - "+.@amount[.@i]+" each";
63 query_sql( "UPDATE `e_wishlist` SET `status` = 3 WHERE `id` = "+.@id[.@i]+" LIMIT 1" );
64 getitem .@nameid[.@i],.@amount[.@i];
65 break;
66 case 3:
67 mes "Recent Entry:";
68 query_sql( "SELECT `id`,`nameid`,`amount`,`status` FROM `e_wishlist` WHERE `aid` = "+.@aid+" LIMIT 100", .@id, .@nameid, .@amount, .@status );
69 .@size = getarraysize( .@id );
70 for ( .@i = 0; .@i < .@size; .@i++ ) {
71 switch ( .@status[.@i] ) {
72 case 1: .@status$ = "Expired"; break;
73 case 2: .@status$ = "Unclaimed"; break;
74 case 3: .@status$ = "Claimed"; break;
75 default: .@status$ = "Pending"; break;
76 }
77 mes "["+( .@i+1 )+".] "+.@amount[.@i]+"x "+getitemname( .@nameid[.@i] )+" ("+.@status$+")";
78
79 if ( .@i && .@i % 7 == 0 ) {
80 next;
81 if ( select ( "Next Page","Cancel" ) == 2 )
82 close;
83 }
84 }
85 default: break;
86 }
87 close;
88
89 OnInit:
90 .max_entry = 1;
91 .item_max_amount = 30000;
92 end;
93
94 OnDay0101:
95 OnDay0201:
96 OnDay0301:
97 OnDay0401:
98 OnDay0501:
99 OnDay0601:
100 OnDay0701:
101 OnDay0801:
102 OnDay0901:
103 OnDay1001:
104 OnDay1101:
105 OnDay1201:
106 query_sql( "SELECT `id`,`aid` FROM `e_wishlist` WHERE `status` = 0 ORDER BY RAND() LIMIT 1",.@id,.@aid );
107 query_sql( "UPDATE `e_wishlist` SET `status` = 2 WHERE `id` = "+.@id+" LIMIT 1" );
108 query_sql( "UPDATE `e_wishlist` SET `status` = 1 WHERE `status` = 0" );
109 if ( .@aid ) {
110 if ( attachrid( .@aid ) ) {
111 message strcharinfo(0),"You gained an item from the WishList NPC.";
112 }
113 }
114 end;
115}