Need to know something
#7

This is how would go about doing it:

pawn Код:
new bool:flag = false;  // this flag will turn true if another person is found
                        // to be alive on the player's team
   
for(new i = 0; i < MAX_PLAYERS; i++) {  // loop through all players
    if(gTeam[i] == gTeam[playerid]) {   // is the current player in the loop on the same team as the player who died?
        if(GetPlayerState(i) != PLAYER_STATE_SPECTATING) {  // is the team-mate still alive?
            if(!flag) { // has an alive team-mate been found yet?
                TogglePlayerSpectating(playerid, 1);
                PlayerSpectatePlayer(playerid, i); // spectate the team-mate who is alive!
                flag = true; // set flag to true, to indicate there has been an alive team-mate found
            }
        }
    }
}
   
if(!flag) { // loop has finished, was an alive team-mate found?
    MapChange(); // no alive team-mates found, initiate the MapChange method!
}
Sorry for the comment spam, I tried to make it clear exactly what is happening! In this solution, I have assumed that the variable gTeam[] holds an integer value that represents the "team ID" that a player is in.

I do have a suggestion regarding the MapChange() method: give it a parameter so that it knows which team has just lost. For example: MapChange(gTeam[playerid]) would tell the MapChange method that this player's team has just lost. If you have already thought of doing this, then just ignore me
Reply


Messages In This Thread
Need to know something - by Lorenc_ - 17.12.2010, 09:16
Re: Need to know something - by XePloiT - 17.12.2010, 10:57
Re: Need to know something - by Lorenc_ - 17.12.2010, 11:09
Re: Need to know something - by Lorenc_ - 17.12.2010, 22:38
Re: Need to know something - by MestreKiller - 17.12.2010, 22:39
Re: Need to know something - by Lorenc_ - 18.12.2010, 00:01
Re: Need to know something - by Benjo - 18.12.2010, 00:16
Re: Need to know something - by Lorenc_ - 18.12.2010, 02:41

Forum Jump:


Users browsing this thread: 1 Guest(s)