Skip to content

A3D_GetActorsInSphere

imshooter edited this page Oct 17, 2026 · 1 revision

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

native A3D_GetActorsInSphere(
    Float:x,
    Float:y,
    Float:z,
    Float:radius,
    actors[],
    size = sizeof (actors),
    worldid = -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.
actors[] The actors found.
size Room in actors. sizeof (actors)
worldid Virtual world of the actors, or -1 for any. -1
bool:sight Whether the centre must see them, with the map and static objects in the way. false

Returns

  • The number of actors written.

Remarks

Actors have no interior, so only the virtual world filters them. With sight, the line from the centre to the chest of each actor must be free of the map and of static objects. The actors are written nearest first.

Example

The actors near a gunshot put their hands up.

public OnPlayerWeaponShot(playerid, WEAPON:weaponid, BULLET_HIT_TYPE:hittype, hitid, Float:fX, Float:fY, Float:fZ) {
    new
        Float:x,
        Float:y,
        Float:z,
        actors[16],
        count
    ;

    GetPlayerPos(playerid, x, y, z);
    count = A3D_GetActorsInSphere(x, y, z, 15.0, actors, .worldid = GetPlayerVirtualWorld(playerid));

    for (new i; i != count; ++i) {
        ApplyActorAnimation(actors[i], "SHOP", "SHP_Rob_HandsUp", 4.1, false, true, true, true, 0);
    }

    return 1;
}

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
Callbacks

Clone this wiki locally