Skip to content

A3D_GetVehiclesInSphere

imshooter edited this page Oct 17, 2026 · 1 revision

Find the vehicles within a distance of a point, nearest first.

native A3D_GetVehiclesInSphere(
    Float:x,
    Float:y,
    Float:z,
    Float:radius,
    vehicles[],
    size = sizeof (vehicles),
    worldid = -1,
    interiorid = -1,
    bool:sight = false
);

Parameters

Parameter Description Default
Float:x Centre on the X axis.
Float:y Centre on the Y axis.
Float:z Centre on the Z axis.
Float:radius Distance from the centre.
vehicles[] The vehicles found.
size Room in vehicles. sizeof (vehicles)
worldid Virtual world of the vehicles, or -1 for any. -1
interiorid Interior of the vehicles, or -1 for any. -1
bool:sight Whether the centre must see it, with the map and static objects in the way. false

Returns

  • The number of vehicles written.

Remarks

A vehicle is measured from its position, the centre of its model. With sight, the line from the centre to that position must be free of the map and of static objects. The vehicles are written nearest first.

Example

A mechanic repairs every vehicle within ten metres.

stock RepairAround(playerid) {
    new
        Float:x,
        Float:y,
        Float:z,
        vehicles[32],
        count
    ;

    GetPlayerPos(playerid, x, y, z);
    count = A3D_GetVehiclesInSphere(x, y, z, 10.0, vehicles, .worldid = GetPlayerVirtualWorld(playerid));

    for (new i; i != count; ++i) {
        RepairVehicle(vehicles[i]);
    }
}

Related

Home

Guides

Reference

Functions

Creating objects
Motion
Placement
Behaviour
Display and data
Rays
Shapes
Players, vehicles and actors
Map probes
Screen
Map objects
Water
Models and surfaces
Rotations and offsets
Vehicles
Routes
Route display
Walking
Callbacks

Clone this wiki locally