SA-MP Forums Archive
Need to know something - 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: Need to know something (/showthread.php?tid=200014)



Need to know something - Lorenc_ - 17.12.2010

Hey guys, I was wondering how could i detect if one person died on the survivor team and make them observe their team mates. if all the team mates are gone, it'll call a function, MapChange(); and let the zombies win.

Might be basic, although been abit inactive and i need to get a recap of this...

-Lorenc


Re: Need to know something - XePloiT - 17.12.2010

you make 2 counter for each team... lets say : new TeamA,TeamB; each time player joins a team you add 1..
... also you add new PlayersA[MAX_PLAYER],PlayersB[MAX_PLAYER];
each player gets by his team 1 or 0 if he on this team 1 if not 0...
every time player dies you check...
pawn Код:
public OnPlayerDeath(playerid,killerid,reason)
{
     if(TeamB==0)
          return // SendClientMessage or W/E , you want to change map in this case
     else if(TeamA==0)
          return // SendClientMessage or W/E , you want to change map in this case
     if(PlayersA[playerid]==1)
          TeamA--;
     else TeamB--;
}



Re: Need to know something - Lorenc_ - 17.12.2010

yea but how do i select a survivor, example. 3 survivors alive, give a random value to select a survivor to spectate if you know what i mean, if i wanted it your way i could of done it my self but its not really how i want it. Hope you's understand


Re: Need to know something - Lorenc_ - 17.12.2010

bump -.-


Re: Need to know something - MestreKiller - 17.12.2010

random with your team vars then
playerspectateplayeer the random one
dont forget make a loop


Re: Need to know something - Lorenc_ - 18.12.2010

Im sorta unsure how to do it,

Код:
 
	if(gTeam[playerid] == TEAM HUMAN) {
		for(new i = 0; i < MAX_PLAYERS; i++) {
			if(gTeam[i] == TEAM_HUMAN) { // Unsure on this line
   				TogglePlayerSpectating(playerid, 1);
				PlayerSpectatePlayer(playerid, (Im unsure here));// Unsure on this line
			}
		}
	}
^ thats in the onplayerdeath callback to let u know...


Re: Need to know something - Benjo - 18.12.2010

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


Re: Need to know something - Lorenc_ - 18.12.2010

That might do thanks.