Cuffing Commands
#3

Using sscanf. Below is my cuff command, I added freezing and unfreezing to it for you.

pawn Код:
new pCop[MAX_PLAYERS];
new pCuffed[MAX_PLAYERS];

CMD:cuff(playerid, params[])
{
    new tid, string[64], name[MAX_PLAYER_NAME];

    if(sscanf(params, "u", tid)) return SendClientMessage(playerid, -1, "/cuff [ID]");
    if(!IsPlayerConnected(tid)) return SendClientMessage(playerid, -1, "The ID you entered isn't connected to the server.");

    if(pCop[playerid] == 1)
    {
        if(pCuffed[tid] == 0)
        {
            pCuffed[tid] = 1; // set var
            TogglePlayerControllable(playerid, 0); // freeze

            format(string, sizeof(string), "You have cuffed %s.", GetPlayerName(tid, name, sizeof(name)) );
            SendClientMessage(playerid, -1, string);

            SetPlayerSpecialAction(tid, SPECIAL_ACTION_CUFFED);
            SetPlayerAttachedObject(tid, 7, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);

            format(string, sizeof(string), "Officer %s has just cuffed you.", GetPlayerName(playerid, name, sizeof(name)) );
            SendClientMessage(tid, -1, string);
        }
        else if(pCuffed[tid] == 1)
        {
            pCuffed[tid] = 0; // set var
            TogglePlayerControllable(playerid, 1); // unfreeze

            format(string, sizeof(string), "You have uncuffed %s.", GetPlayerName(tid, name, sizeof(name)) );
            SendClientMessage(playerid, -1, string);

            RemovePlayerAttachedObject(playerid, 7); // remove their attached object
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);

            format(string, sizeof(string), "Officer %s has just uncuffed you.", GetPlayerName(playerid, name, sizeof(name)) );
            SendClientMessage(tid, -1, string);
        }
        return 1;
    }
    else SendClientMessage(playerid, -1, "You are not a police officer.");
    return 1;
}
Reply


Messages In This Thread
Cuffing Commands - by Ciarannn - 18.02.2014, 16:18
Re: Cuffing Commands - by ShaneOvSina - 18.02.2014, 16:31
Re: Cuffing Commands - by Dignity - 18.02.2014, 16:34
Re: Cuffing Commands - by Kyance - 18.02.2014, 16:35
Re: Cuffing Commands - by Ciarannn - 18.02.2014, 16:45
Re: Cuffing Commands - by Ciarannn - 18.02.2014, 16:47
Re: Cuffing Commands - by Ciarannn - 18.02.2014, 16:51
Re: Cuffing Commands - by Dignity - 18.02.2014, 17:00
Re: Cuffing Commands - by Ciarannn - 18.02.2014, 18:03
Re: Cuffing Commands - by Dignity - 18.02.2014, 18:06

Forum Jump:


Users browsing this thread: 1 Guest(s)