Jump to content
  • 0
Sign in to follow this  
mcNyj

Need assistance debugging a Race to 99 script.

Question

Posted (edited)

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	[email protected][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	[email protected][0], Job_Soul_Linker, Job_Star_Gladiator, Job_Ninja, Job_Gunslinger;
	setarray	[email protected][0], 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518;
	setarray	[email protected][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 ([email protected] = 0; [email protected] < getarraysize([email protected]); [email protected]++) {
				if (Class == [email protected][[email protected]] && JobLevel == 70) {
					if (getarraysize([email protected][[email protected]]) == 0) {	
						set [email protected][[email protected][0]], strcharinfo(0);
						set retrieved, 1;
						mail getcharid(0), "Sender", "Race to 99", 0, [email protected][[email protected]], 1, 0, 0, 0, 0, 0;
						announce "Congratulations " + strcharinfo(0) + " for being the first " + jobname(Class) + " to reach Max Level!",0;
					}
					else if (getarraysize([email protected][[email protected]]) == 1) {
						set [email protected][[email protected][1]], strcharinfo(0);
						set retrieved, 1;
						mail getcharid(0), "Sender", "Race to 99", 0, [email protected][[email protected]], 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 ([email protected] = 13; [email protected] < 17; [email protected]++) {
				if (Class == [email protected][[email protected]] && JobLevel == 50 && [email protected][[email protected]+13] < 1) {
					if (getarraysize([email protected][[email protected]+13]) == 0) {	
						set [email protected][[email protected][0]], strcharinfo(0);	
						set retrieved, 1;
						mail getcharid(0), "Sender", "Race to 99", 0, [email protected][[email protected]+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([email protected][[email protected]]) == 1) {
						set [email protected][[email protected][1]], strcharinfo(0);
						set retrieved, 1;
						mail getcharid(0), "Sender", "Race to 99", 0, [email protected][[email protected]+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([email protected][17]) == 0) {
					set [email protected][$racesn[0]], strcharinfo(0);
					set retrieved, 1;
					mail getcharid(0), "Sender", "Race to 99", 0, [email protected][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([email protected][17]) == 1) {
					set [email protected][$racesn[0]], strcharinfo(0);
					set retrieved, 1;
					mail getcharid(0), "Sender", "Race to 99", 0, [email protected][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. 

Edited by mcNyj

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I don´t know if you can specify what is exactly not workin, but in any case... I see some strange things like:

set [email protected][[email protected][0]], strcharinfo(0);

if limits are:

setarray   [email protected][0], $racelk$racepally$racehw$raceprof$racesniper$raceclown$racegypsy$racehp$racechamp$racews$racecreo$racesinx$racestalker$racesl$racesg$raceninja$racegs$racesn;
and [email protected] is not an array, that makes no sense for me... it should be just [email protected][[email protected]]
 
Also the first part of the script when you declare some of the variables with the jobs involved... there is nothing calling that part, right? I was expecting some OnInit label or something, but maybe this is not all the code.

Share this post


Link to post
Share on other sites
  • 0

So basically what I was hoping for the [email protected][[email protected][0]] is to store the IGN of the player after they receive the reward. I wanted the character names to be in an array, which the arrays of the character names being in another array for all the classes. Not entirely sure if it actually works that way, but from researching for C++ coding to pull an element in an array within an array, I was told to do something like array[0][0], so I tried that. Thinking back and using more of my brain, Maybe it should be [email protected][[email protected]][0]. 
 

for the part where I declare the classes, I just wanted them to be in an array, so that I could run in the for loop to check their job. And since there different job level requirements, I had them in 3 different arrays for 3 different if statements. 
 

im gonna try out the [email protected] change later when I’m back from my travels, and I’ll update on if it works. Anyhow, thanks for the reply! 

Share this post


Link to post
Share on other sites
  • 0

The scripting language is pretty primitive and while I don't have time to completely review your script associative arrays are not a thing. By just glancing and reading through what you've posted that's what I think you're trying to accomplish... There are some ways of making something similar though, but it is not recommended for multiple repetitions because it's cumbersome.

Anyways...

setarray [email protected]$, "greg", "frank", "ashe";

Works...

setarray [email protected], "greg", "frank", "ashe";

Doesn't Work.

 

Furthermore:

[email protected] = getarraysize([email protected]$);
for([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
    for([email protected] = 1; [email protected] < 11; [email protected]++) {
        setd "[email protected]_"[email protected]$[[email protected]]+"_things["[email protected]+"]", [email protected];
    }
}

In this example I create 3 new arrays from the [email protected]$ array above...

[email protected]_greg_things = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

[email protected]_frank_things = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

[email protected]_ashe_things = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

I'm by no means saying this is best practice but it's something that can be done.

I'm pretty sure...

setarray getd("[email protected]_"[email protected]$[0]+"_things"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

Will also work to create an array like...
[email protected]_greg_things = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

I could then access gerg's values like...

mes "Greg's first value is... "+getd("[email protected]_"[email protected]$[0]+"_things[0]");

Output would be Greg's first value is... 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.