Skip to content

A3D_GetPlayersInSphere

imshooter edited this page Oct 17, 2026 · 1 revision

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

Players who are not spawned, are dead or spectate are left out.

native A3D_GetPlayersInSphere(
    Float:x,
    Float:y,
    Float:z,
    Float:radius,
    players[],
    size = sizeof (players),
    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.
players[] The players found.
size Room in players. sizeof (players)
worldid Virtual world of the players, or -1 for any. -1
interiorid Interior of the players, 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 players written.

Remarks

A player is measured from their position, the centre of the body about a metre above the feet. Players who are not spawned, are dead or spectate are left out. Players in vehicles are found too, at their own position.

With sight, the line from the centre to the chest of each player must be free of the map and of static objects, in the virtual world asked for.

The players are written nearest first, as many as size allows.

Example

Hurts the players an explosion reaches, but not the ones behind a wall.

stock HurtAround(Float:x, Float:y, Float:z, Float:radius, worldid) {
    new
        players[MAX_PLAYERS],
        count = A3D_GetPlayersInSphere(x, y, z, radius, players, .worldid = worldid, .sight = true),
        Float:health
    ;

    for (new i; i != count; ++i) {
        GetPlayerHealth(players[i], health);
        SetPlayerHealth(players[i], health - 30.0);
    }
}

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