SA-MP Forums Archive
Random Player Choosing - 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: Random Player Choosing (/showthread.php?tid=432984)



Random Player Choosing - JaKe Elite - 25.04.2013

I'm creating a gamemode.

Which selects Random Player to become one notorious gangster.

How can i make it?


Re: Random Player Choosing - MP2 - 25.04.2013

Use foreach. It has Iter_random() which is a very good way of doing this as it's very efficient (as foreach is as a whole).

https://sampforum.blast.hk/showthread.php?tid=92679


Re: Random Player Choosing - JaKe Elite - 25.04.2013

is it something like Iter_Random(MAX_PLAYERS); ?


Re: Random Player Choosing - MP2 - 25.04.2013

Iter_Random(Player);

Literally 'Player' - not an ID or anything. Type EXACTLY that.


Re: Random Player Choosing - JaKe Elite - 25.04.2013

So exactly something like this?

pawn Код:
new rando = Iter_Random(Player);

//Exmaple

GangLeader[rando] = 1;



Re: Random Player Choosing - MP2 - 25.04.2013

The random bit is okay, but the variable assignment seems wrong. Surely it'd be something like

pawn Код:
new randPlayer = Iter_Random(Player);

//Exmaple

GangLeader[GANG_BALLAS] = randPlayer;
Also, 'rando' is a very, uh, I don't know, it's just silly. Name things better.


Re: Random Player Choosing - JaKe Elite - 25.04.2013

thanks