Team limit problem
#1

Hi everyone,

I have a problem, I wanted to limit the players of team MERC and NINJA on my server.

To achieve that, I've put a counter, to count the number of MERCS and NINJAS.

However, in the callback "OnPlayerDisconnect", I don't want the counter to decrease when the player is choosing a class...

Here's my code :


Код:
public OnPlayerDisconnect(playerid, reason)
{



if(gTeam[playerid] == MERC) {
MERC_COUNT--; 
printf("Il y a %d mercenaire (disconnect)",MERC_COUNT);
}
else if(gTeam[playerid] == NINJA) {
NINJA_COUNT--; 
printf("Il y a %d ninja (disconnect)",NINJA_COUNT);
}

else{
printf("Disconnected without choosing class");
}

}
Reply
#2

You can also use a loop to prevent a player choose a full team.

pawn Код:
#define MAX_MERCS 10
#define MAX_NINJAS 10

// When the player try to choose a class, i guess you are using OnPlayerRequestClass, so at OnPlayerRequestSpawn do this:
public OnPlayerRequestSpawn(playerid,classid)
{
    new count;
    if(classid == A MERC CLASS)
    {
        for(new a; a < MAX_PLAYERS; ++ a)
        {
            if(IsPlayerConnected(a) && gTeam[a] == MERC)
                count ++;
        }
    }
    else if(classid == some ninja class)
    {
        for(new a; a < MAX_PLAYERS; ++a)
        {
            if(IsPlayerConected(a) && gTeam[a] == NINJA)
               count++;
        }
    }
    if(count >= MAX_MERCS || count >= MAX_NINJAS)
        return SendClientMessage(playerid,-1,"The chosen team is full!");
    return 1;
}
Reply
#3

You helped me two times today, thank you very much !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)