Jump to content
  • 0

Need assistance debugging a Race to 99 script.


mcNyj

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  12/13/20
  • Last Seen:  

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. 

Edited by mcNyj
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  26
  • Reputation:   1
  • Joined:  06/25/16
  • Last Seen:  

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

set .@limits[.@i[0]], strcharinfo(0);

if limits are:

setarray   .@limits[0], $racelk$racepally$racehw$raceprof$racesniper$raceclown$racegypsy$racehp$racechamp$racews$racecreo$racesinx$racestalker$racesl$racesg$raceninja$racegs$racesn;
and .@i is not an array, that makes no sense for me... it should be just .@limits[.@i]
 
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.
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  12/13/20
  • Last Seen:  

So basically what I was hoping for the .@limits[.@i[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 .@limits[.@i][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 .@limits change later when I’m back from my travels, and I’ll update on if it works. Anyhow, thanks for the reply! 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   381
  • Joined:  02/03/12
  • Last Seen:  

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 .@names$, "greg", "frank", "ashe";

Works...

setarray .@names, "greg", "frank", "ashe";

Doesn't Work.

 

Furthermore:

.@len = getarraysize(.@names$);
for(.@a = 0; .@a < .@len; .@a++) {
    for(.@j = 1; .@j < 11; .@j++) {
        setd ".@player_"+.@names$[.@a]+"_things["+.@j+"]", .@j;
    }
}

In this example I create 3 new arrays from the .@names$ array above...

.@player_greg_things = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

.@player_frank_things = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

.@player_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(".@player_"+.@names$[0]+"_things"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;

Will also work to create an array like...
.@player_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(".@player_"+.@names$[0]+"_things[0]");

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

Link to comment
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.

×
×
  • Create New...