RegisterNUICallback(
"GetNearPlayers",
function(data, cb)
local playerPed = PlayerPedId()
local players, nearbyPlayer = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0)
local foundPlayers = false
local nearplayers = {}
local elements = {}
for i = 1, #players, 1 do
if players[i] ~= PlayerId() then
foundPlayers = true
table.insert(nearplayers, {id = GetPlayerServerId(players[i])})
end
end
if not foundPlayers then
exports.pNotify:SendNotification(
{
text = _U("players_nearby"),
type = "error",
timeout = 3000,
layout = "bottomCenter",
queue = "inventoryhud"
}
)
else
ESX.TriggerServerCallback("getplayers", function(lol)
elements = lol
SendNUIMessage(
{
action = "nearPlayers",
foundAny = foundPlayers,
players = elements,
item = data.item
}
)
end, nearplayers)
end
cb("ok")
end)