06.12.2009, 16:40
PlayerDirection(playerid)
This function gets the direction a player is going:
Returns:
N - North
E - East
S - South
W - West
Note that the function has been setup backwards because SA-MP's directions are backwards.
This function gets the direction a player is going:
Returns:
N - North
E - East
S - South
W - West
Note that the function has been setup backwards because SA-MP's directions are backwards.
pawn Код:
stock PlayerDirection(playerid)
{
new
Float:ang,
dir[2];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
else
GetPlayerFacingAngle(playerid, ang);
if (ang > 45 && ang < 135)
format(dir, sizeof(dir), "W");
else if (ang > 135 && ang < 225)
format(dir, sizeof(dir), "S");
else if (ang > 225 && ang < 315)
format(dir, sizeof(dir), "E");
else
format(dir, sizeof(dir), "N");
return dir;
}