Uncuff - not working
#1

Hi i got a
problem i already posted it here but nothing helps

problem
i got a uncuff cmd
but when i go ig i can cuff someone but not UNCUFF
noting appears

Код:
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)
				{
				    if(IsPlayerAttachedObjectSlotUsed(giveplayerid)) RemovePlayerAttachedObject(giveplayerid);
					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_PURPLE,COLOR_PURPLE);
					GameTextForPlayer(giveplayerid, "~g~Uncuffed", 2500, 3);
					TogglePlayerControllable(giveplayerid, 1);
					ClearAnimations(giveplayerid);
					PlayerCuffed[giveplayerid] = 0;
                    PlayerCuffedTime[playerid] = 0;
					DeletePVar(giveplayerid, "PlayerCuffed");
				}
				{
					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
#2

Use:
pawn Код:
SetPlayerSpecialAction(giveplayerid, SPECIAL_ACTION_NONE);
Instead of:
pawn Код:
ClearAnimations(giveplayerid);
Reply
#3

Hmm i wil try it
Reply
#4

okay i did what you said but its still not working when i type /uncuff ther comes [USAGE] /uncuff [playerid]
But the cuffs dont dispaer and the player is not being uncuffd
Reply
#5

no-one
Reply
#6

Your cuffs doesn't dissapear because if statement does not know, which index you want to check. For example:

pawn Код:
if(IsPlayerAttachedObjectSlotUsed(giveplayerid)) RemovePlayerAttachedObject(giveplayerid);
This line is from your script here, IsPlayerAttachedObjectSlotUsed have a different usage.

pawn Код:
IsPlayerAttachedObjectSlotUsed(playerid, index)
Where index is ID of slot when you attached cuffs to the player, so probably it's your /cuff command.

And you said, that animation stays, after you used SPECIAL_ACTION_NONE ? Hm.. it's strange, because it should stop, which skin do you use, to test this action?
Reply
#7

i tested the skin on the "staff Skin" i tought something like this "117" but i'm not sure


But the code you gave IsPlayerAttachedObjectSlotUsed(giveplayerid, 2)
Does remove the Cuffs ?

And the annimation is still here

CMD uncuff/cuff

Код:
CMD:cuff(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))
	{
		if(GetPVarInt(playerid, "Injured") == 1)
		{
			SendClientMessageEx(playerid, COLOR_GREY, "You can't do this right now.");
			return 1;
		}

		new string[128], giveplayerid;
		if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /cuff [playerid]");

		if(IsPlayerConnected(giveplayerid))
		{
			if (ProxDetectorS(8.0, playerid, giveplayerid))
			{
				if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You cannot cuff yourself!"); return 1; }
				if(PlayerCuffed[giveplayerid] == 1 || GetPlayerSpecialAction(giveplayerid) == SPECIAL_ACTION_HANDSUP)
    				{
					format(string, sizeof(string), "* You have been handcuffed by %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
					format(string, sizeof(string), "* You handcuffed %s, till uncuff.", GetPlayerNameEx(giveplayerid));
					SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
					format(string, sizeof(string), "* %s handcuffs %s, tightening the cuffs securely.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
					ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
					TogglePlayerControllable(giveplayerid, 1);
					SetPlayerAttachedObject(giveplayerid, 2, 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);
					/*ClearAnimations(giveplayerid);
					ApplyAnimation(giveplayerid,"ped","cower",1,1,0,0,0,0,1);*/
					PlayerCuffed[giveplayerid] = 2;
					SetPVarInt(giveplayerid, "PlayerCuffed", 2);
					SetPVarInt(giveplayerid, "IsFrozen", 1);
					//Frozen[giveplayerid] = 1;
					PlayerCuffedTime[giveplayerid] = 300;
					}
					else
				    {
					SendClientMessageEx(playerid, COLOR_GREY, "That player isn't restrained!");
					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;
}

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)
				{
				    IsPlayerAttachedObjectSlotUsed(giveplayerid, 2)
				    //if(IsPlayerAttachedObjectSlotUsed(giveplayerid)) RemovePlayerAttachedObject(giveplayerid);
					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_PURPLE,COLOR_PURPLE);
					GameTextForPlayer(giveplayerid, "~g~Uncuffed", 2500, 3);
					TogglePlayerControllable(giveplayerid, 1);
					//ClearAnimations(giveplayerid);
					SetPlayerSpecialAction(giveplayerid, SPECIAL_ACTION_NONE);
					PlayerCuffed[giveplayerid] = 0;
                    PlayerCuffedTime[playerid] = 0;
					DeletePVar(giveplayerid, "PlayerCuffed");
				}
				{
					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
#8

Edit ^
|
Reply
#9

no one again ? there need to be someone that could help me
Reply
#10

Please, stop bumping your topic. I'm gonna help you, so don't worry, okey?

Try this code, I re-write it a little bit, if it's not gonna work then, I have some other idea.

pawn Код:
#include    <a_samp>
#include    <zcmd>
#include    <sscanf2>

CMD:cuff(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)))
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You're not a law enforcement officer.");
        return true;
    }
    new string[128], giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /cuff [playerid]");
    {
        if(GetPVarInt(playerid, "Injured") == 1)
        {
            SendClientMessageEx(playerid, COLOR_GREY, "You can't do this right now.");
            return 1;
        }
   
        if(!IsPlayerConnected(giveplayerid))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
            return true;
        }
       
        if(!ProxDetectorS(8.0, playerid, giveplayerid))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
            return true;
        }
       
        if(giveplayerid == playerid)
        {
            SendClientMessageEx(playerid, COLOR_GREY, "You cannot cuff yourself!");
            return true;
        }
       
        if(PlayerCuffed[giveplayerid] == 1 || GetPlayerSpecialAction(giveplayerid) == SPECIAL_ACTION_HANDSUP)
        {
            format(string, sizeof(string), "* You have been handcuffed by %s.", GetPlayerNameEx(playerid));
            SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
           
            format(string, sizeof(string), "* You handcuffed %s, till uncuff.", GetPlayerNameEx(giveplayerid));
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
           
            format(string, sizeof(string), "* %s handcuffs %s, tightening the cuffs securely.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

            GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
           
            TogglePlayerControllable(giveplayerid, 1);
            SetPlayerAttachedObject(giveplayerid, 2, 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);
           
            PlayerCuffed[giveplayerid] = 2;
            SetPVarInt(giveplayerid, "PlayerCuffed", 2);
            SetPVarInt(giveplayerid, "IsFrozen", 1);
            PlayerCuffedTime[giveplayerid] = 300;
           
        }
       
        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't restrained!");
        }
    }
    return true;
}


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)))
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You're not a law enforcement officer.");
        return true;
    }
   
    new string[128], giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /uncuff [playerid]");
    {
   
        if(!IsPlayerConnected(giveplayerid))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
            return true;
        }

        if(!ProxDetectorS(8.0, playerid, giveplayerid))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
            return true;
        }

        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 true;
        }

        if(PlayerCuffed[giveplayerid] > 1)
        {
            if(IsPlayerAttachedObjectSlotUsed(giveplayerid, 2))
            {
                RemovePlayerAttachedObject(giveplayerid);
            }

            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_PURPLE,COLOR_PURPLE);

            GameTextForPlayer(giveplayerid, "~g~Uncuffed", 2500, 3);
            TogglePlayerControllable(giveplayerid, 1);

            SetPlayerSpecialAction(giveplayerid, SPECIAL_ACTION_NONE);
            PlayerCuffed[giveplayerid] = 0;
            PlayerCuffedTime[playerid] = 0;
            DeletePVar(giveplayerid, "PlayerCuffed");
        }

        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't cuffed.");
            return 1;
        }
    }
    return 1;
}
Reply
#11

Thanks man i will try it!

Btw sorry for the bumbs
Reply
#12

Edit it doesn't work again cuff = working uncuff doesn't work.....
Reply
#13

Put this some where in your code.

pawn Код:
RemovePlayerAttachedObject(id, 9);
Reply
#14

i will try it thanks !
Reply
#15

Advice: Don't use the NGRP script
Reply
#16

Quote:
Originally Posted by firemanjv
Посмотреть сообщение
Edit it doesn't work again cuff = working uncuff doesn't work.....
pawn Код:
if(IsPlayerAttachedObjectSlotUsed(giveplayerid, 2))
{
        RemovePlayerAttachedObject(giveplayerid);
}
I made a really big mistake in this line. Just after 'giveplayerid' parameter from RemovePlayerAttachedObject, add comma and number 2 (your index number). So it's gonna be like:

From:
pawn Код:
RemovePlayerAttachedObject(giveplayerid);
To:
pawn Код:
RemovePlayerAttachedObject(giveplayerid, 2);
Quote:
Originally Posted by Kestro
Посмотреть сообщение
Put this some where in your code.

pawn Код:
RemovePlayerAttachedObject(id, 9);
Why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)