[HELP] Player ID near me

I need help with a script.

I would like you to show on the screen the ID of the player who is nearby. But it’s not working. Can someone help me? Sorry for the english, I’m using google translator.

CLIENT.LUA

Citizen.CreateThread(function()
    Wait(50)
    while true do
        miid(0.815, 1.435, 1.0,1.0,0.50, "~w~ID PROXIMO:~r~  ".. GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1))) .. '', 255, 255, 255, 255)
        Citizen.Wait(1)
    end
end)

function miid(x,y ,width,height,scale, text, r,g,b,a, outline)
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(scale, scale)
	SetTextColour( 0,0,0, 255 )
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
	SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end

STAYS LIKE THIS

WHEN YOU LEAVE THE SERVER AND SIGN IN AGAIN, THE ID CHANGES

I want you to show the “use_id” of the player who is nearby, and not mine.
Thanks.

Bro. That doesn’t be a communication rp. It is better you ask them their id in ooc.

GetPlayerServerId(NetworkGetEntityOwner(GetPlayerPed(-1))) this doesn’t make sense?

You need a function to get the closest player to you, something along the lines of:

local greatestDist = 99999

for k, playerId in pairs(GetActivePlayers()) do
    if #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(GetPlayerPed(playerId))) < greatestDist then
        greatestDist = playerId -- Get playerId's server id
    end
end