Angle? - 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: Angle? (
/showthread.php?tid=527018)
Angle? -
Lajko1 - 20.07.2014
How can I make if player will write a command it will turn his angle to the nearest vehicle?
Re: Angle? -
Lajko1 - 21.07.2014
if you don't understand something feel free to ask...
Re: Angle? -
Virtual1ty - 21.07.2014
For what actually do you need this, it's very unrealistic to just rapidly 'look at' a vehicle.
As to how to do it, getting the angle between the two coords, use atan2 (or search for SetPlayerFacePoint by RyDeR` I think).
Re: Angle? -
Lajko1 - 21.07.2014
Well it for /plantbomb command when player will write that command near one car it will automaticly turn him towards that car he is near and apply animation "planting bomb"... that's why I need that
Re: Angle? -
Lajko1 - 23.07.2014
Bump
Re: Angle? -
[D]ry[D]esert - 23.07.2014
Not sure if you mean this:
pawn Код:
stock SetPlayerFacePlayer(playerid, vehicleid)
{
new Float:Px, Float:Py, Float: Pa;
GetPlayerPos(playerid, Px, Py, Pa);
new Float:fpX, Float:fpY, Float: fpZ;
GetVehiclePos(vehicleid, fpX, fpY, fpZ);
Pa = floatabs(atan((fpY-Py)/(fpX-Px)));
if(fpX <= Px && fpY >= Py) Pa = floatsub(180, Pa);
else if(fpX < Px && fpY < Py) Pa = floatadd(Pa, 180);
else if(fpX >= Px && fpY <= Py) Pa = floatsub(360.0, Pa);
Pa = floatsub(Pa, 90.0);
if(Pa >= 360.0) Pa = floatsub(Pa, 360.0);
if(!IsPlayerInAnyVehicle(playerid)) SetPlayerFacingAngle(playerid, Pa);
else SetVehicleZAngle(GetPlayerVehicleID(playerid), Pa);
}
And not sure who made this, but i've edited it to be like you want.
Re: Angle? -
Lajko1 - 23.07.2014
More then great, rep+ for you