SA-MP Forums Archive
Assigning the number to a player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Assigning the number to a player (/showthread.php?tid=551908)



Assigning the number to a player - kamiliuxliuxliux - 21.12.2014

Let's say I have numbers: 0, 1, 2, 3, 4.
And there are 3 players. Each of those numbers must be assigned to each player randomly, but NOT THE SAME. How?
Maybe there's an algorythm to do such things...? Hope you understood me.



Re: Assigning the number to a player - Vince - 21.12.2014

Put them in an array, shuffle the array and then assign sequentially. Here's an implementation in C++, but shouldn't be too hard to adapt to Pawn: http://www.geeksforgeeks.org/shuffle-a-given-array/


Re: Assigning the number to a player - kamiliuxliuxliux - 21.12.2014

Thank you!