18.12.2011, 13:52
hi,
i have this team balance but its bugged.
The looping and counting of the team members works but not the if statement.
print1 shows team police = 0 and team terror = 0. thats right cause it is resettet before a new looping begins as u can see in the code.
prin2 shows the right team count as well this time with the looping count.
if print2 shows e.g. 0:1 it doesnt let me spawn on both teams. always writing its full on both teams why?
The looping works as the print shows but not the if statements...
i hope u can help me.
i have this team balance but its bugged.
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
CountPolice = 0;
CountTerrorists = 0;
//print1
new stringg[128];
format(stringg,sizeof(stringg)," police: %d terrorist: %d",CountPolice,CountTerrorists);
SendClientMessage(playerid, 0xE100E1FF, stringg);
foreach (Player, i)
{
if(gTeam[i] == TEAM_POLICE)
{
CountPolice++;
}
if(gTeam[i] == TEAM_TERRORISTS)
{
CountTerrorists++;
}
}
//print2
new stringg[128];
format(stringg,sizeof(stringg)," police: %d terrorist: %d",CountPolice,CountTerrorists);
SendClientMessage(playerid, 0xE100E1FF, stringg);
if(gTeam[playerid] == TEAM_POLICE && CountPolice > CountTerrorists)
{
SendClientMessage(playerid, 0xE100E1FF, "join other team");
GameTextForPlayer(playerid, "full!", 2000, 5);
return 0;
}
if(gTeam[playerid] == TEAM_TERRORISTS && CountPolice < CountTerrorists)
{
SendClientMessage(playerid, 0xE100E1FF, "join other team");
GameTextForPlayer(playerid, "full!", 2000, 5);
return 0;
}
return 1;
}
print1 shows team police = 0 and team terror = 0. thats right cause it is resettet before a new looping begins as u can see in the code.
prin2 shows the right team count as well this time with the looping count.
if print2 shows e.g. 0:1 it doesnt let me spawn on both teams. always writing its full on both teams why?
The looping works as the print shows but not the if statements...
i hope u can help me.