Jump to content
  • 0
Sign in to follow this  
astralprojection

Pick item from array

Question

-	script	test	-1,{
	setarray(.@newarray, <pick 10 items from .@mission[1]);
	mes("Your missions are;");
	mes("Mission 1: "+.@newarray[1];
	mes("Mission 2: "+.@newarray[2];
	mes("Mission 3: "+.@newarray[3];
	mes("Mission 4: "+.@newarray[4];
	mes("Mission 5: "+.@newarray[5];
	mes("Mission 6: "+.@newarray[6];
	mes("Mission 7: "+.@newarray[7];
	mes("Mission 8: "+.@newarray[8];
	mes("Mission 9: "+.@newarray[9];
	mes("Mission 10: "+.@newarray[10];
	close();
	
OnInit:
	setarray(.@mission[1],50001,50002,50003,50004,50005,50006,50007,50008,50009,50010,50011,50012,50013,50014,50015,50016,50017);
	end;

To the script Guru out there :D

can i ask help on this to pick 10 random items from array with no duplicate and create new array on the picked items?
 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

https://github.com/AnnieRuru/Release/blob/master/Guides/Shuffle Algorithm.md

prontera,157,180,4	script	Option Master	4_DOG01,{
	mes "Your missions are;";
	F_ShuffleNumbers 0, .size -1, .@r, 10;
	for ( .@i = 0; .@i < 10; ++.@i )
		mesf "Mission %d: %d", .@i +1, .mission[.@r[.@i]];
	close;
OnInit:
	for ( .@i = 1; .@i <= 17; ++.@i )
		.mission[.@i -1] = .@i + 50000;
	.size = getarraysize(.mission);
	end;
}

 

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.