Jump to content
  • 0
Sign in to follow this  
Hakuren

About random different item in a array

Question

Hi hercules,

 

Request :

- Can i request a script that gives 5 different items in a array.

 

Example :

- i got setarray .@item_ids, 501,502,503,504,505,506,507,508,509,510;

 

Randomly give 5 different items on that array at the sametime

 

Thank you in advance. :D

Edited by Hakuren

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

If the items can be repeated:

 

setarray .@items , ....;
for(.@i = 0; .@i < 5; ++.@i)
getitem .@items[rand(getarraysize(.@items))],1;
end;/close;

If they cant be repeated:

setarray .@items , ....;
for(.@i = 0; .@i < 5; ++.@i){
.@removed = rand(getarraysize(.@items));
getitem .@items[.@removed],1;
deletearray .@items[.@removed],1;
}
end;/close;

just be sure that you use setarray everytime the script is called, since it removes from the array :3

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

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