Trying to create complex a complex playerinfrontofplayer
#1

I'm trying to create a script that detects if a player is in front of another player. I think it would be possible using getxyinfrontofplayer but I want it to be a little more complex than that. In other words, I am trying to detect if player1 is infront of player2 within a certain angle. I am really bad with coordinate math so any help would be appreciated.

Thanks


This screenshot is an example of what im looking for:
Reply
#2

Code:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;

    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);

    if (GetPlayerVehicleID(playerid)) {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Reply
#3

Code:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;

    GetPlayerPos(playerid, x, y, a);

	new veh;
    if ((veh = GetPlayerVehicleID(playerid)) != 0) {
        GetVehicleZAngle(veh, a);
    } else {
        GetPlayerFacingAngle(playerid, a);
    }

    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
more efficent..
Reply
#4

getxyinfrontofplayer only counts if it is directly in front of the player i thought. I was looking for somthing more along the lines of in front of the player within like 40 degrees or something.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)