I've recently attempted to write a script for race to 99, and it's not working for some reason. The only bug detected on the map server is the duplicate name thing, which could be fixed easily later and i don't think it's the cause.
So basically how I want the script to work is that 2 players of each of the classes will be mailed an item via rodex. Aside from that, there will be an announcement to the server if he/she is the first or second person to reach max level, etc. The following is the script I've wrote, I've went through it multiple times, couldn't figure out why it's not working. By not working, i meant the reward wouldn't be sent, and no announcement was made when the character reached maxed level for their respective class. Since I'm using OnPCLoginEvent, I've tested it via relogging.
I'm also storing character names for an npc that shows who are the players that won the race to 99, and I've got that covered and working fine.
- script Race to 99 -1,{
set retrieved,0;
setarray $racelk,"";
setarray $racepally,"";
setarray $racehw,"";
setarray $raceprof,"";
setarray $racesniper,"";
setarray $raceclown,"";
setarray $racegypsy,"";
setarray $racehp,"";
setarray $racechamp,"";
setarray $racews,"";
setarray $racecreo,"";
setarray $racesinx,"";
setarray $racestalker,"";
setarray $racesl,"";
setarray $racesg,"";
setarray $racegs,"";
setarray $racesn,"";
setarray .@transjobs[0], Job_Lord_Knight, Job_Paladin, Job_High_Wizard,Job_Professor, Job_Sniper, Job_Clown, Job_Gypsy,
Job_High_Priest, Job_Champion, Job_WhiteSmith, Job_Creator, Job_Assassin_Cross, Job_Stalker;
setarray .@extjobs[0], Job_Soul_Linker, Job_Star_Gladiator, Job_Ninja, Job_Gunslinger;
setarray .@rewards[0], 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518;
setarray .@limits[0], $racelk, $racepally, $racehw, $raceprof, $racesniper, $raceclown, $racegypsy, $racehp, $racechamp,
$racews, $racecreo, $racesinx, $racestalker, $racesl, $racesg, $raceninja, $racegs, $racesn;
OnPCLoginEvent:
if (BaseLevel == 99 && retrieved == 0){
for (.@i = 0; .@i < getarraysize(.@transjobs); .@i++) {
if (Class == .@transjobs[.@i] && JobLevel == 70) {
if (getarraysize(.@limits[.@i]) == 0) {
set .@limits[.@i[0]], strcharinfo(0);
set retrieved, 1;
mail getcharid(0), "Sender", "Race to 99", 0, .@rewards[.@i], 1, 0, 0, 0, 0, 0;
announce "Congratulations " + strcharinfo(0) + " for being the first " + jobname(Class) + " to reach Max Level!",0;
}
else if (getarraysize(.@limits[.@i]) == 1) {
set .@limits[.@i[1]], strcharinfo(0);
set retrieved, 1;
mail getcharid(0), "Sender", "Race to 99", 0, .@rewards[.@i], 1, 0, 0, 0, 0, 0;
announce "Congratulations " + strcharinfo(0) + " for being the second " + jobname(Class) + " to reach Max Level! This is the last reward for " + jobname(Class) + " class.",0;
}
}
}
for (.@i = 13; .@i < 17; .@i++) {
if (Class == .@extjobs[.@i] && JobLevel == 50 && .@limits[.@i+13] < 1) {
if (getarraysize(.@limits[.@i+13]) == 0) {
set .@limits[.@i[0]], strcharinfo(0);
set retrieved, 1;
mail getcharid(0), "Sender", "Race to 99", 0, .@rewards[.@i+13], 1, 0, 0, 0, 0, 0;
announce "Congratulations " + strcharinfo(0) + " for being the first " + jobname(Class) + " to reach Max Level!",0;
}
else if (getarraysize(.@limits[.@i]) == 1) {
set .@limits[.@i[1]], strcharinfo(0);
set retrieved, 1;
mail getcharid(0), "Sender", "Race to 99", 0, .@rewards[.@i+13], 1, 0, 0, 0, 0, 0;
announce "Congratulations " + strcharinfo(0) + " for being the second " + jobname(Class) + " to reach Max Level! This is the last reward for " + jobname(Class) + " class.",0;
}
}
}
if (Class == Job_Super_Novice && JobLevel == 99) {
if (getarraysize(.@limits[17]) == 0) {
set .@limits[$racesn[0]], strcharinfo(0);
set retrieved, 1;
mail getcharid(0), "Sender", "Race to 99", 0, .@rewards[17], 1, 0, 0, 0, 0, 0;
announce "Congratulations " + strcharinfo(0) + " for being the first " + jobname(Class) + " to reach Max Level!",0;
}
else if (getarraysize(.@limits[17]) == 1) {
set .@limits[$racesn[0]], strcharinfo(0);
set retrieved, 1;
mail getcharid(0), "Sender", "Race to 99", 0, .@rewards[17], 1, 0, 0, 0, 0, 0;
announce "Congratulations " + strcharinfo(0) + " for being the second " + jobname(Class) + " to reach Max Level! This is the last reward for " + jobname(Class) + " class.",0;
}
}
}
}
In addition, I know that the script is no where near optimal, so any suggestions would be greatly appreciated. Thanks in advance.