Skip to content

A3D_GetPlayersInCone

imshooter edited this page Oct 17, 2026 · 1 revision

Find the players inside a cone, such as the view of a guard or the spread of a shotgun, nearest first.

A player is measured at the height of the chest. With sight, a player behind the map or a static object is left out.

native A3D_GetPlayersInCone(
    Float:x,
    Float:y,
    Float:z,
    Float:directionX,
    Float:directionY,
    Float:directionZ,
    Float:angle,
    Float:range,
    players[],
    size = sizeof (players),
    worldid = -1,
    interiorid = -1,
    bool:sight = false,
    exceptid = INVALID_PLAYER_ID
);

Parameters

Parameter Description Default
Float:x Apex of the cone on the X axis.
Float:y Apex on the Y axis.
Float:z Apex on the Z axis.
Float:directionX Direction of the cone on the X axis.
Float:directionY Direction on the Y axis.
Float:directionZ Direction on the Z axis.
Float:angle Angle between the direction and the side of the cone, in degrees.
Float:range Length of the cone.
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 apex must see the player. false
exceptid A player to leave out, such as the one who looks. INVALID_PLAYER_ID

Returns

  • The number of players written.

Remarks

The cone opens from its apex along the direction, which needs no particular length. angle is the angle between that direction and the side of the cone, so 10.0 makes a cone 20 degrees wide. A player is inside when their chest lies within the cone and within range of the apex.

The players are written nearest first. exceptid leaves out one player, usually the one at the apex.

Example

Finds who a shotgun blast reaches, along the camera of the shooter.

stock GetShotgunTargets(playerid, targets[], size = sizeof (targets)) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:frontX,
        Float:frontY,
        Float:frontZ
    ;

    GetPlayerCameraPos(playerid, x, y, z);
    GetPlayerCameraFrontVector(playerid, frontX, frontY, frontZ);

    return A3D_GetPlayersInCone(x, y, z, frontX, frontY, frontZ, 8.0, 20.0, targets, size, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), true, playerid);
}

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