Only returns a table if val param is also of type table.

More intuitive. If I want the job count of a single job "police", I don't expect a table as a return value, but the count directly.
This commit is contained in:
Ilias Rbayti
2023-08-21 01:58:52 +02:00
parent acd18c6b15
commit 29fdf896f9
+3 -2
View File
@@ -264,7 +264,8 @@ function ESX.GetNumPlayers(key, val)
return ESX.Table.SizeOf(ESX.Players)
end
local valTable = (type(val) == "table" and val or {val})
local isValATable = (type(val) == "table")
local valTable = (isValATable and val or {val})
local numPlayers = {}
for i, val in ipairs(valTable) do
numPlayers[val] = 0
@@ -277,7 +278,7 @@ function ESX.GetNumPlayers(key, val)
end
end
return numPlayers
return (isValATable and numPlayers or numPlayers[val])
end
function ESX.GetPlayerFromId(source)