-1 meaning?

Hi, I’m quite new to fiveM and I see people are using -1 as playerID for GetPlayerPed.

I can’t find the meaning of -1 anywhere. Does -1 return the localPlayer always?

Thanks

1 Like

The function GetPlayerPed(playerId) takes “playerId”. Using -1 as your playerId will return the player for which the script is running.
An alternative to GetPlayerPed() is PlayerPedId() which is what most people use right now.
PlayerPedId() returns the same thing as GetPlayerPed(-1)

6 Likes

Thank you for your answer. But with ‘for which the script is running’, that is client side right? So for serverside you need to use PlayerPedId()? (or need to loop through players I guess :stuck_out_tongue:)

Both functions are client side, you can’t use them on the server. If for some reason you need to get the player ped on the server, you’d have to trigger a client event from the server, then have that client event get the player id and pass that on by triggering a server event.

Got it! Thanks :slight_smile: