Ocean Solutions

Player

Framework-agnostic player bridge supporting ESX, QBCore and QBX

Overview

The Player bridge wraps the three most common FiveM frameworks — ESX, QBCore, and QBX — behind a single, unified interface. The correct core is resolved automatically at runtime based on which resource is started.

Access a player object via the getPlayerFromId export.

Supported Frameworks

FrameworkResource name
ESXes_extended
QBCoreqb-core
QBXqbx_core

Player Class

---@class Player
---@field id number
---@field job table
---@field accounts table

Functions

getPlayerFromId

Ocean.getPlayerFromId(playerId)

Returns a Player instance for the given server ID. Instances are cached per session.

  • playerId: number
  • Returns: Player

Player:getJob

player:getJob()

Returns the player's current job table from the active framework.

  • Returns: table

Player:getAccounts

player:getAccounts()

Returns the player's account balances from the active framework.

  • Returns: table

Player:removeItem

player:removeItem(item, amount)

Removes amount of item from the player's ox_inventory.

  • item: string
  • amount: number
  • Returns: boolean

Player:getItemAmount

player:getItemAmount(item)

Returns how many of item the player currently has.

  • item: string
  • Returns: number

Player:addItem

player:addItem(item, amount)

Adds amount of item to the player's ox_inventory.

  • item: string
  • amount: number
  • Returns: boolean

Player:removeAccountMoney

player:removeAccountMoney(account, amount)

Deducts amount from the named account via the active framework.

  • account: string — e.g. "bank", "cash"
  • amount: number
  • Returns: boolean

Player:addAccountMoney

player:addAccountMoney(account, amount)

Credits amount to the named account via the active framework.

  • account: string
  • amount: number
  • Returns: boolean

Player:removeMoney

player:removeMoney(amount)

Removes cash from the player via the active framework.

  • amount: number
  • Returns: boolean

Player:addMoney

player:addMoney(amount)

Adds cash to the player via the active framework.

  • amount: number
  • Returns: boolean

Player:getGroup

player:getGroup()

Returns the player's permission group / admin level.

  • Returns: string

Example

local player = Ocean.getPlayerFromId(source)
 
 
local job = player:getJob()
if job.name == "police" then
    print("Player is a cop")
end
 
if player:removeAccountMoney("bank", 500) then
    Notify(source, "Charged $500 from your bank account.")
end
 
if player:getItemAmount("lockpick") > 0 then
    player:removeItem("lockpick", 1)
end

On this page