delete car infront of me
#1

pawn Код:
new Float:playerpos[3];
    GetPlayerPos(playerid, playerpos[0], playerpos[1], playerpos[2]);

    for(new v = 0; v < MAX_VEHICLES; v++)
    {
        if(IsPlayerInRangeOfPoint(v, 4, playerpos[0], playerpos[1], playerpos[2]))
        {
            DestroyVehicle(v);
        }
    }
this doesnt work for me why
Reply
#2

Because IsPlayerInRangeOfPoint takes a playerid as the first parameter, not the vehicle id.
If you want here is a working code for what you need, with a function called
'CheckPlayerDistanceToVehicle', so you can use that to check, or make your own by looking at it.

pawn Код:
stock CheckPlayerDistanceToVehicle( Float:radi, playerid, vehicleid )
{
    // Function: CheckPlayerDistanceToVehicle( Float:radi, playerid, vehicleid )

    new
        Float:vX, Float:vY, Float:vZ;

    GetVehiclePos( vehicleid, vX, vY, vZ );
   
    return IsPlayerInRangeOfPoint( playerid, radi, vX, vY, vZ );
}
Example of usage would be:
pawn Код:
CheckPlayerDistanceToVehicle( 3.5, playerid, vehid ) )
That checks if a player is in a 3.5 radius of the vehicle with the vehid as the vehicle id.
Cheers !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)