- Documentation
- Shared functions
- getElementsWithinRange
Function
getElementsWithinRange
Returns elements within a radius of a point, optionally only of a given type and dimension.
Syntax
table getElementsWithinRange(float x, float y, float z, float range [, string elemType = nil, int dimension = nil])Arguments
xfloat- Centre X.
yfloat- Centre Y.
zfloat- Centre Z.
rangefloat- Radius in metres.
elemTypestring, optional = nil- Element type.
dimensionint, optional = nil- Dimension.
Differences from MTA:SA
- These MTA:SA arguments are not here:
int dimension = nil
In MTA:SA
getElementsWithinRange(float x, float y, float z, float range, string elemType = "", int interior = nil, int dimension = nil)Returns
A table of elements.
Example
addCommandHandler("krzyk", function(player, cmd, ...)
local x, y, z = getElementPosition(player)
local text = table.concat({ ... }, " ")
for _, p in ipairs(getElementsWithinRange(x, y, z, 40, "player")) do
outputChatBox(getPlayerName(player) .. " krzyczy: " .. text, p, 255, 120, 0)
end
end)