17.01.2019, 15:26
Test it.
By the way, in the 'foreach' you must verify if all the 'id' traversed are in 'spectator' mode (variable 'IsSpecing' enabled). Another thing, when using 'foreach' it is not necessary to check if the player is connected or disconnected.
By the way, in the 'foreach' you must verify if all the 'id' traversed are in 'spectator' mode (variable 'IsSpecing' enabled). Another thing, when using 'foreach' it is not necessary to check if the player is connected or disconnected.
PHP Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
if(IsBeingSpeced[playerid] == 1)
{
foreach(new i:Player)
{
if(IsSpecing[i] != 1) continue; //All those who do not have the variable 'IsSpecing' enabled
if(SpecID[i] != playerid) continue;
SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
}
}
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
if(IsBeingSpeced[playerid] == 1)
{
foreach(new i:Player)
{
if(IsSpecing[i] != 1) continue; //All those who do not have the variable 'IsSpecing' enabled
if(SpecID[i] != playerid) continue;
SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
PlayerSpectatePlayer(i, playerid);
}
}
}
return 1;
}
PHP Code:
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
if(IsBeingSpeced[playerid] == 1)
{
foreach(new i:Player)
{
if(IsSpecing[i] != 1) continue; //All those who do not have the variable 'IsSpecing' enabled
if(SpecID[i] != playerid) continue;
SetPlayerInterior(i, GetPlayerInterior(playerid));
SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
if(IsPlayerInAnyVehicle(playerid)) PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
else PlayerSpectatePlayer(i, playerid);
}
}
return 1;
}