Hello, good morning.
I was trying to show the UID of each player in his head with "exports.zrx_uniqueid:GetUID" but the only thing I got was to show my own UID over their heads, I wanted to know if it is possible to export the UID of each player in his head.
I will leave the code that I use to show the ids, I have been doing this for a few days, I am quite new to the subject but I wanted to clear my doubt if it is possible to do it or not, since I do not know if I am making a mistake or directly with the export that I am using it is not possible to obtain the result that I am looking for.
Citizen.CreateThread(function()
TriggerServerEvent("tgiann-showid:add-id")
while true do
Citizen.Wait(1)
if IsControlPressed(0, TGIANN.key) or forceDraw then
for k, v in pairs(GetNeareastPlayers()) do
local x, y, z = table.unpack(v.coords)
local textoCompleto = v.playerId .. " - " .. v.idunica
Draw3DText(x, y, z + 1.1, textoCompleto, 1.6)
Draw3DText(x, y, z + 1.20, v.topText, 1.0)
end
end
end
end)
RegisterNetEvent('tgiann-showid:client:add-id')
AddEventHandler('tgiann-showid:client:add-id', function(identifier, playerSource)
if playerSource then
onlinePlayers[playerSource] = identifier
else
onlinePlayers = identifier
end
end)
RegisterCommand(TGIANN.commandName, function()
if not forceDraw then
forceDraw = not forceDraw
Citizen.Wait(5000)
forceDraw = false
end
end)
function Draw3DText(x, y, z, text, newScale)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
if onScreen then
local dist = GetDistanceBetweenCoords(GetGameplayCamCoords(), x, y, z, 1)
local scale = newScale * (1 / dist) * (1 / GetGameplayCamFov()) * 100
SetTextScale(scale, scale)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 255)
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextDropShadow()
SetTextEdge(4, 0, 0, 0, 255)
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x, _y)
end
end
function GetNeareastPlayers()
local playerPed = PlayerPedId()
local players_clean = {}
local playerCoords = GetEntityCoords(playerPed)
if IsPedInAnyVehicle(playerPed, false) then
local playersId = tostring(GetPlayerServerId(PlayerId()))
local idunica = exports.zrx_uniqueid:GetUID(GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1))))
table.insert(players_clean, {topText = onlinePlayers[playersId], playerId = playersId, idunica = idunica, coords = playerCoords})
else
local players, _ = GetPlayersInArea(playerCoords, TGIANN.drawDistance)
for i = 1, #players, 1 do
local playerServerId = GetPlayerServerId(players[i])
local player = GetPlayerFromServerId(playerServerId)
local ped = GetPlayerPed(player)
if IsEntityVisible(ped) then
for x, identifier in pairs(onlinePlayers) do
if x == tostring(playerServerId) then
local idunica = exports.zrx_uniqueid:GetUID(GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1))))
table.insert(players_clean, {topText = identifier:upper(), playerId = playerServerId, idunica = idunica, coords = GetEntityCoords(ped)})
end
end
end
end
end
return players_clean
end
function GetPlayersInArea(coords, area)
local players, playersInArea = GetPlayers(), {}
local coords = vector3(coords.x, coords.y, coords.z)
for i=1, #players, 1 do
local target = GetPlayerPed(players[i])
local targetCoords = GetEntityCoords(target)
if #(coords - targetCoords) <= area then
table.insert(playersInArea, players[i])
end
end
return playersInArea
end
function GetPlayers()
local players = {}
for _, player in ipairs(GetActivePlayers()) do
local ped = GetPlayerPed(player)
if DoesEntityExist(ped) then
table.insert(players, player)
end
end
return players
end ```
I think it would be a good way to be able to identify people who reconnect to change their ids and avoid being sanctioned.