SA-MP Forums Archive
Lose weapons after Specating - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lose weapons after Specating (/showthread.php?tid=351784)



Lose weapons after Specating - Stefand - 17.06.2012

Hello,

Does maybe someone know how to give the spectating admin his weapons back after /specoff?

here are the two codes

pawn Код:
command(spec, playerid, params[])
{
    new id, string[128], Float: health, Float: armour, healthf, armourf;
    if(sscanf(params, "u", id))
    {
        if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /spec [playerid] (type /specoff to finish spectating)");
        }
    }
    else
    {
        if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
        {
            if(IsPlayerConnectedEx(id))
            {
                if(Spectator[playerid][SpecSpectatingPlayer] == -1)
                {
                    GetPlayerPos(playerid, Spectator[playerid][SpecPlayerX], Spectator[playerid][SpecPlayerY], Spectator[playerid][SpecPlayerZ]);
                    GetPlayerFacingAngle(playerid, Spectator[playerid][SpecPlayerAngle]);
                    Spectator[playerid][SpecPlayerWorld] = GetPlayerVirtualWorld(playerid);
                    Spectator[playerid][SpecPlayerInterior] = GetPlayerInterior(playerid);
                }
               
                Player[playerid][PhoneStat] = 0;
               
                format(string, sizeof(string), "You are now spectating Player %s.", GetName(id));
                SendClientMessage(playerid, GREY, string);
                GetPlayerHealth(id, health);
                GetPlayerArmour(id, armour);
                healthf = floatround(health, floatround_ceil);
                armourf = floatround(armour, floatround_ceil);
               
                SetPlayerInterior(playerid, GetPlayerInterior(id));
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
               
                format(string, sizeof(string), "Health: %d | Armour: %d | Money: %d", healthf, armourf, Player[id][Money]);
                SendClientMessage(playerid, WHITE, string);
                Spectator[playerid][SpecSpectatingPlayer] = id;
                TogglePlayerSpectating(playerid, true);

                if(IsPlayerInAnyVehicle(id))
                {
                    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
                    Spectator[playerid][SpecSpectatingState] = 1;
                }
                else
                {
                    PlayerSpectatePlayer(playerid, id);
                    Spectator[playerid][SpecSpectatingState] = 2;
                }
               
                Spectator[playerid][SpecSpectatingPlayer] = id;
                SpectatorRefresh(playerid, id);
            }
            else
            {
                SendClientMessage(playerid, WHITE, "That player is not connected or isn't logged in.");
            }
        }
    }
    return 1;
}
pawn Код:
command(specoff, playerid, params[])
{
    #pragma unused params
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    {
        new string[128];

        Spectator[playerid][SpecSpectatingPlayer] = -1;
       
        TogglePlayerSpectating(playerid, false);
        SetCameraBehindPlayer(playerid);
       
        SetPlayerInterior(playerid, Spectator[playerid][SpecPlayerInterior]);
        SetPlayerFacingAngle(playerid, Spectator[playerid][SpecPlayerAngle]);
        SetPlayerVirtualWorld(playerid, Spectator[playerid][SpecPlayerWorld]);
        SetPlayerPos(playerid, Spectator[playerid][SpecPlayerX], Spectator[playerid][SpecPlayerY], Spectator[playerid][SpecPlayerZ]);

        SendClientMessage(playerid, WHITE, "You've finished your session of spectating.");
       
        Player[playerid][Hospitalized] = -1;
       
        Player[playerid][PhoneStat] = 1;
        Player[playerid][ResetTimer] = 1;

        format(string, sizeof(string), "%s has finished spectating.", GetName(playerid));
        AdminActionsLog(string);
    }
    return 1;
}