When someone you're spectating dies, I want the admin to continue spectating them when they respawn, how can I achieve this? OnPlayerDeath? My admins are complaining about this, and I can't seem to fix this one on my own, I'm relatively new.
Код:
new String[128], Float:SpecX[MAX_PLAYERS], Float:SpecY[MAX_PLAYERS], Float:SpecZ[MAX_PLAYERS], vWorld[MAX_PLAYERS], Inter[MAX_PLAYERS];
new IsSpecing[MAX_PLAYERS], Name[MAX_PLAYER_NAME], IsBeingSpeced[MAX_PLAYERS],spectatorid[MAX_PLAYERS];
if(IsSpecing[playerid] == 1)
{
SetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
SetPlayerInterior(playerid,Inter[playerid]);
SetPlayerVirtualWorld(playerid,vWorld[playerid]);
IsSpecing[playerid] = 0;
IsBeingSpeced[spectatorid[playerid]] = 0;
}
public OnPlayerDisconnect(playerid, reason)
{
if(IsBeingSpeced[playerid] == 1)
{
foreach(Player,i)
{
if(spectatorid[i] == playerid)
{
TogglePlayerSpectating(i,false);// This justifies what's above, if it's not off then you'll be either spectating your connect screen, or somewhere in blueberry (I don't know why)
}
}
}
return 1;
}
COMMAND:spec(playerid, params[])
{
new id;
if(pInfo[playerid][Adminlevel] == 0)return 0;
if(sscanf(params,"u", id))return SendClientMessage(playerid, Grey, "Usage: /spec [id]");
if(id == playerid)return SendClientMessage(playerid,Grey,"You cannot spec yourself.");
if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, Grey, "Player not found!");
if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,Grey,"You are already specing someone.");
GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
Inter[playerid] = GetPlayerInterior(playerid);
vWorld[playerid] = GetPlayerVirtualWorld(playerid);
TogglePlayerSpectating(playerid, true);
if(IsPlayerInAnyVehicle(id))
{
if(GetPlayerInterior(id) > 0)
{
SetPlayerInterior(playerid,GetPlayerInterior(id));
}
if(GetPlayerVirtualWorld(id) > 0)
{
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
}
PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
}
else
{
if(GetPlayerInterior(id) > 0)
{
SetPlayerInterior(playerid,GetPlayerInterior(id));
}
if(GetPlayerVirtualWorld(id) > 0)
{
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
}
PlayerSpectatePlayer(playerid,id);
}
GetPlayerName(id, Name, sizeof(Name));
format(String, sizeof(String),"You have started to spectate %s.",Name);
SendClientMessage(playerid,0x0080C0FF,String);
IsSpecing[playerid] = 1;
IsBeingSpeced[id] = 1;
spectatorid[playerid] = id;
return 1;
}
COMMAND:specoff(playerid, params[])
{
if(pInfo[playerid][Adminlevel] == 0)return 0;
if(IsSpecing[playerid] == 0)return SendClientMessage(playerid,Grey,"You are not spectating anyone.");
TogglePlayerSpectating(playerid, 0);
return 1;
}
When a player dies check if hes being spectated, if he is - whoever spectates him it sets this:
Код:
if(IsSpecing[playerid] == 1)
{
SetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
SetPlayerInterior(playerid,Inter[playerid]);
SetPlayerVirtualWorld(playerid,vWorld[playerid]);
IsSpecing[playerid] = 0;
IsBeingSpeced[spectatorid[playerid]] = 0;
}