Jump to content
  • 0

Array mistake.


Auryn

Question


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   1
  • Joined:  01/26/12
  • Last Seen:  

Hi, I would need some support on my script.

I'm only getting the last reward ID from the reward item list, I don't understand why.

I assume I don't need $ after the variable here.

setarray .RewardList[0],969,607,7539;
setarray .RewardAmount[0],2,5,15;

OnKilled:
getitem .RewardList[.Reward],.RewardAmount[.Reward];
announce strcharinfo(0)+" a croisé la route d'un Gold Poring.",0;

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1132
  • Joined:  05/27/12
  • Last Seen:  

You should read more about arrays first: http://rathena.org/wiki/Variables#Array_Variables

The problem should be clear:

.RewardList[.Reward]

Where .Reward is never defined, defaulting to "0". To loop through an entire array, you'd use, well, a loop:

for(set .@i,0; .@i<getarraysize(.RewardList); set .@i,.@i+1)
   getitem .RewardList[.@i],.RewardAmount[.@i];

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  5
  • Reputation:   0
  • Joined:  05/22/12
  • Last Seen:  

I think he's referring to his own script earlier on a recent topic anyways I rescripted it for him.

- script goldporing -1,{
OnClock0000:
goto spawn_gp;

//This is if you want to just whisper npc:goldporing instead of clicking an NPC
//Change 99 to your desired GM level that will be able to access the NPC by whisper

OnWhisperGlobal:
if(getgmlevel() < 99) end;
menu "Start Event",-,"Exit",exit_gp;

spawn_gp:
setarray .MapList$[0],"payon","prontera","izlude","geffen";
setarray .RewardList[0],969,607,739;
setarray .RewardAmount[0],2,5,15;
set .Map, rand(getarraysize(.MapList$));
set .randpicklist, rand(getarraysize(.RewardList));
set .randpickamount, rand(getarraysize(.RewardAmount));
announce "Un nouveau Gold Poring est apparu quelque part dans "+.Maplist$[.Map]+"!",0;
monster .MapList$[.Map],0,0,"Gold Poring",2248,1,strnpcinfo(0)+"::OnGPKilled";
end;

exit_gp:
mes "[Gold Poring Event]";
mes "Adios, "+strcharinfo(0)+"!";
close;

OnGPKilled:
getitem .RewardList[.randpicklist],rand(.randpickamount);
announce strcharinfo(0)+" a trouvé le Gold Poring à "+.MapList$[.Map]+".",0;
end;
}

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