- Documentation
- Shared functions
- getDistanceBetweenElements
Function
getDistanceBetweenElements
Returns the distance between two elements in metres. With flat = true the height difference is ignored.
Syntax
float getDistanceBetweenElements(element a, element b [, bool flat = false])Arguments
aelement- The first element.
belement- The second element.
flatbool, optional = false- Horizontal distance only.
Returns
The distance; false for an invalid element, without a warning.
Example
addCommandHandler("dystans", function(player, _, name)
local other = getPlayerFromName(name or "")
if other then
outputChatBox(("%.1f m"):format(getDistanceBetweenElements(player, other)), player)
end
end)