mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user