[HELP] for(new i; i<GetMaxPlayers(); i++)... - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] for(new i; i<GetMaxPlayers(); i++)... (
/showthread.php?tid=194449)
[HELP] for(new i; i<GetMaxPlayers(); i++)... -
sushihusi - 29.11.2010
Hello!
I am creating a team deathmatch mode, but i have problems. The players start with 5 score and if they dead they get -1, if the kill somebody they get +1 score. If all the players in the team has 0 point, the team loose, if all the players in the team has 10 score, the team wins.
Код:
for(new i; i<GetMaxPlayers(); i++)
{
if(gTeam[i]==TEAM_ARMY)
{
if(GetPlayerScore(i)==0)
{
SendClientMessageToAll(COLOR_BLUE,"Las Venturas Army has lost the battle.");
}
}
}
It doesnt works, because if it ARMY team are 2 players for example id 0 and id 1, if id 0 has got score 0 and id 1 has got score 5, they loose the battle.
How to make this that not only id 0, but all players in the team must have score 0??
Re: [HELP] for(new i; i<GetMaxPlayers(); i++)... -
MadeMan - 29.11.2010
You need to check if at least 1 player in that team has score bigger than 0. If not, then team loses.
pawn Код:
new armylost=1;
for(new i; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i]==TEAM_ARMY)
{
if(GetPlayerScore(i) > 0)
{
armylost = 0;
break;
}
}
}
}
if(armylost == 1)
{
SendClientMessageToAll(COLOR_BLUE,"Las Venturas Army has lost the battle.");
}
Re: [HELP] for(new i; i<GetMaxPlayers(); i++)... -
sushihusi - 29.11.2010
So if it looks like this, if there a 100 players in team, every player must have score 0 to loose the battle??
Re: [HELP] for(new i; i<GetMaxPlayers(); i++)... -
MadeMan - 29.11.2010
Quote:
Originally Posted by sushihusi
So if it looks like this, if there a 100 players in team, every player must have score 0 to loose the battle??
|
Yes, that's what it does.