Help whit save position to use /spec
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
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 Код:
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;
}
I have done so because the spanish section is inactive. I will take the code as a reference if at the end I can't fix this, thanks

Quote:
Originally Posted by alexus
Посмотреть сообщение
OnPlayerDeath code perhaps ?
There is no code in OnPlayerDeath
Reply


Messages In This Thread
Help whit save position to use /spec - by Guss - 22.05.2015, 18:15
Re: Help whit save position to use /spec - by AlonzoTorres - 22.05.2015, 18:27
Respuesta: Re: Help whit save position to use /spec - by Guss - 22.05.2015, 18:31
Re: Help whit save position to use /spec - by AlonzoTorres - 22.05.2015, 18:35
Re: Help whit save position to use /spec - by SickAttack - 22.05.2015, 18:46
Respuesta: Help whit save position to use /spec - by alexus - 22.05.2015, 18:48
Respuesta: Re: Help whit save position to use /spec - by Guss - 22.05.2015, 18:56

Forum Jump:


Users browsing this thread: 1 Guest(s)