Skip to content

Commit

Permalink
Merge pull request #1201 from Gellipapa/dev
Browse files Browse the repository at this point in the history
💥 Fix breaking change
  • Loading branch information
Gellipapa authored Sep 4, 2023
2 parents 53f8eb1 + d2ac393 commit 8d9d1c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions [core]/es_extended/server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,9 @@ end, false)

ESX.RegisterCommand('players', "admin", function()
local xPlayers = ESX.GetExtendedPlayers() -- Returns all xPlayers
local count = 0
for _, xPlayer in pairs(xPlayers) do
count += 1
print(('^5%s^2 online player(s)^0'):format(#xPlayers))
for i = 1, #(xPlayers) do
local xPlayer = xPlayers[i]
print(('^1[^2ID: ^5%s^0 | ^2Name : ^5%s^0 | ^2Group : ^5%s^0 | ^2Identifier : ^5%s^1]^0\n'):format(xPlayer.source, xPlayer.getName(), xPlayer.getGroup(), xPlayer.identifier))
end
print(('^5%s^2 online player(s)^0'):format(count))
end
end, true)
8 changes: 5 additions & 3 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,18 @@ local function checkTable(key, val, player, xPlayers)
end

function ESX.GetExtendedPlayers(key, val)
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
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
Expand Down

0 comments on commit 8d9d1c2

Please sign in to comment.