small problem
#1

My pawno crashes when I add this:

pawn Код:
stock GetPlayersCountInTeam(teamid)
{
     new playercount = 0;
     for(new x = 0; x < MAX_PLAYERS; x ++)
     {
           if(GetPlayerState(x) == PLAYER_STATE_NONE) continue;
           if(GetPlayerTeam(x) != teamid) continue;
           playercount++;
     }
     return playercount;
}
an add this at the top:
pawn Код:
new         bluecount = GetPlayersCountInTeam(TEAM_HOME); // The team count of the home team.
new         redcount = GetPlayersCountInTeam(TEAM_AWAY);
Anyone know why?
Reply
#2

You can't call functions outside of functions. The count of the players will change later on anyway so instead of retrieving it during variable creation, retrieve it when you need it.
Reply
#3

Ah yeah, thanks alot I accidentally forgot to move the new at the top to where it's actually needed, thanks alot for that reminder, it is now fixed!

Thanks again! + rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)