SA-MP Forums Archive
Retrieve position of an object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Retrieve position of an object (/showthread.php?tid=456230)



Retrieve position of an object - Drek - 05.08.2013

Hello,

I created a small function that creates an object, I would like to retrieve the position of the object for a command to see if the player is ready or not this object.

pawn Код:
if(strcmp(subcmd, "haha", true) == 0)
{
    if(IsPlayerInRangeOfPoint(playerid, 8.0, info[playerid][bObjet1], info[playerid][bObjet2], adavre_info[playerid][bObjet3]))
    {
        ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.1,0,1,1,1,1);
        FreezePlayer(playerid,"Freeze");
    }
    else
    {
        SendClientMessage(playerid, COLOR_JOB, "no position object");
    }
}
Here by the creation of the object

pawn Код:
o1[playerid] = CreateDynamicObject(2900,posX-0.16,posY+0.49,posZ-0.95,0.0,0.0,0.0,-1,-1,-1,250);
    o2[playerid] = CreateDynamicObject(2900,posX+0.29,posY+0.31,posZ-0.95,0.0,180.0,330.68,-1,-1,-1,250);
    o3[playerid] = CreateDynamicObject(2900,posX-0.05,posY-0.36,posZ-0.95,0.0,0.0,0.0,-1,-1,-1,250);

    info[playerid][bObjet1] = o1[playerid];
    info[playerid][bObjet2] = o2[playerid];
    info[playerid][bObjet3] = o3[playerid];

thank you for aid future
Cordialement,
Drek.


Re: Retrieve position of an object - Marricio - 05.08.2013

If you mean what I think you mean:

Use GetObjectPos, GetDynamicObjectPos in your case.

pawn Код:
new Float:objectx, Float:objecty, Float:objectz;
GetDynamicObjectPos( /* Objectid goes here, lets say*/ o1[playerid],  objectx, objecty, objectz );

// So you can do this
if(IsPlayerInRangeOfPoint(playerid, 8.0, objectx, objecty, objectz))



Re : Retrieve position of an object - Drek - 05.08.2013

Thank you for the quick response.

but instead of / * ObjectID goes here, lets say * /
Sence I put what.
Sorry I'm not English: s


Re: Retrieve position of an object - Marricio - 05.08.2013

That's the parameter where you put the object id, like for example o1[playerid].

GetDynamicObjectPos( o1[playerid], objectx, objecty, objectz );


Re : Retrieve position of an object - Drek - 05.08.2013

+1 reput.