mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Rewrote .SizeOf() function
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user