21.04.2012, 11:54
Well I tried to do a function which will do that if there is still someone in your team and you die then it sets you to spec him, it's just not working.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
if(gTeam[playerid] == TEAM_SWAT && gSWAT > 0) gSWAT--;
else if(gTeam[playerid] == TEAM_CRIMINALS && gCriminals > 0) gCriminals--;
if(gCriminals <= 0)
{
SendClientMessageToAll(COLOR_BLUE, "SWAT has won this round!");
gRounds++;
SetEveryoneToSpawn(playerid);
}
else if(gSWAT <= 0)
{
SendClientMessageToAll(COLOR_RED, "Criminals has won this round!");
gRounds++;
SetEveryoneToSpawn(playerid);
}
if(gCriminals > 0 && gSWAT > 0)
{
gSpectating[playerid] = 1;
SetToSpectate(playerid);
}
CancelSpectate(playerid);
return 1;
}
SetToSpectate(playerid)
{
for(new i; i < 10; i++)
{
if(!IsPlayerConnected(i)) continue;
if(gSpectating[i]) continue;
if(gTeam[i] != gTeam[playerid]) continue;
new string[128];
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, i);
new Name[MAX_PLAYER_NAME]; GetPlayerName(i, Name, sizeof(Name));
format(string, sizeof(string), "[Info:] You are now spectating %s", Name);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}

