Team limit problem - 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: Team limit problem (
/showthread.php?tid=452473)
Team limit problem -
kurt225 - 21.07.2013
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");
}
}
Re: Team limit problem -
arakuta - 21.07.2013
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;
}
Re: Team limit problem -
kurt225 - 21.07.2013
You helped me two times today, thank you very much !