Help please.
#1

Hello players of SA-MP.
I would like some help with my /uncuff command.
When I try to use the command, the cuffs are still attached to the player.

pawn Код:
command(cuff, playerid, params[])
{
    new ID, string[64];
    if(Factions[Player[playerid][Faction]][fType] == 1)
    {
        if(FactionDuty[playerid] == 0)return SendClientMessage(playerid, GREY, "You must be on Duty to perform this command.");
        if(sscanf(params, "u", ID)) return SendClientMessage(playerid, GREY, "Usage: /cuff [player id or name]");
        if(IsPlayerConnected(ID))
        {
            if(ID != playerid)
            {
                if(GetDistanceBetweenPlayers(playerid, ID) < 4)
                {
                    if(pCuffed[ID] == 0)
                    {
                        pCuffed[ID] = 1;
                        format(string, sizeof(string), "* %s has been hand-cuffed by %s. *", MaskName(ID), MaskName(playerid));
                        CloseMessage(playerid, ACTION, string);
                        SetPlayerSpecialAction(ID, SPECIAL_ACTION_CUFFED);
                        SetPlayerAttachedObject(ID, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
                        ClearAnimations(ID);
                        pTazed[ID] = 0;
                    }
                    else return SendClientMessage(playerid, WHITE, "That player is already cuffed.");
                }
                else return SendClientMessage(playerid, GREY, "You must be close to the player.");
            }
            else return SendClientMessage(playerid, WHITE, "You can't cuff your self.");
        }
        else return SendClientMessage(playerid, GREY, NotConnected);
    }
    else return SendClientMessage(playerid, WHITE, FactionOnly);
    return 1;
}
pawn Код:
command(uncuff, playerid, params[])
{
    new string[128], ID;
    if(Factions[Player[playerid][Faction]][fType] == 1)
    {
        if(FactionDuty[playerid] == 0)return SendClientMessage(playerid, GREY, "You must be on Duty to perform this command.");
        if(sscanf(params, "u", ID)) return SendClientMessage(playerid, GREY, "Usage: /uncuff [player id or name]");
        if(IsPlayerConnected(ID))
        {
            if(ID != playerid)
            {
                if(GetDistanceBetweenPlayers(playerid, ID) < 4)
                {
                    if(pCuffed[ID] == 1)
                    {
                        pCuffed[ID] = 0;
                        format(string, sizeof(string), "* %s has been uncuffed by %s. *", MaskName(ID), MaskName(playerid));
                        CloseMessage(playerid, ACTION, string);
                        TogglePlayerControllable(ID, true);
                        for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)if(IsPlayerAttachedObjectSlotUsed(playerid, ID)) RemovePlayerAttachedObject(ID, i);
                        SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
                        RemovePlayerAttachedObject(playerid,);
                    }
                    else return SendClientMessage(playerid, WHITE, "That player isn't cuffed.");
                }
                else return SendClientMessage(playerid, GREY, "You must be close to the player.");
            }
            else return SendClientMessage(playerid, WHITE, "You can't uncuff yourself.");
        }
        else return SendClientMessage(playerid, GREY, NotConnected);
    }
    else return SendClientMessage(playerid, WHITE, FactionOnly);
    return 1;
}
Reply
#2

removeattachedobject(playerid,)
what your parameter is blank how can you expect that
Reply
#3

Try this 1
Quote:

CMD:uncuff(playerid, params[])
{
if(IsACop(playerid) || PlayerInfo[playerid][pMember] == 4 && PlayerInfo[playerid][pDivision] == 2 || PlayerInfo[playerid][pMember] == 4 && PlayerInfo[playerid][pRank] >= 5 || (PlayerInfo[playerid][pMember] == 12 && PlayerInfo[playerid][pDivision] == 2))
{
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /uncuff [playerid]");

if(IsPlayerConnected(giveplayerid))
{
if (ProxDetectorS(8.0, playerid, giveplayerid))
{
if(PlayerInfo[giveplayerid][pJailed] >= 1)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't uncuff a jailed player.");
return 1;
}
if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You can't uncuff yourself."); return 1; }
if(PlayerCuffed[giveplayerid]>1)
{
DeletePVar(giveplayerid, "IsFrozen");
format(string, sizeof(string), "* You have been uncuffed by %s.", GetPlayerNameEx(playerid));
SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* You uncuffed %s.", GetPlayerNameEx(giveplayerid));
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has uncuffed %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
GameTextForPlayer(giveplayerid, "~g~Uncuffed", 2500, 3);
TogglePlayerControllable(giveplayerid, 1);
ClearAnimations(giveplayerid);
PlayerCuffed[giveplayerid] = 0;
PlayerCuffedTime[playerid] = 0;
DeletePVar(giveplayerid, "PlayerCuffed");
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "That player isn't cuffed.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "You're not a law enforcement officer.");
}
return 1;
}

Reply
#4

Do I have to simply say: RemovePlayerAttachedObject(playerid, 0);
in the uncuff command to remove it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)