SA-MP Forums Archive
How to get coords of the side of me? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to get coords of the side of me? (/showthread.php?tid=145498)



How to get coords of the side of me? - Torran - 02.05.2010

Ive heard of GetXYInfrontOfPlayer or something like that,
Anyway it gets the coords for infront of you,

And i was wondering how i would get the coords of the side of me?

Like how would i get the coords so if i was to put a command called /test

When i type that it will put me a few bit to the side of me? Either side it dont matter,
anyone know?


Re: How to get coords of the side of me? - Backwardsman97 - 02.05.2010

pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x2, y2, a);
    GetPlayerFacingAngle(playerid, a);
    if(GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x2 += (distance * floatsin(-a, degrees));
    y2 += (distance * floatcos(-a, degrees));
}
Well that's how you'd get the position in front of the player. You could edit it maybe and subtract an amount from the angle to get either side. Or you could try this which should get any direction around the player.

pawn Код:
stock GetOffsetFromPlayer(playerid, Float:x, Float:y, Float:z, Float:xo, Float:yo, Float:zo)
{
    new Float:pa;

    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, pa);
    x += (xo * sin(-pa)) + (yo * sin(pa + 90));
    y += (xo * cos(-pa)) + (yo * cos(pa + 90));
    z += zo;
}



Re: How to get coords of the side of me? - Torran - 02.05.2010

How would i use that second one you posted?