astralprojection 35 Posted March 15, 2019 - 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 can i ask help on this to pick 10 random items from array with no duplicate and create new array on the picked items? Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted March 16, 2019 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; } Quote Share this post Link to post Share on other sites
- 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
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