05.03.2019, 20:05
So basically you need a delay to make a gap between the changing of the target's variable and the spectator variables it's just a little timer like that
and its function to be like that..
I tested this one and it worked for me.
PHP код:
foreach(new i : Player)
{
if(PlayerInfo[i][pSpectating] == playerid)
{
SetTimerEx("SpectateTimer", 500, false, "ii", i, playerid);
}
}
PHP код:
forward SpectateTimer(playerid, targetid);
public SpectateTimer(playerid, targetid)
{
if(PlayerInfo[playerid][pSpectating] == targetid)
{
SetPlayerInterior(playerid, GetPlayerInterior(targetid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(targetid));
if(IsPlayerInAnyVehicle(targetid))
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(targetid));
}
else
{
PlayerSpectatePlayer(playerid, targetid);
}
}
}