Choose a radnom player[+REP]
#1

How can I choose a random player if one team has 0 members and send him a message
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)