how can I check if a player is in the front of an object? I need such a function for my speed cameras.
The players speed should only be checked if the player is in the visible area of the speed camera (Object model: 18880).
pawn Code:
forward GetXYInFrontOfPlayer2(playerid, &Float, &Float:y, Float:distance, Float:angle);
public GetXYInFrontOfPlayer2(playerid, &Float, &Float:y, Float:distance, Float:angle) {
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
a += angle;
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}