Cuff ??
#1

Hi

i maked a cuff / uncuff command

first of all the cuff cmd
it works 99% but the problem is when i try to cuff someone
it cuffs the player i wanted
but gives the animation / cuff objects to my self

Command

Код:
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, 0);
					SetPlayerAttachedObject(playerid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
                                        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_CUFFED);
					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;
}

Uncuff cmd

you can do /uncuff
and then you will get [ usage: /uncuff [part of name / playerid ]
but when i try to do /uncuff 1 it
gives [ Error Unknow command ]

Код:
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(playerid)) RemovePlayerAttachedObject(playerid);
					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");
				}
				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;
}
PLEASE HELP !
Reply
#2

on cuff this should be be

playerid = the player who executes the commands
giveplayerid = the player who gets cuff when the playerid executes the /cuff command

pawn Код:
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);
Reply
#3

Exactly ^^
Reply
#4

Quote:
Originally Posted by pds2012
Посмотреть сообщение
on cuff this should be be

playerid = the player who executes the commands
giveplayerid = the player who gets cuff when the playerid executes the /cuff command

pawn Код:
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);
hmm i should give it a try

EDIT it works and what about the /uncuff
Reply
#5

EDIT ^
|
Reply
#6

CMD:uncuff(playerid, params[])
{
new targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, -1, "[USAGE]: /uncuff [Part of Name/Player ID]");
if(IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
{
new Float, Float:y, Float:z;//these are the defines of your x,y and z position.
GetPlayerPos(playerid, x, y, z);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))//this will check that if the player you want to cuff is near you or not.
{
if(!SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NON E);//this will remove the players cuffs and his arms will go normal.
RemovePlayerAttachedObject(targetid, 0); // This will remove the cuff object!
new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
GetPlayerName(playerid, name, sizeof(name));//this will get your name and store it in the variable you defines as name.
new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
GetPlayerName(targetid, target, sizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
format(str, sizeof(str), "INFO: You have uncuffed %s!",target);//explained at the end of the tutorial.
SendClientMessage(playerid, 0xE01B1B, str);//will send the formated message to you that you created above.
format(str, sizeof(str), "WARNING: You have been uncuffed by %s!",name);//explained bellow.
SendClientMessage(targetid, 0xE01B1B, str);//will send the formated message to the player you want to cuff that you created above.
return 1;
}
}
return 1;
}
Reply
#7

Sorry but i don't realy get what you changed -_-
Reply
#8

on Uncuff try this. im not sure if this works. i haven't tested it

you can remove the #pragma tabsize 0 if you can fix the Loose Indentation warning i dont want to touch anything about your indentation so i just put #pragma tabsize 0

pawn Код:
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) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't uncuff a jailed player.");
                if(giveplayerid == playerid) return  SendClientMessageEx(playerid, COLOR_GREY, "You can't uncuff yourself.");
                if(PlayerCuffed[giveplayerid] > 1)
                {
                    if(IsPlayerAttachedObjectSlotUsed(playerid)) return RemovePlayerAttachedObject(playerid);
                    //
                    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");
                }
                #pragma tabsize 0
                else
                {
                    SendClientMessageEx(playerid, COLOR_GREY, "That player isn't cuffed.");
                }
            else
            {
                SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
            }
        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
        }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You're not a law enforcement officer.");
    }
    return 1;
}
Reply
#9

hmm i gonna check it
Reply
#10

Same problem with uncuff i do /uncuff then everything goes right
it gives [usage: /uncuff [id / part off name]
but when i do /uncuff 1 or /uncuff Jack_Harison
then it say's [Server: Unknow Command]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)