Attach Object To Player [Please Help Me]
#1

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!
Reply
#2

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);
Reply
#3

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 .
Reply
#4

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.
Reply
#5

Same result the cone isnt showing up and not attaching to the player .
Reply
#6

pawn Код:
SetPlayerAttachedObject(playerid,5,1210,6);
If you don't see any object then I'm fail
Reply
#7

That didnt work either, anyone please help me out with this problem?
Reply
#8

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.........
Reply
#9

Okay thanks you.
Reply
#10

Anyone please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)