Getting new XY coordinates -
Whizion - 03.12.2013
So i have a coordinate, let's say:
x = 10, y = 2
And let's say i want to travel 20 "units" in 90° direction (west in-game).
What would be my new x and y?
Can you give me a snipet/function/explain how to do this?
Thank you.
Re: Getting new XY coordinates -
ReApZ - 03.12.2013
do /save [optional(name)]
goto savedpositions.txt in samp files
and get the new x y code
\Documents\GTA San Andreas User Files\SAMP
default
Re: Getting new XY coordinates -
Avi Raj - 03.12.2013
pawn Код:
new Float:X,Float:Y,Float:Z,Float:Angle;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
Then do what you want to do.
Re: Getting new XY coordinates -
Whizion - 03.12.2013
I don't want to manually do it, i want the server to calculate it.
For instance a function like this:
GetDistanceXY(current_x, current_y, distance, angle)
And it returns the new x/y, which are "distance" far from current_x and current_y at "angle".
Re: Getting new XY coordinates -
RajatPawar - 03.12.2013
pawn Код:
stock getNewCoordinatesInDirection(playerid, Float: fNewX, Float: fNewY, Float: fDistance = 2.0)
{
new Float: fOldX, Float: fOldY, Float: fOldZ, Float: fAngle;
GetPlayerPos(playerid, fOldX, fOldY, fOldZ);
GetPlayerFacingAngle(playerid, fAngle);
fNewX = fOldX + (fDistance * (floatcos(-(fAngle + 90), degrees)));
fNewY = fOldY + (fDistance * (floatsin(-(fAngle + 90), degrees)));
return 1;
}
You'll have to change
these lines in order to get the desired effect, because this is simple polar stuff, but I am unsure as to how the GTA: SA co - ordinates work.
Re: Getting new XY coordinates -
Whizion - 03.12.2013
Thanks a lot, that will help.