Choose a radnom player[+REP] - 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: Choose a radnom player[+REP] (
/showthread.php?tid=564057)
Choose a radnom player[+REP] -
Kruno88 - 19.02.2015
How can I choose a random player if one team has 0 members and send him a message
Re: Choose a radnom player[+REP] -
CalvinC - 19.02.2015
Use "random" to send the msg to a random person:
https://sampwiki.blast.hk/wiki/Random
I made a code you can take a look at:
pawn Код:
new count[3], randomid; // Define "count" and "randomid"
foreach(Player, i) // Loop through all connected players and define them as "i"
{
switch(GetPlayerTeam(i)) // Starts a switch to find the team of "i"
{
case 0: count[0] ++; // If "i"'s team is 0, it increases count[0] by one
case 1: count[1] ++; // If "i"'s team is 1, it increases count[1] by one
case 2: count[2] ++; // If "i"'s team is 2, it increases count[2] by one
}
randomid = random(sizeof(i)); // Declares "randomid" as a random value between "i"
// Not sure this ^ will work, i haven't tested it
}
if(count[0] == 0 || count[1] == 0 || count[2] == 0) SendClientMessage(randomid, -1, "One of the teams has 0 members.");
// Sends "randomid" (which was declared above) a message, if one of the "count"'s is 0
I don't think the randomid will work, and i cannot really test it, but it should give you a general idea.