15.03.2010, 17:20
I started coding a new game mode this weekend and it's almost finished. I just need to figure out how to check if all players on one team are dead, and then return a value if they are. How would one do this?
new TeamA[MAX_PLAYERS];
new TeamB[MAX_PLAYERS];
new TeamAalive;
new TeamBalive;
if(TeamA[playerid]==1) TeamAalive--;
if(TeamB[playerid]==1) TeamBalive--;
if(TeamAalive<=0)
{
// whatever you do here
}
if(TeamBalive<=0)
{
// whatever you do here
}
new PlayerDead[MAX_PLAYERS];//Global Variable ------------------------------------------------ //Somewhere in OnPlayerSpawn PlayerDead[playerid] = 0; ------------------------------------------------------ //Somewhere in OnPlayerDeath PlayerDead[playerid] = 1; ------------------------------------------------------ //Function public IsTeamDead(teamid)//Will return true if all members of this team is dead { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(GetPlayerTeam(i) == teamid) { if(PlayerDead[playerid] == 0)//if player alive return 0; } } } return 1; }
Originally Posted by Sinyavski
Also, somethink like this should work:
Код:
new PlayerDead[MAX_PLAYERS];//Global Variable ------------------------------------------------ //Somewhere in OnPlayerSpawn PlayerDead[playerid] = 0; ------------------------------------------------------ //Somewhere in OnPlayerDeath PlayerDead[playerid] = 1; ------------------------------------------------------ //Function public IsTeamDead(teamid)//Will return true if all members of this team is dead { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(GetPlayerTeam(i) == teamid) { if(PlayerDead[playerid] == 0)//if player alive return 0; } } } return 1; } |