20.07.2014, 14:13
How can I make if player will write a command it will turn his angle to the nearest vehicle?
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);
}