[Solved] Player facing vehicle
#1

Hi


I'm making some speed radar.

This is how it should work:

You look in an direction.
You can check the speed of a vehicle in range of 100.
The angle degree would be 15.

The speed radar shall not find any vehicles outside the 15 degree and 100 range.
It shall find the closest vehicle that follows up with the requirements.
A vehicle that is beside him or behind him shall make no effect on this speed radar.

But to start it out, i need to know how i'm going to find the players position, players angle and vehicles position.
To find the location of these things is easy, but how to put them all together so it works as i explained?

Much appreciated for any help.
Reply
#2

there are functios around like GetPointInFrontOf player and is player in circle the hard bit would be just checking a slice of that circle where the player is looking what if you get a point 50units in front of the player and check a 100unit circle there? it ckecking a bigger area but its a start
Reply
#3

Right now the only thing I really need is finding a way to know if the player is looking at the vehicle when typing /radar. There are no custom functions allowing that, right?

Thanks for the reply.
Reply
#4

well you can check if there are any cars in the 100m circle in 50m front of the player and he should be looking at them

these might be handy
pawn Код:
stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance){
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    else GetPlayerFacingAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
    return a;
}
and
pawn Код:
stock GetStartDirection(Float:angle) { // by Noobanatior
    new direction[16];
    if      (angle > 22.5 && angle <= 67.5) direction = "North East";
    else if (angle > 67.5 && angle <= 112.5) direction = "East";
    else if (angle > 112.5 && angle <= 157.5) direction = "South East";
    else if (angle > 157.5 && angle <= 202.5) direction = "South";
    else if (angle > 202.5 && angle <= 247.5) direction = "South West";
    else if (angle > 247.5 && angle <= 292.5) direction = "West";
    else if (angle > 247.5 && angle <= 337.5) direction = "North West";
    else direction = "North";
    return direction;
}
Reply
#5

having any luck?
Reply
#6

Thank you for your help and assist.

I've found a IfPlayerFacingPoint function on sa-mp..
That works as a charm.

This topic is solved!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)