Client
Player Data

Player Data (Client)

On the client side all player data is accessed through RP.PlayerData — a read-only metatable proxy backed by RP._PlayerData. The server pushes updates via the _rp-base:update net event; you never need to poll.


RP.PlayerData

The global player data proxy. Access it directly or listen for the load event.

-- After rp-base:playerLoaded fires, this is safe to access
local pd = RP.PlayerData
print(pd.pid)           -- database ID
print(pd.username)      -- chosen username
print(pd.coords)        -- current coords (live)
print(pd.ped)           -- current ped handle (live)
print(pd.xp)            -- current XP (from metadata)
print(pd.playtime)      -- seconds this session + stored playtime (live)
⚠️

RP.PlayerData is read-only. Writing to any key raises an error, except for coords and heading which trigger SetEntityCoords / SetEntityHeading.

To modify balances or metadata use RP.TriggerServerCallback or a server event — changes are pushed back down automatically.


Properties

PropertyTypeNotes
identifierstringLicense identifier
pidnumberDatabase row ID
groupstringPermission group
usernamestringDisplay name
discordpfpstringDiscord avatar URL
last_vehicletable?{ model, plate, data } of last stored vehicle
ped (live)numberox_lib cache.ped or GetPlayerPed(-1)
coords (live)vector3ox_lib cache.coords or entity coords
heading (live)numberEntity heading
state (live)tableLocalPlayer.state state bag
xp (live)numbermetadata.xp
sid (live)numberServer ID (from ox_lib cache or GetPlayerServerId)
playtime (live)numberElapsed session seconds + stored playtime
accountsproxyRead-only account balances (see below)
metadataproxyRead-only metadata (see below)

Writable props

RP.PlayerData.coords  = vector3(0, 0, 70)  -- teleports ped
RP.PlayerData.heading = 90.0               -- rotates ped

RP.PlayerData.accounts

Read-only proxy over the client's cached account balances.

print(RP.PlayerData.accounts["credits"])
-- writing raises an error — use a server callback to modify balances

RP.PlayerData.metadata

Read-only proxy over the client's cached metadata.

local jumps = RP.PlayerData.metadata["stunt_jumps"]

Events

rp-base:playerLoaded

Fired on the client when all player data has arrived from the server.

AddEventHandler('rp-base:playerLoaded', function()
    local pd = RP.PlayerData
    print('Loaded as', pd.username, '(pid', pd.pid .. ')')
end)
💡

This event fires after _rp-base:playerLoadedCB is processed. It is safe to read all of RP.PlayerData inside this handler.


Helper functions

RP.GetPlayerData()

Returns the raw RP._PlayerData table (plain, no metatable). Useful when you need to serialize or iterate all keys.

--- @return table
local raw = RP.GetPlayerData()

RP.GetPlayerRank()

Returns the player's rank name based on their current XP.

--- @return string
print(RP.GetPlayerRank())  -- "Drift King"

RP.Teleport(x, y, z, heading?)

Teleports the local player's ped. Accepts individual numbers or a vector3.

RP.Teleport(100.0, 200.0, 30.0)
RP.Teleport(vector3(100.0, 200.0, 30.0), 90.0)