small 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: small problem (
/showthread.php?tid=427485)
small problem -
(_AcE_) - 01.04.2013
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?
Re: small problem -
SuperViper - 01.04.2013
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.
Re: small problem -
(_AcE_) - 01.04.2013
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