SA-MP Forums Archive
Distance between checkpoint and player on textdraw - 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: Distance between checkpoint and player on textdraw (/showthread.php?tid=260736)



Distance between checkpoint and player on textdraw - UTvern - 10.06.2011

Can someone please help me get the France between te displayed checkpoint and put on a textdraw


Re: Distance between checkpoint and player on textdraw - Sascha - 10.06.2011

I bet there are easier ways to do it, however I've just written up a short code that should fullfill what you need..
(didn't test the code)
pawn Code:
new Float:cx, Float:cy, Float:x, Float:y, Float:rst, Float:px, Float:py, Float:pz;
cx = 1.00; cy = 152.31;
GetPlayerPos(playerid, px, py, pz);
cx = floatabs(cx);
cy = floatabs(cy);
px = floatabs(px);
py = floatabs(py);
x = cx - px; y = cy - py;
x = floatabs(x);
y = floatabs(y);
rst = floatsqroot((x*x) + (y*y));
remember to replace the floats that I've used for cx and cy with your checkpoint's x and y coords

rst = the result as a float