How create a count for team ?
#1

Hi,

I need some help for my server :

I created a command (same idea that robbery in bank) but i want this command work ONLY if there is at least one member of the other team connected...

How can i do ?

Thanks for you help,

See you,

Guillaume.
Reply
#2

Make a counter variable, increment it by 1 on player connect? :P
Reply
#3

Use for loop and check how many players are on from the team.


pawn Код:
new TeamPlayerCount;
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(playerid)){
        if(Team[i] == Team[playerid])
        {
            TeamPlayerCount++;
        }
        if(TeamPlayerCount <= 0){
            //none is online..
        }
    }
}
Reply
#4

Quote:
Originally Posted by Tayab
Посмотреть сообщение
Use for loop and check how many players are on from the team.


pawn Код:
new TeamPlayerCount;
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(playerid)){
        if(Team[i] == Team[playerid])
        {
            TeamPlayerCount++;
        }
        if(TeamPlayerCount <= 0){
            //none is online..
        }
    }
}
... a rather inefficient method. You should go for the OnPlayerConnect() idea.
Reply
#5

Thanks for replies.
Quote:

new TeamPlayerCount;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(playerid)){
if(Team[i] == Team[playerid])
{
TeamPlayerCount++;
}
if(TeamPlayerCount <= 0){
//none is online..
}
}
}

It seems perfect, so i can put my code until this ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)