ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
client

GetPlayerServerId

FiveM client native documentation with a Lua example.

Summary

Returns the server ID for a local player index. The server ID is the stable number you use in events and server logic.

Returns

number — the server ID.

Parameters

playernumberThe local player index.

Example

local myServerId = GetPlayerServerId(PlayerId())

Common pitfalls

  • Don't confuse PlayerId() (local index) with the server ID.
  • Server IDs are what you send in events and match on the server.

Related natives

Related guides

FiveM scripts done right

Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.

Browse Scripts →