Attach Object To Player [Please Help Me] -
Tommy_Mandaz - 20.06.2011
The code:
pawn Код:
CMD:cone(playerid, params[])
{
new string[128], sendername[MAX_PLAYER_NAME];
new oldcar = gLastCar[playerid];
new model = GetVehicleModel(oldcar);
if(gPlayerInfo[playerid][pFaction] == 1)
{
if(model == 413)
{
if(!IsPlayerInAnyVehicle(playerid))
{
if(ItemHolding[playerid] == 0)
{
new Float:tx,Float:ty,Float:tz;
GetVehiclePos(oldcar, tx, ty, tz);
if(IsPlayerInRangeOfPoint(playerid, 10, tx, ty, tz))
{
ItemHolding[playerid] = 1;
TrafficCone[playerid] = CreateObject(1210,0,0,0,0,0,0,0);
RemovePlayerAttachedObject(playerid, 5);
SetPlayerAttachedObject(playerid,5,1210,6,0.271233, 0.078992, 0.041259, 0.349204, 260.329711, 358.628845);
GetPlayerName(playerid, sendername, sizeof(sendername));
Fmsg("%s opens the back of the truck and takes out a traffic cone", sendername);
SLM(playerid, string, 15, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not near the truck!");
}
}
else
{
ItemHolding[playerid] = 0;
DestroyObject(TrafficCone[playerid]);
RemovePlayerAttachedObject(playerid, 5);
GetPlayerName(playerid, sendername, sizeof(sendername));
Fmsg("%s opens the back of the truck and puts a traffic cone inside", sendername);
SLM(playerid, string, 15, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}
}
}
}
return 1;
}
Part that is not working in the code:
pawn Код:
SetPlayerAttachedObject(playerid,5,1210,6,0.271233, 0.078992, 0.041259, 0.349204, 260.329711, 358.628845);
Problem is the object, street cone, is not attaching to the player? Why please help me!
Re: Attach Object To Player [Please Help Me] -
=WoR=Varth - 20.06.2011
pawn Код:
SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0);
Maybe you put the wrong number of arguments or IDK what's that called.
Btw what is this?
pawn Код:
TrafficCone[playerid] = CreateObject(1210,0,0,0,0,0,0,0);
RemovePlayerAttachedObject(playerid, 5);
Re: Attach Object To Player [Please Help Me] -
Tommy_Mandaz - 20.06.2011
I added the other 3 arguements I was missing and same result, For the removeplayerattachedobject I did that to make sure they had no other object on them, then for the TrafficCone[playerid] it is so I can delete the object that is created after the player tried to return the cone:
pawn Код:
ItemHolding[playerid] = 0;
DestroyObject(TrafficCone[playerid]);
RemovePlayerAttachedObject(playerid, 5);
GetPlayerName(playerid, sendername, sizeof(sendername));
Fmsg("%s opens the back of the truck and puts a traffic cone inside", sendername);
SLM(playerid, string, 15, COLOR_PURPLE, COLOR_PURPLE);
Like I said for some odd reason the there is no object and nothing appears but the action text appears

.
Re: Attach Object To Player [Please Help Me] -
=WoR=Varth - 20.06.2011
pawn Код:
#define SetPlayerHoldingObject(%1,%2,%3,%4,%5,%6,%7,%8,%9) SetPlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1,%2,%3,%4,%5,%6,%7,%8,%9)
#define StopPlayerHoldingObject(%1) RemovePlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
#define IsPlayerHoldingObject(%1) IsPlayerAttachedObjectSlotUsed(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
Maybe it's needed.
EDIT:Maybe you put the wrong pos so it would be in the sky, undergroud, of far away from you.
I don't know to' I'm a 5 days scripter.
Re: Attach Object To Player [Please Help Me] -
Tommy_Mandaz - 20.06.2011
Same result the cone isnt showing up and not attaching to the player

.
Re: Attach Object To Player [Please Help Me] -
=WoR=Varth - 21.06.2011
pawn Код:
SetPlayerAttachedObject(playerid,5,1210,6);
If you don't see any object then I'm fail
Re: Attach Object To Player [Please Help Me] -
Tommy_Mandaz - 21.06.2011
That didnt work either, anyone please help me out with this problem?
Re: Attach Object To Player [Please Help Me] -
[$A$]W33D$P33D - 21.06.2011
there is a very nice script on sa-mp forum for player holding objects easy to use aswell and to debug as a player too ill have a look on my pc where i put it i used it in my server its very kewl the objects attach to your head or hands or shoulders or feet or privates and moves with the body.........
Re: Attach Object To Player [Please Help Me] -
Tommy_Mandaz - 21.06.2011
Okay thanks you.
Re: Attach Object To Player [Please Help Me] -
Tommy_Mandaz - 21.06.2011
Anyone please