Detecting if playerid is in range of vehicleid
#1

How do I detect if a playerid is in range (55.0) of vehicleid?

Thanks in advance!
Reply
#2

pawn Code:
RespawnNearbyVehicles(playerid, Float:radi)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i=1; i<MAX_VEHICLES; i++)
    {
        if(GetVehicleModel(i))
        {
            new Float:posx, Float:posy, Float:posz;
            new Float:tempposx, Float:tempposy, Float:tempposz;
            GetVehiclePos(i, posx, posy, posz);
            tempposx = (posx - x);
            tempposy = (posy - y);
            tempposz = (posz - z);
            if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
            {
                SetVehicleToRespawn(i);
            }
        }
    }
}
Usage
pawn Code:
RespawnNearbyVehicles(playerid, radius);
Reply
#3

That doesn't look right.... That respawns the cars. I want it to check if a player is in range (55.0) of a certain vehicle (I will be using with GetNearestVehicle).

Anyone know?
Reply
#4

pawn Code:
new Float:X,Float:Y,Float:Z;
GetVehiclePos(vehicleid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 55.0, X, Y, Z))
{
     ...
}
Reply
#5

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)