local math = math local table = table local string = string local getElementMatrix = getElementMatrix local getPlayerAccount = getPlayerAccount local getPlayerName = getPlayerName local getElementData = getElementData local getElementType = getElementType math.clamp = function (value, min, max) return math.max(min, math.min(value, max)) end math.round = function (number) return (math.floor((number * (10 ^ 0)) + 0.5)) / (10 ^ 0) end table.copy = function (t) local new = {}; if not t or type(t) ~= 'table' then return new end for k, v in next, t, nil do if type(v) == 'table' then new[k] = table.copy(v) else new[k] = v end end return new; end table.size = function (t, iterate) if not t then return 0 end if type(t) ~= 'table' then return 0 end if next(t) == nil then return 0 end if iterate then return #t end local q = 0 for _ in next, t, nil do q = q + 1 end return q end table.find = function (tbl, value) if not tbl or type(tbl) ~= 'table' then return nil end if next(tbl) == nil then return nil end for key, val in next, tbl, nil do if val == value then return key, val end end return nil end table.ifind = function (tbl, value) if not tbl or type(tbl) ~= 'table' then return nil end if next(tbl) == nil then return nil end for key, val in next, tbl, nil do if key == value then return val end end return nil end string.change = function (s, t) if not s or type (s) ~= 'string' then return 'N/A', error ('O modulo '..t.reason..' não existe no arquivo de configuração!') end for w in s:gmatch ('${(%w+)}') do s = s:gsub ('${'..w..'}', tostring ((t and t[w]) or 'undefined')) end return s end isPlayer = function (element) if (not element) then return false end if (isElement(element) and getElementType(element) == 'player') then return true end return false end function getElementName(element) if not element or not isElement(element) then return 'N/A'; end if getElementType(element) == 'player' then return getPlayerName(element):gsub('_', ' ') or getPlayerName(element); end return 'N/A'; end function isElementInACL(player, acls) if (not isElement(player) or not getElementType(player) == 'player') then return false, error('Defina um jogador válido para a verificação.', 2) end if (not acls or not type(acls) == 'table') then return false, error('Defina uma tabela de ACL\'s para a verificação', 2) end local account = getAccountName(player) if not account then return false end if (account ~= 'guest') then for _, v in next, acls, nil do if (aclGetGroup(v) and isObjectInACLGroup('user.'..account, aclGetGroup(v))) then return true, v end end end return false end function isElementInData(player, datas) if (not isElement(player) or not getElementType(player) == 'player') then return false, error('Defina um jogador válido para a verificação.', 2) end if (not datas or not type(datas) == 'table') then return false, error('Defina uma tabela de ACL\'s para a verificação', 2) end for _, v in next, datas, nil do if getElementData(player, v) then return true, v end end return false end function getDistance2D(x1, y1, x2, y2) local dx = x1 - x2 local dy = y1 - y2 return math.sqrt(dx * dx + dy * dy) end function getDistance3D(x1, y1, z1, x2, y2, z2) local half2 = 1 / 2 local vectorX, vectorY, vectorZ = x2 - x1, y2 - y1, z2 - z1 return ((vectorX * vectorX) + (vectorY * vectorY) + (vectorZ * vectorZ)) ^ half2 end