Cuffing
#1

Hi
Well I am new to scripting and this isn't my code but I was wondering is there a way to make it so you can cuff
no matter what, like no matter if they are a cop. Please help me this will be very very helpful and I will rep all that
help and put me a step forward in fixing this issue
Reply
#2

post your code please?
Reply
#3

Код:
	if(strcmp(cmd, "/cuff", true) == 0 || strcmp(cmd, "/cu", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(IsACop(playerid) || IsAFreecop(playerid))
			{
			    tmp = strtok(cmdtext, idx);
				if(!strlen(tmp)) {
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Playerid/PartOfName]");
					return 1;
				}
				if(PlayerInfo[playerid][pDBanned] == 1)
				{
			    	SendClientMessage(playerid, COLOR_GREY, "* You are Banned From Cop Duty!");
			    	return 1;
				}
				if(PlayerInfo[playerid][pDuty] == 0)
				{
			    	SendClientMessage(playerid, COLOR_GREY, "* You aren't on Duty!");
			    	return 1;
				}
				giveplayerid = ReturnUser(tmp);
			    if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
				        {
				            SendClientMessage(playerid, COLOR_GREY, "* You can't Cuff Cops !");
					        return 1;
				        }
				        if(GaveUp[giveplayerid] == 0)
					    {
					        SendClientMessage(playerid, COLOR_GREY, "* Player Didn't Gave up!");
					        return 1;
					    }
					    if(PlayerCuffed[giveplayerid] > 0)
					    {
					        SendClientMessage(playerid, COLOR_GREY, "* Player already Cuffed !");
					        return 1;
					    }
						if (ProxDetectorS(8.0, playerid, giveplayerid))
						{
						    if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot cuff yourself!");
						    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
     	 					format(string, sizeof(string), "* You were Cuffed by %s, till uncuff.", sendername);
							SendClientMessage(giveplayerid, COLOR_WHITE, string);
							format(string, sizeof(string), "* You Cuffed %s, till uncuff.", giveplayer);
							SendClientMessage(playerid, COLOR_WHITE, string);
							format(string, sizeof(string), "* %s Hand Cuffs %s, so he wont go anywhere.", sendername ,giveplayer);
							ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
							GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
							TogglePlayerControllable(giveplayerid, 1);
							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);
							cufftimer[giveplayerid] = SetTimerEx("CheckDist",10000,true,"ii",giveplayerid,playerid);
						}
						else
						{
						    SendClientMessage(playerid, COLOR_GREY, "* That player is not near you !");
						    return 1;
						}
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "* That player is Offline !");
				    return 1;
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "* You are not a Cop / FBI / National Guard !");
			}
		}
		return 1;
	}
Reply
#4

Of course you can, and it's easy, too!
First, you need to check if the player is near the other one(If you want to of course).
You will need something like this:
pawn Код:
new giveplayerid;(It's the guy we're gonna cuff)
TogglePlayerControllable(giveplayerid, 0); // so he cant move
SetPlayerSpecialAction(giveplayerid, SPECIAL_ACTION_CUFFED); // will put his hands behind back with cuffs
But you need to make the whole command for it of course, like /cuff ID

EDIT:To edit your code, this is it:
pawn Код:
if(strcmp(cmd, "/cuff", true) == 0 || strcmp(cmd, "/cu", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {

                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp)) {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Playerid/PartOfName]");
                    return 1;
                }

                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        {
                            SendClientMessage(playerid, COLOR_GREY, "* You can't Cuff Cops !");
                            return 1;
                        }
                        if(GaveUp[giveplayerid] == 0)
                        {
                            SendClientMessage(playerid, COLOR_GREY, "* Player Didn't Gave up!");
                            return 1;
                        }
                        if(PlayerCuffed[giveplayerid] > 0)
                        {
                            SendClientMessage(playerid, COLOR_GREY, "* Player already Cuffed !");
                            return 1;
                        }
                        if (ProxDetectorS(8.0, playerid, giveplayerid))
                        {
                            if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot cuff yourself!");
                            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "* You were Cuffed by %s, till uncuff.", sendername);
                            SendClientMessage(giveplayerid, COLOR_WHITE, string);
                            format(string, sizeof(string), "* You Cuffed %s, till uncuff.", giveplayer);
                            SendClientMessage(playerid, COLOR_WHITE, string);
                            format(string, sizeof(string), "* %s Hand Cuffs %s, so he wont go anywhere.", sendername ,giveplayer);
                            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                            GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
                            TogglePlayerControllable(giveplayerid, 1);
                            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);
                            cufftimer[giveplayerid] = SetTimerEx("CheckDist",10000,true,"ii",giveplayerid,playerid);
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GREY, "* That player is not near you !");
                            return 1;
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "* That player is Offline !");
                    return 1;
                }
           
        }
        return 1;
    }
Reply
#5

Here you are mate. Quickly made this up, tell me if it works or not.


Код:
CMD:cuff(playerid, params[])
{
	new targetid;
    new Skin;
	Skin = GetPlayerSkin(playerid);
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /cuff [id]");
	if(IsPlayerConnected(targetid))
    {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
    {
    new str[512];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new target[MAX_PLAYER_NAME];
    GetPlayerName(targetid, target, sizeof(target));
 	format(str, sizeof(str), "You have cuffed %s!");
    SendClientMessage(playerid, 0x0000BBAA, str);
    format(str, sizeof(str), "You have been cuffed by %s!");
    SendClientMessage(targetid, 0x0000BBAA, str);
    SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);//this will set the object cuffs at the hand of the player you want to cuff.
    SetPlayerSpecialAction(targetid,SPECIAL_ACTION_CUFFED);
    return 1;
    }

	}
    return 1;
}
Reply
#6

@Nines where should I put this? should I replace it with the /cuff I have now? and will this work for other factions such as FBI etc..
Reply
#7

Both codes will work if you put it on the same script, and yes, EVERYONE on the server can /cuff, isn't that what you requested?

EDIT: Yes replace the /cuff you got now.
Reply
#8

what I requested was it so I can cuff a cop, because if an offduty cop does something wrong ingame i want to be able to cuff and arrest the.
sorry worded my question wrong to begin with, I want it to be so a Cop can cuff another Cop
Reply
#9

You should consider making it where On Duty cops cant cuff Other On Duty Cops, or else you may be trying to arrest a suspect and you'll accidentally handcuff your partner cause hes too close.
Reply
#10

Well with the /cuff it goes needs id of the player you want to be cuffed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)