32 lines
824 B
Lua
32 lines
824 B
Lua
local ESX = exports['es_extended']:getSharedObject()
|
|
|
|
ESX.RegisterServerCallback('mercyv-admin:getPlayers', function(source, cb)
|
|
local xPlayer = ESX.GetPlayerFromId(source)
|
|
|
|
if not xPlayer or xPlayer.getGroup() ~= 'admin' then
|
|
cb(nil)
|
|
return
|
|
end
|
|
|
|
local players = {}
|
|
local xPlayers = ESX.GetExtendedPlayers()
|
|
|
|
for _, xTarget in pairs(xPlayers) do
|
|
local targetId = xTarget.source
|
|
local ped = GetPlayerPed(targetId)
|
|
|
|
if ped and DoesEntityExist(ped) then
|
|
local coords = GetEntityCoords(ped)
|
|
table.insert(players, {
|
|
id = targetId,
|
|
name = GetPlayerName(targetId),
|
|
x = coords.x,
|
|
y = coords.y,
|
|
z = coords.z
|
|
})
|
|
end
|
|
end
|
|
|
|
cb(players)
|
|
end)
|