Rewrote .SizeOf() function

This commit is contained in:
ElPumpo
2019-04-15 11:14:37 +02:00
parent a0cc840ec9
commit 16a78f4613
+4 -12
View File
@@ -2,21 +2,13 @@ ESX.Table = {}
-- nil proof alternative to #table
function ESX.Table.SizeOf(t)
local keys = {}
local count = 0
for k,v in pairs(t) do
table.insert(keys, tonumber(k))
for _,_ in pairs(t) do
count = count + 1
end
table.sort(keys, function(a, b)
return a < b
end)
if #keys > 0 then
return keys[#keys]
else
return 0
end
return count
end
function ESX.Table.IndexOf(t, value)