ents.FindInBox

From Garry's Mod
Jump to: navigation, search
 ents.FindInBox( )

Contents

Description

Returns all entities within the specified box.

NOTE

Clientside entities will not be returned by this function.

WARNING

There is a limit of 512 entities for the output!

Arguments

Vector boxMins

The box minimum coordinates.

Arguments

Vector boxMaxs

The box maximum coordinates.

Returns

table

A table of all found entities.

Examples

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


Personal tools
Navigation