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

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

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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