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