Auryn Posted August 7, 2012 Group: Members Topic Count: 69 Topics Per Day: 0.01 Content Count: 147 Reputation: 1 Joined: 01/26/12 Last Seen: April 27, 2018 Share Posted August 7, 2012 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; Quote Link to comment Share on other sites More sharing options...
Euphy Posted August 7, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted August 7, 2012 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]; 1 Quote Link to comment Share on other sites More sharing options...
Verunix Posted August 7, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 5 Reputation: 0 Joined: 05/22/12 Last Seen: April 2, 2015 Share Posted August 7, 2012 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; } Quote Link to comment Share on other sites More sharing options...
Question
Auryn
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.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.