Random playerID? - 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 playerID? (
/showthread.php?tid=371133)
Random playerID? -
ValentinLaw - 22.08.2012
So lets say I have this code:
PHP код:
SendClientMessage(playerid, COLOR_GREEN, "You're the one who got randomly picked, and won 500$!");
The server will pick a random "playerid", and will send the message up (^) to that player. Is it possible? Thanks already :>
Re: Random playerID? -
ValentinLaw - 22.08.2012
Edit: Nevermind it didn't work. :/ Any of you got any ideas?
Re: Random playerID? - HuSs3n - 22.08.2012
include foreach
https://sampforum.blast.hk/showthread.php?tid=92679
and use Iter_Random(Player);
pawn Код:
SendClientMessage(Iter_Random(Player), COLOR_GREEN, "You're the one who got randomly picked, and won 500$!");
Re: Random playerID? -
ValentinLaw - 22.08.2012
Is it possible to choose a random vehicleID?
Re: Random playerID? - HuSs3n - 22.08.2012
there are many ways to do that.
if you want to use foreach:
pawn Код:
//OnTop
new Iterator:Vehicle<MAX_VEHICLES>;
//Replace Your CreateVehicle Lines with this
Iter_Add(Vehicle, CreateVehicle(....................................................));
Iter_Add(Vehicle, CreateVehicle(....................................................));
Iter_Add(Vehicle, CreateVehicle(....................................................));
Iter_Add(Vehicle, CreateVehicle(....................................................));
//Then , to choose a random vehicle use this
Iter_Random(Vehicle);