Jump to content
  • 0

Array not working


grobyczen

Question


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

Hi,

 

I'm trying to make a script that erases a fixed set of variables. When I do it one by one like this:

 

prontera,156,174,4	script	Reset	752,{
	mes "La variable Z es igual a:";
	mes  $Z;
	mes "Resetear variable Z a:";
	input $Z;
	next;
	mes "La variable rossata es igual a:";
	mes  $rossata;
	mes "Resetear variable rossata a:";
	input $rossata;
		next;
	mes "La variable dullahan es igual a:";
	mes  $dullahan;
	mes "Resetear variable dullahan a:";
	input $dullahan;	
		next;
	mes "La variable cachorro es igual a:";
	mes  $cachorro;
	mes "Resetear variable cachorro a:";
	input $cachorro;	
		next;
	mes "La variable $teo es igual a:";
	mes  $teo;
	mes "Resetear variable $teo a:";
	input $teo;	
	
		close2;
		end;
		
}

It works fine. I input the values, and they stay that way.

 

But when I try to use arrays, like this:

 

prontera,156,174,4	script	Reset	752,{
	
setarray .@resetnam$[0],"recluta","$Z","$rossata","$dullahan","$cachorro","$teo";
setarray .@reset[0],recluta,$Z,$rossata,$dullahan,$cachorro,$teo;
	

	cleararray .@reset[0],0,(getarraysize(.@resetnam$[0]));
	mes "Estado de las variables:";
		for (.@i=0; .@i < (getarraysize(.@resetnam$[0])); .@i=.@i+1)	{	
					
					mes .@resetnam$[.@i]+" = "+.@reset[.@i];
												}
	close;			
}//end script

... the message window in the client  shows me that all the values are now 0, but they really are not because when I close the "Reset" NPC and check the values on another NPC, they're back to the value they had before I used the "Reset" NPC.

 

Any help to make the array changes work?

 

Thanks in advance.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

cleararray only clear that particular array not other variable ...

 

if you are refering to these variable..

recluta,$Z,$rossata,$dullahan,$cachorro,$teo;

you have to set these variable to "0" if you want to remove it.

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...