Checking if players are still alive on a team - 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: Checking if players are still alive on a team (
/showthread.php?tid=134169)
Checking if players are still alive on a team -
biltong - 15.03.2010
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?
Re: Checking if players are still alive on a team -
biltong - 16.03.2010
Bump
Re: Checking if players are still alive on a team -
Jeffry - 16.03.2010
Well, explaing wont help alot.
But something like this:
pawn Код:
new TeamA[MAX_PLAYERS];
new TeamB[MAX_PLAYERS];
new TeamAalive;
new TeamBalive;
OnPlayerDeath
pawn Код:
if(TeamA[playerid]==1) TeamAalive--;
if(TeamB[playerid]==1) TeamBalive--;
And then put it in a timer, that checks how many are alive, and like this:
pawn Код:
if(TeamAalive<=0)
{
// whatever you do here
}
if(TeamBalive<=0)
{
// whatever you do here
}
If you need more help, just say.
Re: Checking if players are still alive on a team -
Norck - 16.03.2010
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;
}
Re: Checking if players are still alive on a team -
woot - 16.03.2010
or just PLAYER_STATE_WASTED
https://sampwiki.blast.hk/wiki/Playerstates
Re: Checking if players are still alive on a team -
biltong - 16.03.2010
Quote:
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;
}
|
I have IsPlayerDead[MAX_PLAYERS] in my script already. All I needed was the function :P thanks guys
EDIT: It should be if(PlayerDead[
i] == 0)
Also, I'm having trouble integrating this into my script. I want to make the current round end early and skip straight to the next one. If I posted it on pastebin or something would you guys help me fix it?
Re: Checking if players are still alive on a team -
Jeffry - 16.03.2010
How long is your script?
EDIT: Cool that your countdown works now.
Re: Checking if players are still alive on a team -
biltong - 16.03.2010
+- 700 lines. Not very long.
Re: Checking if players are still alive on a team -
Jeffry - 17.03.2010
PM me the pastebin code. I will check it.
Re: Checking if players are still alive on a team -
biltong - 17.03.2010
You got PM