[SOLVED] How to get the same player ID on server and client?


I try to something that look very special, because I don’t fourd any solution for that:
I do a simple for loop on xlient with that:

for i = 0, 31 do
    if HasEntityBeenDamagedByEntity(GetVehiclePedIsUsing(GetPlayerPed(i)), GetVehiclePedIsUsing(GetPlayerPed(-1)), 1) then
TriggerServerEvent('hc:damageRunner', i)

On server, I do that:

AddEventHandler('hc:damageRunner', function(n)
    TriggerClientEvent('hc:runnerTouched', n)

But “n” and “i” are not the same!

There is a way to have the server user id (source) on the client script?

I try NetworkPlayerGetUserId(i) but it’s a big number, not a simple int and all other NetworkPlayerBlaBlaBla only return bool!

So, there is a way to do that?

Thank you

you cant get the same ID of a player because everytime he rejoins he has a different ID

To get the serverid from the client you can do

GetPlayerServerId(client id)


Thank work well! Thank you!

Uh… anywhere? Assign it to a variable… put it in a function… do whatever. It returns the ID.

There is no resource. It is a function.

XD you should learn the base of programmation man or will be lost for long time ^^


Its a really basic thing. I can’t possibly explain it in terms you would understand if you don’t know how to use a function. I’m not saying this in a rude way, but go look at some basic Lua tutorials.

I could use help with the following tho, I’m working on some functionality to have players own carwashes and stuff… however, when i obtain a steamID from my database to find the owner to pay to, i can update the owners bank, but when he or she is online, it will not update on their hud, and whenever they log off, the owners bank will be saved to the same data the hud gets.
I’m using ESX, my question is = how do i obtain the proper id from a steamID to be able to use the user.setBank function from es or ESX, i’m not sure wich one has it.

EDIT: I figured it out lol
ESX.GetPlayerFromIdentifier(identifier) is what i needed :slight_smile: