Client

Player

get_data

Returns the players data which is available to the client.

Function

--- Gets player data.
--- @param key string: Retrieve a specific data key (optional).
local function get_data(key)
    return boii.player_data
end

boii.get_data = get_data
exports('get_data', get_data)

Example

--- Retrieving all data    
local player_data = boii.get_data()

--- Accessing player data.
print('Player Data:', json.encode(player_data))
print('Player Identity:', json.encode(player_data.identity))
print('Player First Name:', player_data.identity.first_name)

--- Accessing nested values directly.
local player_identity = boii.get_data().identity
print('Player Identity:', json.encode(player_identity))
print('Player First Name:', player_identity.first_name)

local first_name = boii.get_data().identity.first_name
print('Player First Name:', first_name)

Last updated