From a83e9f34e7244db4810a98274feed83006a6086a Mon Sep 17 00:00:00 2001 From: Atemo Date: Wed, 14 Aug 2019 16:24:14 +0200 Subject: [PATCH] Updated Euphy's WoE controller using the new mail script command (#4243) * Splitted the item reward and zeny to support multi-reward by mail Thanks to @burningFlower74, @Lemongrass3110 ! --- npc/custom/woe_controller.txt | 51 ++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/npc/custom/woe_controller.txt b/npc/custom/woe_controller.txt index 65d1966c5a..55be8a11da 100644 --- a/npc/custom/woe_controller.txt +++ b/npc/custom/woe_controller.txt @@ -53,7 +53,7 @@ OnInit: // [1] Enable rewards. // [2] Mail all rewards. // - If not set, players receive items in their inventory. -// - Only ONE item can be sent via mail, plus Zeny. +// - Only ONE item can be sent via mail for PACKETVER < 20150513 while later clients are limited to MAIL_MAX_ITEM (5). // - Note that offline players do NOT receive rewards. // [4] Only reward Guild Masters. // - If not set, all guild members are rewarded. @@ -67,9 +67,13 @@ OnInit: set .Options, 1|8; // Rewards per castle. - // -- when given directly: ,{,,,...} - // -- via mail (option 2): ,, - setarray .Reward[0],14001,1; + // setarray .reward_id[0], {,,...} + // setarray .reward_amount[0], {,,...} + setarray .reward_id[0],14001; + setarray .reward_amount[0],1; + + // Zeny reward: + .reward_zeny = 0; // ----------------------------------------------------------- // Constants (leave this section alone). @@ -91,6 +95,7 @@ OnInit: // ----------------------------------------------------------- + .reward_id_size = getarraysize(.reward_id); set .Size, getarraysize($WOE_CONTROL); if (.AutoKick || .NoOwner) for(set .@i,0; .@i<30; set .@i,.@i+1) { @@ -160,10 +165,13 @@ function Add_Zero { } OnReward: + if (!.reward_id_size && !.reward_zeny) + return; + set .@sql$, ((.Options&4)?"position = 0":"online = 1"); if (.Options&2) set .@str$,gettimestr("%B %d, %Y",21); freeloop(1); - for(set .@i,0; .@i<30; set .@i,.@i+1) + for(set .@i,0; .@i<30; set .@i,.@i+1) { if (getarg(0)&(1<<.@i)) { set .@gid, getcastledata(.Castles$[.@i],1); if (!.@gid) continue; @@ -175,22 +183,35 @@ OnReward: setd ".@ip_"+.@i+"_"+.@ip$,1; } if (.Options&2) { - query_sql("INSERT INTO `mail` (send_name,dest_id,title,message,nameid,amount,identify,zeny,time) VALUES ("+ - "'no-reply',"+.@cid[.@j]+",'** Siege Reward: "+getcastlename(.Castles$[.@i])+" **',"+ - "'Brave one,% % Congratulations!% Your guild has successfully occupied% territory in the War of Emperium on% "+.@str$+".% % % % % [ Your reward is attached. ]',"+ - .Reward[0]+","+.Reward[1]+",0,"+.Reward[2]+",UNIX_TIMESTAMP(NOW()))"); - if (!getd(".@str_"+.@cid[.@j]) && isloggedin(.@aid[.@j],.@cid[.@j])) { + .@charid = .@cid[.@j]; + .@sender$ = "no-reply"; + .@title$ = "** Siege Reward: "+getcastlename(.Castles$[.@i])+" **"; + .@body$ = "Brave one,\r\n \r\n Congratulations!\r\n Your guild has successfully occupied\r\n territory in the War of Emperium on\r\n "+.@str$+".\r\n \r\n \r\n \r\n \r\n [ Your reward is attached. ]"; + + if (.reward_id_size) + mail .@charid, .@sender$, .@title$, .@body$, .reward_zeny, .reward_id, .reward_amount; + else + mail .@charid, .@sender$, .@title$, .@body$, .reward_zeny; + + if (PACKETVER < 20150513 && !getd(".@str_"+.@cid[.@j]) && isloggedin(.@aid[.@j],.@cid[.@j])) { setd ".@str_"+.@cid[.@j],1; - message rid2name(.@aid[.@j]),"You've got mail! Please re-login to update your mailing list."; + message rid2name(.@aid[.@j]),"You've got mail!"; } } else if (isloggedin(.@aid[.@j])) { - for(set .@k,0; .@k