check a players direction - 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: check a players direction (
/showthread.php?tid=165592)
check a players direction -
Kar - 05.08.2010
how do i detect what direct the player is going in south southwest east west north etc?
like use angles?
If hes 180 north 360 south
is this the best way
Re: check a players direction -
Hiddos - 05.08.2010
pawn Код:
new A; GetPlayerFacingAngle(playerid, A);
if(A < 45 || A > 315) print("Going north");
if(A > 225 && A < 315) print("Going west");
if(A > 135 && A < 225) print("Going south");
if(A > 45 && A < 135) print("Going east");
Might work, I don't know if 90 degrees is west or east ^^
Re: check a players direction -
Kar - 05.08.2010
mhm saved me alot of typing thx lol just needed to clarify
edit. is there a possiblilty to detect what angle he is from you?
like south west from you
Re: check a players direction -
Joe_ - 05.08.2010
360 - North
315 - North-West
270 - West
225 - South-West
180 - South
135 - South-East
090 - East
045 - North-East
0 - Same as 360, North
Re: check a players direction -
Kar - 05.08.2010
so to detect what direction someone is from you
i do like..>?
Re: check a players direction -
MadeMan - 05.08.2010
Use atan2(x, y);
For example:
pawn Код:
new Float:p1x, Float:p1y, Float:p1z;
GetPlayerPos(playerid1, p1x, p1y, p1z);
new Float:p2x, Float:p2y, Float:p2z;
GetPlayerPos(playerid2, p2x, p2y, p2z);
new Float:angle;
angle = atan2(p2x-p1x,p2y-p1y);
Re: check a players direction -
Hiddos - 05.08.2010
Wut... I needed that *** ****** function a long time before (atan2) and you just... posted it?
Im gonna retire if everybody is pwning me this hard..
Re: check a players direction -
Kar - 05.08.2010
lmao i dont even understand how to use it xD
Re: check a players direction -
MadeMan - 05.08.2010
Quote:
Originally Posted by Kar
lmao i dont even understand how to use it xD
|
angle is the direction you wanted.
Re: check a players direction -
Kar - 05.08.2010
I need it in a command I made something to show his x y z coords but I need to to show the direction the player is from me like 0.36086(south-west)
will it do that?