[HELP] for(new i; i<GetMaxPlayers(); i++)...
#1

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??
Reply
#2

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.");
}
Reply
#3

So if it looks like this, if there a 100 players in team, every player must have score 0 to loose the battle??
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)