· 7 years ago · Nov 30, 2018, 02:56 PM
1/* ______________________________________________________________
2 | |
3 | rAthena Script |
4 | |
5 | Rewards NPC |
6 | By: |
7 | Viole |
8 | |
9 | Current Version |
10 | 1.5 |
11 | |
12 | Description: |
13 | NPC which you can assign a reward |
14 | to a 'specific' player and set |
15 | the quantity of the reward to be |
16 | given. |
17 | |
18 | Changelog: |
19 | Rewards NPC 1.0 Items recognized are only from item_db |
20 | Rewards NPC 1.1 Items recognized from item_db to item_db2 |
21 | Rewards NPC 1.1 Prevent null from typing 0 in item & amount |
22 | Rewards NPC 1.1 Main: Can put many players now to give item |
23 | Rewards NPC 1.2 Fixed Cancel the process option |
24 | Rewards NPC 1.2 Added Delete a process or all process option|
25 | Rewards NPC 1.3 Added Show Current Processes option |
26 | Rewards NPC 1.4 Added Party Option in Assign Rewards |
27 | Rewards NPC 1.4 Show Current Process (Player or Party) |
28 | Rewards NPC 1.4 Added Delete Option for Party |
29 | Rewards NPC 1.5 Added Guild Option in Assign Rewards |
30 | Rewards NPC 1.5 Show Current Process (Player/Party/Guild) |
31 | Rewards NPC 1.5 Added Delete Option for Guild |
32 | Rewards NPC 1.5 Announce. GM adds a process for Party/Guild |
33 | |
34 | Note: |
35 | If you added 2 items to a 'same' player/guild/party |
36 | Only the first one is recognized. |
37 | |
38 | (If you downloaded 1.1) |
39 | You can delete the table 'rewardsnpc' in sql |
40 | cuz I decided to rename it to have a name similarity |
41 | with the new tables. |
42 | |
43 | Load with OnInit. |
44 |______________________________________________________________|*/
45
46
47- script Rewards#101 -1,{
48
49 set .@n$, "^FF0000[Rewards NPC]^000000";
50 set .gmlvl, 80;
51
52 if (getgmlevel() >= .gmlvl)
53 {
54 admin_only:
55 mes .@n$;
56 mes "Hello, GM "+strcharinfo(0)+"!";
57 mes "What do you want to do?";
58 next;
59 switch(select("Assign Reward:Show Current Processes:Delete Process"))
60 {
61 case 1:
62 next;
63 mes .@n$;
64 mes"Choose what category you want to give the reward.";
65 next;
66 switch(select("To a Player:To a Party:To a Guild"))
67 {
68 case 1:
69 next;
70 mes .@n$;
71 mes "To whom do you wanna give the reward?";
72 input @playername$;
73 query_sql "SELECT `char_id` FROM `char` WHERE `name` = '"+escape_sql(@playername$)+"'",.@charid;
74 if (!.@charid) {next; mes .@n$; mes "The name is invalid."; next; goto admin_only; }
75 else set .@charid,0;
76 next;
77 mes .@n$;
78 mes "What will be the reward item?";
79 mes "Please, input the Item ID #";
80 input @rewarditem;
81 if(@rewarditem <= 500) {next; mes .@n$; mes "The item is invalid."; next; goto admin_only; }
82 next;
83 mes .@n$;
84 mes "How many "+getitemname(@rewarditem)+" will be given to "+@playername$+"?";
85 input @rewardamount;
86 if(@rewardamount <= 0) {next; mes .@n$; mes "Please input a number greater than 0"; next; goto admin_only; }
87 next;
88 mes .@n$;
89 mes "So, player "+@playername$+" will have";
90 mes ""+@rewardamount+" "+getitemname(@rewarditem)+"s. Great~!";
91 next;
92 message @playername$,"Please claim your rewards from the Rewards NPC! "+@rewardamount+" "+getitemname(@rewarditem)+"s";
93 query_sql "INSERT INTO `rewardplayernpc` (`playername`, `reward_id`, `reward_amount`) VALUES ('"+@playername$+"', "+@rewarditem+", "+@rewardamount+")";
94 set @playername$, "";
95 close2;
96 end;
97 case 2:
98 next;
99 mes .@n$;
100 mes "Please input the party name..";
101 input @partyname$;
102 query_sql "SELECT `party_id` FROM `party` WHERE `name` = '"+escape_sql(@partyname$)+"'",.@partyid;
103 if (!.@partyid) {next; mes .@n$; mes "The party name is invalid."; next; goto admin_only; }
104 else set .@partyid,0;
105 next;
106 mes .@n$;
107 mes "What will be the reward item?";
108 mes "Please, input the Item ID #";
109 input @partyrewarditem;
110 if(@partyrewarditem <= 500) {next; mes .@n$; mes "The item is invalid."; next; goto admin_only; }
111 next;
112 mes .@n$;
113 mes "How many "+getitemname(@partyrewarditem)+" will be given to party "+@partyname$+"?";
114 input @partyrewardamount;
115 if(@partyrewardamount <= 0) {next; mes .@n$; mes "Please input a number greater than 0"; next; goto admin_only; }
116 next;
117 mes .@n$;
118 mes "So, party "+@partyname$+" will have";
119 mes ""+@partyrewardamount+" "+getitemname(@partyrewarditem)+"s. Great~!";
120 next;
121 announce "Party leader of the party ["+@partyname$+"], please claim your rewards from the Rewards NPC! "+@partyrewardamount+" "+getitemname(@partyrewarditem)+"s",0,0xDBA901;
122 query_sql "INSERT INTO `rewardpartynpc` (`partyname`, `reward_id`, `reward_amount`) VALUES ('"+@partyname$+"', "+@partyrewarditem+", "+@partyrewardamount+")";
123 set @partyname$, "";
124 close2;
125 end;
126 case 3:
127 next;
128 mes .@n$;
129 mes "Please input the guild name..";
130 input @guildname$;
131 query_sql "SELECT `guild_id` FROM `guild` WHERE `name` = '"+escape_sql(@guildname$)+"'",.@guildid;
132 if (!.@guildid) {next; mes .@n$; mes "The guild name is invalid."; next; goto admin_only; }
133 else set .@guildid,0;
134 next;
135 mes .@n$;
136 mes "What will be the reward item?";
137 mes "Please, input the Item ID #";
138 input @guildrewarditem;
139 if(@guildrewarditem <= 500) {next; mes .@n$; mes "The item is invalid."; next; goto admin_only; }
140 next;
141 mes .@n$;
142 mes "How many "+getitemname(@guildrewarditem)+" will be given to the guild "+@guildname$+"?";
143 input @guildrewardamount;
144 if(@guildrewardamount <= 0) {next; mes .@n$; mes "Please input a number greater than 0"; next; goto admin_only; }
145 next;
146 mes .@n$;
147 mes "So, player "+@guildname$+" will have";
148 mes ""+@guildrewardamount+" "+getitemname(@guildrewarditem)+"s. Great~!";
149 next;
150 announce "GuildMaster of the Guild ["+@guildname$+"], please claim your rewards from the Rewards NPC! "+@guildrewardamount+" "+getitemname(@guildrewarditem)+"s",0,0xDBA901;
151 query_sql "INSERT INTO `rewardguildnpc` (`guildname`, `reward_id`, `reward_amount`) VALUES ('"+@guildname$+"', "+@guildrewarditem+", "+@guildrewardamount+")";
152 set @guildname$, "";
153 close2;
154 end;
155 }
156 case 2:
157 next;
158 mes .@n$;
159 mes "Choose from what category you would like to view current processes.";
160 next;
161 switch(select("Player:Party:Guild"))
162 {
163 case 1:
164 next;
165 mes "^FF0000[Current Processes - Player]^000000";
166 mes "••••••••••••••••••••••••••••••••";
167 query_sql "SELECT `playername`, `reward_id`, `reward_amount` FROM `rewardplayernpc`", .@show_name$, .@show_item, .@show_amount;
168 for(set @i, 0; @i < getarraysize(.@show_name$); set @i, @i+1)
169 {
170 mes "To: ^0000FF" + .@show_name$[@i]+"^000000";
171 mes "Reward: "+.@show_amount[@i]+" "+getitemname(.@show_item[@i])+"s";
172 mes "••••••••••••••••••••••••••••••••";
173 }
174 close;
175 case 2:
176 next;
177 mes "^FF0000[Current Processes - Party]^000000";
178 mes "••••••••••••••••••••••••••••••••";
179 query_sql "SELECT `partyname`, `reward_id`, `reward_amount` FROM `rewardpartynpc`", .@partyshow_name$, .@partyshow_item, .@partyshow_amount;
180 for(set @i, 0; @i < getarraysize(.@partyshow_name$); set @i, @i+1)
181 {
182 mes "To: ^0000FF" + .@partyshow_name$[@i]+"^000000";
183 mes "Reward: "+.@partyshow_amount[@i]+" "+getitemname(.@partyshow_item[@i])+"s";
184 mes "••••••••••••••••••••••••••••••••";
185 }
186 close;
187 case 3:
188 next;
189 mes "^FF0000[Current Processes - Guild]^000000";
190 mes "••••••••••••••••••••••••••••••••";
191 query_sql "SELECT `guildname`, `reward_id`, `reward_amount` FROM `rewardguildnpc`", .@guildshow_name$, .@guildshow_item, .@guildshow_amount;
192 for(set @i, 0; @i < getarraysize(.@guildshow_name$); set @i, @i+1)
193 {
194 mes "To: ^0000FF" + .@guildshow_name$[@i]+"^000000";
195 mes "Reward: "+.@guildshow_amount[@i]+" "+getitemname(.@guildshow_item[@i])+"s";
196 mes "••••••••••••••••••••••••••••••••";
197 }
198 close;
199 }
200 case 3:
201 next;
202 mes .@n$;
203 mes "Do you want to delete one process only or all processes?";
204 switch(select("Delete one process only:Delete all processes:Leave it as it is"))
205 {
206 case 1:
207 next;
208 mes .@n$;
209 mes "Please choose from what category you would like to delete a process.";
210 next;
211 switch(select("Player:Party:Guild"))
212 {
213 case 1:
214 next;
215 mes .@n$;
216 mes "Please input the player name you want to delete the process.";
217 input @deletename$;
218 next;
219 query_sql "SELECT `playername`, `reward_id`, `reward_amount` FROM `rewardplayernpc`", .@delete_name$, .@delete_item, .@delete_amount;
220 for (set @i, 0; @i < getarraysize(.@delete_name$); set @i, @i+1)
221 {
222 if(@deletename$ == .@delete_name$[@i])
223 {
224 mes .@n$;
225 mes "Deleting....";
226 query_sql "DELETE FROM `rewardplayernpc` WHERE `playername`='"+@deletename$+"'";
227 next;
228 mes .@n$;
229 mes "Deleted unclaimed process!";
230 close;
231 }
232 }
233 mes .@n$;
234 mes "Name doesn't exists in the logs!";
235 close;
236 case 2:
237 next;
238 mes .@n$;
239 mes "Please input the party name you want to delete the process.";
240 input @partydeletename$;
241 next;
242 query_sql "SELECT `partyname`, `reward_id`, `reward_amount` FROM `rewardpartynpc`", .@partydelete_name$, .@partydelete_item, .@partydelete_amount;
243 for (set @i, 0; @i < getarraysize(.@partydelete_name$); set @i, @i+1)
244 {
245 if(@partydeletename$ == .@partydelete_name$[@i])
246 {
247 mes .@n$;
248 mes "Deleting....";
249 query_sql "DELETE FROM `rewardpartynpc` WHERE `partyname`='"+@partydeletename$+"'";
250 next;
251 mes .@n$;
252 mes "Deleted unclaimed process!";
253 close;
254 }
255 }
256 mes .@n$;
257 mes "Party name doesn't exists in the logs!";
258 close;
259 case 3:
260 next;
261 mes .@n$;
262 mes "Please input the guild name you want to delete the process.";
263 input @guilddeletename$;
264 next;
265 query_sql "SELECT `guildname`, `reward_id`, `reward_amount` FROM `rewardguildnpc`", .@guilddelete_name$, .@guilddelete_item, .@guilddelete_amount;
266 for (set @i, 0; @i < getarraysize(.@guilddelete_name$); set @i, @i+1)
267 {
268 if(@guilddeletename$ == .@guilddelete_name$[@i])
269 {
270 mes .@n$;
271 mes "Deleting....";
272 query_sql "DELETE FROM `rewardguildnpc` WHERE `guildname`='"+@guilddeletename$+"'";
273 next;
274 mes .@n$;
275 mes "Deleted unclaimed process!";
276 close;
277 }
278 }
279 mes .@n$;
280 mes "Guild name doesn't exists in the logs!";
281 close;
282 }
283 case 2:
284 next;
285 mes .@n$;
286 mes "Please input DELETE to delete all the unclaimed processes.";
287 input @deleteall$;
288 if(@deleteall$ == "DELETE")
289 {
290 next;
291 mes .@n$;
292 mes "Deleting....";
293 query_sql "DELETE FROM `rewardplayernpc`";
294 query_sql "DELETE FROM `rewardpartynpc`";
295 query_sql "DELETE FROM `rewardguildnpc`";
296 next;
297 mes .@n$;
298 mes "Deleted all unclaimed processes!";
299 close;
300 }
301 next;
302 mes .@n$;
303 mes "Next time, please input DELETE correctly!";
304 close;
305 case 3:
306 next;
307 mes .@n$;
308 mes "Nothing Changed!";
309 close2;
310 end;
311 }
312 }
313 }
314 mes .@n$;
315 mes "Hello, "+strcharinfo(0)+"!";
316 next;
317 switch(Select("Claim Reward:Leave"))
318 {
319 case 1:
320 mes .@n$;
321 mes "From what category you want to claim your reward?";
322 next;
323 switch(select("Player:Party:Guild"))
324 {
325 case 1:
326 mes .@n$;
327 mes "Please enter your Name:";
328 input @winnername$;
329 if (@winnername$!=strcharinfo(0)){next; mes .@n$; mes "You are a fake!"; close; end; }
330 next;
331 query_sql "SELECT `playername`, `reward_id`, `reward_amount` FROM `rewardplayernpc`", .@available_name$, .@available_item, .@available_amount;
332 for (set @i, 0; @i < getarraysize(.@available_name$); set @i, @i+1)
333 {
334 if(@winnername$ == .@available_name$[@i])
335 {
336 mes .@n$;
337 mes "You get ^0000FF" + getitemname(.@available_item[@i]) + " - " + .@available_amount[@i] + " ea.^000000";
338 query_sql "DELETE FROM `rewardplayernpc` WHERE `playername`='"+@winnername$+"'";
339 getitem .@available_item[@i],.@available_amount[@i];
340 announce "Congratulations to "+strcahrinfo(0)+" who claimed his/her reward. Thank you!",0;
341 close;
342 }
343 }
344 mes .@n$;
345 mes "No rewards at the meantime";
346 mes "Get out!";
347 close;
348 case 2:
349 if( !getcharid(1) || getcharid(3) != getpartyleader( getcharid(1),1 ) ){next; mes .@n$; mes "Only party leaders are allowed here!"; close; end; }
350 mes .@n$;
351 mes "Please enter your party name:";
352 input @partywinnername$;
353 if (@partywinnername$!=strcharinfo(1)){next; mes .@n$; mes "You are a fake!"; close; end; }
354 next;
355 query_sql "SELECT `partyname`, `reward_id`, `reward_amount` FROM `rewardpartynpc`", .@partyavailable_name$, .@partyavailable_item, .@partyavailable_amount;
356 for (set @i, 0; @i < getarraysize(.@partyavailable_name$); set @i, @i+1)
357 {
358 if(@partywinnername$ == .@partyavailable_name$[@i])
359 {
360 mes .@n$;
361 mes "You get ^0000FF" + getitemname(.@partyavailable_item[@i]) + " - " + .@partyavailable_amount[@i] + " ea.^000000";
362 query_sql "DELETE FROM `rewardpartynpc` WHERE `partyname`='"+@partywinnername$+"'";
363 getitem .@partyavailable_item[@i],.@partyavailable_amount[@i];
364 announce "Congratulations to "+strcahrinfo(0)+" who claimed his/her reward. Thank you!",1;
365 close;
366 }
367 }
368 mes .@n$;
369 mes "No rewards at the meantime";
370 mes "Get out!";
371 close;
372 case 3:
373 set @guildid, getcharid(2);
374 if( !getcharid(2) || strcharinfo(0) != getguildmaster(@guildid) ){next; mes .@n$; mes "Only guild masters are allowed here!"; close; end; }
375 mes .@n$;
376 mes "Please enter your guild name:";
377 input @guildwinnername$;
378 if (@guildwinnername$!=strcharinfo(2)){next; mes .@n$; mes "You are a fake!"; close; end; }
379 next;
380 query_sql "SELECT `guildname`, `reward_id`, `reward_amount` FROM `rewardguildnpc`", .@guildavailable_name$, .@guildavailable_item, .@guildavailable_amount;
381 for (set @i, 0; @i < getarraysize(.@guildavailable_name$); set @i, @i+1)
382 {
383 if(@guildwinnername$ == .@guildavailable_name$[@i])
384 {
385 mes .@n$;
386 mes "You get ^0000FF" + getitemname(.@guildavailable_item[@i]) + " - " + .@guildavailable_amount[@i] + " ea.^000000";
387 query_sql "DELETE FROM `rewardguildnpc` WHERE `guildname`='"+@guildwinnername$+"'";
388 getitem .@guildavailable_item[@i],.@guildavailable_amount[@i];
389 announce "Congratulations to "+strcahrinfo(0)+" who claimed his/her reward. Thank you!",3;
390 close;
391 }
392 }
393 mes .@n$;
394 mes "No rewards at the meantime";
395 mes "Get out!";
396 close;
397 }
398 case 2:
399 mes .@n$;
400 mes "See yah.";
401 close;
402 }
403
404OnInit:
405 query_sql "CREATE TABLE IF NOT EXISTS `rewardplayernpc` (`playername` TINYTEXT NOT NULL, `reward_id` INT NOT NULL, `reward_amount` INT NOT NULL, INDEX `playername` (`playername`(32)) ) ENGINE=MyISAM";
406 query_sql "CREATE TABLE IF NOT EXISTS `rewardpartynpc` (`partyname` TINYTEXT NOT NULL, `reward_id` INT NOT NULL, `reward_amount` INT NOT NULL, INDEX `partyname` (`partyname`(32)) ) ENGINE=MyISAM";
407 query_sql "CREATE TABLE IF NOT EXISTS `rewardguildnpc` (`guildname` TINYTEXT NOT NULL, `reward_id` INT NOT NULL, `reward_amount` INT NOT NULL, INDEX `guildname` (`guildname`(32)) ) ENGINE=MyISAM";
408}
409
410/* Add npc's here (duplicate) ciao */
411
412prontera,130,191,6 duplicate(Rewards#101) Rewards NPC 100