Random player
#1

ok i have a question ... how can i make a random player change team if all the players are in the same team !
i mean if all the player are in the same team : change a random player to an other team
Reply
#2

pawn Code:
stock ChooseRandomPlayer() // Function by Admantis
{
    new TMP, TOTAL; // Creates TMP and TOTAL
    for(new I = 0; I < MAX_PLAYERS; I++) // Player loop
    {
        if (IsPlayerConnected(I)) { TMP += 1; } // If player is connected, count is increased
    }
    TOTAL = random(TMP); // TOTAL is equal of the random of online players
    return TOTAL; // Returning a value (TOTAL)
}
Example:
pawn Code:
gTeam[ChooseRandomPlayer()] = 1;
SetPlayerTeam(ChooseRandomPlayer(), 1);
Reply
#3

what's about chйking if all the online players are in the same team ?
Reply
#4

pawn Code:
stock GetPlayersInTeam(team_id)
{
    new COUNT;
    for(new I = 0; I < MAX_PLAYERS; I++)
    {
        if (IsPlayerConnected(I))
        {
            if (GetPlayerTeam(I) == team_id) { COUNT += 1; }
        }
    }
    return COUNT;
}
Is this what you mean?
Reply
#5

Code:
         for(new i = 0; i < MAX_PLAYERS; i++)
	{
 		if(IsPlayerConnected(i) && (GetPlayerTeam(i)!= 2))
		{
			SetPlayerTeam(ChooseRandomPlayer(), 2)
		}
	}
is this corйct ?
is this will chang a random player to team 2 if all the players are in team 2 ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)