Garry's Mod Wiki

Garry's Mod Wiki

  table ents.FindInBox( Vector boxMins, Vector boxMaxs )

Description

Returns all entities within the specified box.

This internally uses a Spatial Partition to avoid looping through all entities, so it is more efficient than using ents.GetAll for this purpose.

Clientside entities will not be returned by this function. Serverside only entities without networked edicts (entity indexes), such as point logic or Constraints are not returned either

Arguments

1 Vector boxMins
The box minimum coordinates.
2 Vector boxMaxs
The box maximum coordinates.

Returns

1 sequental table<Entity>
A table of all found entities.

Example

Returns a table of players in a box using ents.FindInBox

function ents.FindPlayersInBox( vCorner1, vCorner2 ) local tEntities = ents.FindInBox( vCorner1, vCorner2 ) local tPlayers = {} local iPlayers = 0 for i = 1, #tEntities do if ( tEntities[ i ]:IsPlayer() ) then iPlayers = iPlayers + 1 tPlayers[ iPlayers ] = tEntities[ i ] end end return tPlayers, iPlayers end

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...