new
Float: Save_Position[ MAX_PLAYERS ][ 4 ],
bool: InSpectate[ MAX_PLAYERS ]
;
Save_Position[ playerid ][ 0 ] = 0.0;
Save_Position[ playerid ][ 1 ] = 0.0;
Save_Position[ playerid ][ 2 ] = 0.0;
Save_Position[ playerid ][ 3 ] = 0.0;
InSpectate[ playerid ] = false;
if( InSpectate[ playerid ] )
{
SetPlayerPos( playerid, Save_Position[ playerid ][ 0 ], Save_Position[ playerid ][ 1 ], Save_Position[ playerid ][ 2 ] );
SetPlayerFacingAngle( playerid, Save_Position[ playerid ][ 3 ] );
InSpectate[ playerid ] = false;
}
new SpecID[MAX_PLAYERS];
new id;
new string[44];
GetPlayerPos( playerid, Save_Position[ playerid ][ 0 ], Save_Position[ playerid ][ 1 ], Save_Position[ playerid ][ 2 ] );
GetPlayerFacingAngle( playerid, Save_Position[ playerid ][ 3 ] );
InSpectate{ playerid } = true;
TogglePlayerSpectating(playerid, 1);
SpecID[playerid] = id;
return 1;
TogglePlayerSpectating(playerid, 0);
SetPlayerPos( playerid, Save_Position[ playerid ][ 0 ], Save_Position[ playerid ][ 1 ], Save_Position[ playerid ][ 2 ] );
return 1;
new SpecID[MAX_PLAYERS];
new id;
new string[44];
GetPlayerPos( playerid, Save_Position[ playerid ][ 0 ], Save_Position[ playerid ][ 1 ], Save_Position[ playerid ][ 2 ] );
GetPlayerFacingAngle( playerid, Save_Position[ playerid ][ 3 ] );
InSpectate{ playerid } = true;
TogglePlayerSpectating(playerid, 1);
SpecID[playerid] = id;
return 1;
new SpecID[MAX_PLAYERS];
new id;
new string[44];
GetPlayerPos( playerid, Save_Position[ playerid ][ 0 ], Save_Position[ playerid ][ 1 ], Save_Position[ playerid ][ 2 ] );
GetPlayerFacingAngle( playerid, Save_Position[ playerid ][ 3 ] );
InSpectate[ playerid ] = true; // You put the wrong brackets.
TogglePlayerSpectating(playerid, 1);
SpecID[playerid] = id;
return 1;
Something I noticed...
PHP код:
PHP код:
|
new bool:sSpectating[MAX_PLAYERS] = false,
Float:pSpectatingPos[MAX_PLAYERS][4],
pSpectatingInterior[MAX_PLAYERS],
pSpectatingVirtualWorld[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
if(IsPlayerSpectating(playerid))
{
SetPlayerInterior(playerid, pSpectatingInterior[playerid]);
SetPlayerVirtualWorld(playerid, pSpectatingVirtualWorld[playerid]);
SetPlayerPos(playerid, pSpectatingPos[playerid][0], pSpectatingPos[playerid][1], pSpectatingPos[playerid][2]);
SetPlayerFacingAngle(playerid, pSpectatingPos[playerid][3]);
SetCameraBehindPlayer(playerid);
sSpectating[playerid] = false;
}
return 1;
}
CMD:spec(playerid, params[])
{
new lookupid;
if(sscanf(params, "u", lookupid)) return SendClientMessage(playerid, -1, "Usage: /spec (id/name).");
if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, -1, "Player isn't connected to the server.");
if(IsPlayerNPC(lookupid)) return SendClientMessage(playerid, -1, "You cannot spectate a bot.");
if(lookupid == playerid) return SendClientMessage(playerid, -1, "You cannot spectate yourself.");
if(IsPlayerSpectating(lookupid)) return SendClientMessage(playerid, -1, "You cannot spectate a player that's currently spectating.");
if(!IsPlayerSpectating(playerid))
{
GetPlayerPos(playerid, pSpectatingPos[playerid][0], pSpectatingPos[playerid][1], pSpectatingPos[playerid][2]);
GetPlayerFacingAngle(playerid, pSpectatingPos[playerid][3]);
pSpectatingInterior[playerid] = GetPlayerInterior(playerid);
pSpectatingVirtualWorld[playerid] = GetPlayerVirtualWorld(playerid);
}
sSpectating[playerid] = true;
TogglePlayerSpectating(playerid, true);
if(IsPlayerInAnyVehicle(lookupid))
{
//SetPlayerInterior(playerid, GetVehicleInterior(GetPlayerVehicleID(lookupid))); You need to get that function, it can be found in YSF or somewhere else.
SetPlayerVirtualWorld(playerid, GetVehicleVirtualWorld(GetPlayerVehicleID(lookupid)));
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(lookupid));
}
else
{
SetPlayerInterior(playerid, GetPlayerInterior(lookupid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(lookupid));
PlayerSpectatePlayer(playerid, lookupid);
}
return 1;
}
CMD:specoff(playerid, params[])
{
if(!IsPlayerSpectating(playerid)) return SendClientMessage(playerid, -1, "** You are not spectating anyone.");
TogglePlayerSpectating(playerid, false);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
return 1;
}
stock IsPlayerSpectating(playerid)
{
if(sSpectating[playerid]) return true;
return false;
}
There's no need to create the same thread in multiple sections.
Please take the following code as a reference. If it doesn't solve your issue, I'm pretty sure it's something else causing it to do that to the player. pawn Код:
|