17.04.2012, 14:53
Well I made two global variables gSWAT and gCriminals and did when someone spawns if he's in the swat team it adds one to gSWAT and if he's in the criminals team it adds one to gCriminals.
So I did when a player dies it reduces the variable one less and then I did if any of the variables equals to 0 it'll exit the gamemode.
But it basically doesn't, when a player dies even if he's the last one in his team it's just spawning him again, like the function I made doesn't work.
So I did when a player dies it reduces the variable one less and then I did if any of the variables equals to 0 it'll exit the gamemode.
But it basically doesn't, when a player dies even if he's the last one in his team it's just spawning him again, like the function I made doesn't work.
PHP код:
new gSWAT = 0;
new gCriminals = 0;
public OnPlayerSpawn(playerid)
{
SetPlayerInterior(playerid, 15);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 99999);
SetPlayerArmour(playerid, 100.0);
if(gTeam[playerid] == TEAM_CRIMINALS)
{
SetPlayerColor(playerid, 0xAFAFAF00);
SendClientMessage(playerid, COLOR_WHITE, "[Info:] Protect this building from any SWAT member!");
GivePlayerWeapon(playerid, 30, 99999);
SetPlayerPos(playerid, 2198.3105,-1139.0374,1029.7969);
SetPlayerFacingAngle(playerid, 172.9276);
gCriminals += 1;
}
else if(gTeam[playerid] == TEAM_SWAT)
{
SetPlayerColor(playerid, 0x0000BB00);
SendClientMessage(playerid, COLOR_WHITE, "[Info:] You need to hunt down every criminal in the building!");
GivePlayerWeapon(playerid, 31, 99999);
SetPlayerPos(playerid, 2227.8904,-1150.5730,1025.7969);
SetPlayerFacingAngle(playerid, 80.7447);
gSWAT += 1;
}
TogglePlayerControllable(playerid, false);
SetTimer("StartRound", 5000, false);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(gTeam[playerid] == TEAM_SWAT) { gSWAT -= 1; }
if(gTeam[playerid] == TEAM_CRIMINALS) { gCriminals -= 1; }
if(gSWAT <= 0 || gCriminals <= 0)
{
new string[128];
format(string, sizeof(string), "%s has won this round! \n New round is starting up within the few next seconds!", gTeam[playerid]);
GameModeExit();
}
return 1;
}