• 0
Sign in to follow this  
Followers 0
astralprojection

Pick item from array

Question

-	script	test	-1,{
	setarray([email protected], <pick 10 items from [email protected][1]);
	mes("Your missions are;");
	mes("Mission 1: "[email protected][1];
	mes("Mission 2: "[email protected][2];
	mes("Mission 3: "[email protected][3];
	mes("Mission 4: "[email protected][4];
	mes("Mission 5: "[email protected][5];
	mes("Mission 6: "[email protected][6];
	mes("Mission 7: "[email protected][7];
	mes("Mission 8: "[email protected][8];
	mes("Mission 9: "[email protected][9];
	mes("Mission 10: "[email protected][10];
	close();
	
OnInit:
	setarray([email protected][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

  • 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0