Cuff doesnt work properly
#1

Everything works except the cuff does not appear as it is supposed to:
Код:
COMMAND:cuff(playerid,params[])
{
	new obj,pname[MAX_PLAYER_NAME],rname[MAX_PLAYER_NAME],string[128],string1[128],string2[128],id,Float:x,Float:y,Float:z;
	if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /cuff id");
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFFFFFFFF,"Player not connected!");
	if(cuffed[id] == 1) return SendClientMessage(playerid,0xFFFFFFFF,"This player is already cuffed!");
	if(copduty[playerid] == 0) return SendClientMessage(playerid,0xFFFFFFF,"Only on duty police may use this command!");
	GetPlayerPos(playerid,x,y,z);
	GetPlayerName(playerid,pname,sizeof(pname));
	GetPlayerName(id,rname,sizeof(rname));
	if(IsPlayerInRangeOfPoint(id,5,x,y,z))
	{
	obj = CreateObject(19418,0,0,0,0,0,0,0);
	SetPlayerAttachedObject(id,5,obj, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);
	SetPlayerSpecialAction(id,24);
	format(string,sizeof(string),"You have cuffed %s(%i).",rname,id);
	format(string1,sizeof(string),"You have been cuffed by %s(%i).",pname,playerid);
	format(string2,sizeof(string2),"%s(%i) takes their handcuffs, cuffing %s(%i).",pname,playerid,rname,id);
	SendClientMessage(playerid,0xFFFFFFFF,string);
	SendClientMessage(id,0xFFFFFFFF,string1);
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if(IsPlayerInRangeOfPoint(i,5,x,y,z))
	{
	SendClientMessage(i,0xc2a2daFF,string2);
	}
	}
	cuffed[id] = 1;
	}
	else
	{
	SendClientMessage(playerid,0xFFFFFFFF,"You are not close enough to cuff this person!");
	}
	return 1;
}
Reply
#2

Are you sure the targetid don't got the max objects on himself when trying to give him another?

(from the wiki): Note: This function is seperate from the CreateObject / CreatePlayerObject pools.

https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject

You don't have to use CreateObject before atatching the object, everyone have 10 slots for attatchedobjects, use the function properly and it will work

https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject

Edit: Here's the working attatchedobject code anyways:

Код:
SetPlayerAttachedObject(id,5,19418/*[I CHANGED THIS TO THE MODELID]*/, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)