/spec off
#1

I want to change /spec and /specoff in one cmd so like /spec off will do the same as /specoff

pawn Код:
command(specnew, playerid, params[])
{
    new id, string[128],string2[128],string3[128],string4[128],string5[128],string6[128],string7[128],string8[128];
    if(sscanf(params, "u", id))
    {
        if(AdminLoggedIn[playerid] == 1 && Player[playerid][Adminlevel] >= 1)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /spec [playerid] (type /specoff to finish spectating)");
        }
        else
        {
            RemoveTextMessage(playerid);
            TextDrawShowForPlayer(playerid, Text:CantCommand);
            SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
        }
    }
    else
    {
        if(AdminLoggedIn[playerid] == 1 && Player[playerid][Adminlevel] >= 1)
        {
            SavePlayerData(playerid);
            new text[128];
            valstr(text,id);
            if(strcmp(text, "off", true) == 0)
            {
                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]);
                TextDrawHideForPlayer(playerid, Text:SpecLine1[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecLine2[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecLine3[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecCmd1[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecCmd2[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecCmd3[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecCmd4[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecCmd5[playerid]);
                TextDrawHideForPlayer(playerid, Text:SpecText);
                TextDrawHideForPlayer(playerid, Text:SpecWin1);
                TextDrawHideForPlayer(playerid, Text:SpecWin2);
                TextDrawHideForPlayer(playerid, Text:SpecCMDBG);
                TextDrawHideForPlayer(playerid, Text:SpecLastCMD);
                SetPlayerSkin(playerid, Player[playerid][Skin]);

                /*new str[128], Year, Month, Day, Hour, Minute, Seconds;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Seconds);
                format(str, sizeof(str), "[%02d/%02d/%d - %02d:%02d] Spectation: %s %s has finished spectating", Day, Month, Year, Hour, Minute, RPName(playerid));
                AdminActionsLog(str);*/

                Player[playerid][Muted] = 0;
            }
            else
            {
                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);
                    }
                    new Float: health, Float: armour, healthf, armourf;
                    GetPlayerHealth(id, health);
                    GetPlayerArmour(id, armour);
                    healthf = floatround(health, floatround_round);
                    armourf = floatround(armour, floatround_round);
                    format(string, sizeof(string), "Name: %s, ID: %d, Health: %d, Armour: %d, Money: %d", RPName(id), id, healthf, armourf, GetPlayerMoney(id));
                    TextDrawSetString(SpecLine1[playerid], string);
                    format(string2, sizeof(string2), "IP: %s, FPS: %d, Maskid: %d", PlayerIP[id], FPS2[id]-1, Player[id][Mask]);
                    TextDrawSetString(SpecLine2[playerid], string2);
                    format(string3, sizeof(string3), "");
                    TextDrawSetString(SpecLine3[playerid], string3);
                    format(string4, sizeof(string4), "%s", Player[id][CMD1]);
                    TextDrawSetString(SpecCmd1[playerid], string4);
                    format(string5, sizeof(string5), "%s", Player[id][CMD2]);
                    TextDrawSetString(SpecCmd2[playerid], string5);
                    format(string6, sizeof(string6), "%s", Player[id][CMD3]);
                    TextDrawSetString(SpecCmd3[playerid], string6);
                    format(string7, sizeof(string7), "%s", Player[id][CMD4]);
                    TextDrawSetString(SpecCmd4[playerid], string7);
                    format(string8, sizeof(string8), "%s", Player[id][CMD5]);
                    TextDrawSetString(SpecCmd5[playerid], string8);
                    TextDrawShowForPlayer(playerid, Text:SpecLine1[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecLine2[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecLine3[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecCmd1[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecCmd2[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecCmd3[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecCmd4[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecCmd5[playerid]);
                    TextDrawShowForPlayer(playerid, Text:SpecText);
                    TextDrawShowForPlayer(playerid, Text:SpecWin1);
                    TextDrawShowForPlayer(playerid, Text:SpecWin2);
                    TextDrawShowForPlayer(playerid, Text:SpecCMDBG);
                    TextDrawShowForPlayer(playerid, Text:SpecLastCMD);


                    SetPlayerInterior(playerid, GetPlayerInterior(id));
                    SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));

                    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);
                    Player[playerid][Muted] = 1;
                }
                else
                {
                    RemoveTextMessage(playerid);
                    TextDrawShowForPlayer(playerid, Text:PlayerNotConnected);
                    SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
                }
            }
        }
        else
        {
            RemoveTextMessage(playerid);
            TextDrawShowForPlayer(playerid, Text:CantCommand);
            SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
        }
    }
    return 1;
}
but it does not work.
Reply
#2

pawn Код:
command(specnew, playerid, params[])
O_o
Reply
#3

its a test cmd..
Just to see if it works.
Reply
#4

Check if the player tipes off before checking for any ID.

Ex:
pawn Код:
command(specnew, playerid, params[])
{
    if(strcmp(text, "off", true) == 0)
    {
        //your codes
    }
    else
    {
        //dont forget the new and stuff
        if(sscanf(params, "u", id))
        {
            // codes
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
Check if the player tipes off before checking for any ID.

Ex:
pawn Код:
command(specnew, playerid, params[])
{
    if(strcmp(text, "off", true) == 0)
    {
        //your codes
    }
    else
    {
        //dont forget the new and stuff
        if(sscanf(params, "u", id))
        {
            // codes
        }
    }
    return 1;
}
Worked, REP+
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)