SA-MP Forums Archive
Is player in front of an object? - 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: Is player in front of an object? (/showthread.php?tid=343443)



Is player in front of an object? - Programie - 17.05.2012

Hi,

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).

Any ideas?


Re: Is player in front of an object? - ViniBorn - 17.05.2012

Maybe it can hepl you

http://forum.sa-mp.com/showthread.ph...nFrontOfPlayer
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));
}