SPEC Command
#1

pawn Код:
dcmd_spec(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [ID]");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_GREY, "* Player[ID] is not found!");
    else
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
        GetPlayerPos(playerid, TeleportDest[playerid][0],TeleportDest[playerid][1],TeleportDest[playerid][2]);
        if(IsPlayerInAnyVehicle(id))
        {
            new int = GetPlayerInterior(id);
            SetPlayerInterior(playerid, int);
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
        }
        else
        {
            new int = GetPlayerInterior(id);
            SetPlayerInterior(playerid, int);
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectatePlayer(playerid, id);
        }
    }
    return 1;
}
pawn Код:
dcmd_specoff(playerid, params[])
{
    #pragma unused params
    TogglePlayerSpectating(playerid, 0);
    Specing[playerid] = 0;
    return 1;
}
Could anyone tell me, Why does it not spawn you back we're you did /spec [ID]?

When you do /specoff, I need it to return you, to your last position before /spec [ID].
Reply
#2

pawn Код:
//Top of your script:
new Float:Posxx, Float:Posyy, Float:Poszz;

dcmd_spec(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [ID]");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_GREY, "* Player[ID] is not found!");
    else
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
        GetPlayerPos(playerid, TeleportDest[playerid][0],TeleportDest[playerid][1],TeleportDest[playerid][2]);
        GetPlayerPos(playerid,Posxx,Posyy,Poszz);
        if(IsPlayerInAnyVehicle(id))
        {
            new int = GetPlayerInterior(id);
            SetPlayerInterior(playerid, int);
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
        }
        else
        {
            new int = GetPlayerInterior(id);
            SetPlayerInterior(playerid, int);
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectatePlayer(playerid, id);
        }
    }
    return 1;
}

dcmd_specoff(playerid, params[])
{
    #pragma unused params
    TogglePlayerSpectating(playerid, 0);
    Specing[playerid] = 0;
    SetPlayerPos(playerid,Posxx,Posyy,Poszz);
    return 1;
}
Untested but should work.
Reply
#3

You've to store them in variable.
And load them (use it in SetPlayerPos) to go back to the position where you spectate.
Don't also forget to store the interior and virtual world in the variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)