SA-MP Forums Archive
0.3e Cuffs System bug - 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: 0.3e Cuffs System bug (/showthread.php?tid=342210)



0.3e Cuffs System bug - lsfmd - 13.05.2012

pawn Код:
if(strcmp(cmd, "/cuff", true) == 0)
    {
          if(IsPlayerConnected(playerid))
        {
            if(IsACop(playerid) || IsAUSAF(playerid) || IsASWAT(playerid) || IsAnAgent(playerid))
                {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, RED, "USAGE: /cuff [playerid]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        if(PlayerCuffed[giveplayerid] == 1)
                        {
                            SendClientMessage(playerid, GREY, "That player is already cuffed");
                            return 1;
                        }
                        if(giveplayerid == playerid)
                        {
                            SendClientMessage(playerid, GREY, "You can not cuff yourself");
                            return 1;
                        }
                        if(ProxDetectorS(8.0, playerid, giveplayerid))
                        {
                            format(string, sizeof(string), "You have been cuffed by %s", GetPlayerName(playerid));
                            SendClientMessage(giveplayerid, WHITE, string);
                            format(string, sizeof(string), "You have cuffed %s", GetPlayerName(giveplayerid));
                            SendClientMessage(playerid, WHITE, string);
                            PlayerCuffed[giveplayerid] = 1;
                            SetPlayerAttachedObject(giveplayerid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
                            SetPlayerSpecialAction(giveplayerid,SPECIAL_ACTION_CUFFED);
                        }
                        else
                        {
                            SendClientMessage(playerid, GREY, "That player is not in range");
                            return 1;
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, LIGHTRED, "Playerid is not an active playerid");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, GREY, "Invalid faction");
            }
        }
        return 1;
So the problem with this code is that It returns "That player is already cuffed" When you attempt to cuff an noncuffed person. Can anyone post a fix?


Re: 0.3e Cuffs System bug - [WSF]ThA_Devil - 13.05.2012

you must set PlayerCuffed somewhere to 0... like on OnPlayerConnect or so


Re: 0.3e Cuffs System bug - iRage - 13.05.2012

Put the following to your script.

Under OnPlayerConnect
pawn Код:
PlayerCuffed[playerid] = 0;
Under your /uncuff command
pawn Код:
PlayerCuffed[giveplayerid] = 0;