diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index 973ca661..6ef5bbff 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -221,18 +221,36 @@ end ESX.GetPlayers = GetPlayers +local function checkTable(key, val, player, xPlayers) + for valIndex = 1, #val do + local value = val[valIndex] + if not xPlayers[value] then + xPlayers[value] = {} + end + + if (key == 'job' and player.job.name == value) or player[key] == value then + xPlayers[value][#xPlayers[value] + 1] = player + end + end +end + function ESX.GetExtendedPlayers(key, val) - local xPlayers = {} - for k, v in pairs(ESX.Players) do - if key then - if (key == 'job' and v.job.name == val) or v[key] == val then - xPlayers[#xPlayers + 1] = v - end - else - xPlayers[#xPlayers + 1] = v - end - end - return xPlayers + if not key then return ESX.Players end + + local xPlayers = {} + if type(val) == "table" then + for _, v in pairs(ESX.Players) do + checkTable(key, val, v, xPlayers) + end + else + for _, v in pairs(ESX.Players) do + if (key == 'job' and v.job.name == val) or v[key] == val then + xPlayers[#xPlayers + 1] = v + end + end + end + + return xPlayers end function ESX.GetPlayerFromId(source)