Server API
stg_lib server-side reference. Player methods, global exports, framework detection, and usable item registration.
All server-side interactions with ESX, QBCore, or QBOX go through stg_lib. Never call framework functions directly.
Get a Player
local Player = exports.stg_lib:getPlayer(source)Returns a unified Player object with framework-agnostic methods. Returns nil if no player exists for the given source.
Player methods
All methods use dot syntax on the Player object. Use Player:stg_method(...) (colon) or player.stg_method(player, ...) but never mix.
Money
local cash = Player:stg_getMoney('cash')
local bank = Player:stg_getMoney('bank')
Player:stg_addMoney('cash', 500)
Player:stg_removeMoney('bank', 1000)Inventory
local item = Player:stg_getItem('bread')
Player:stg_addItem('bread', 5)
Player:stg_removeItem('bread', 2)Job
local job = Player:stg_getJob()
-- { name = 'police', grade = 3, label = 'Police', grade_label = 'Sergeant' }
Player:stg_setJob('mechanic', 0)Identity and permissions
local permission = Player:stg_getPermission() -- 'admin' | 'user' | etc.
local gender = Player:stg_getGender() -- 'm' | 'f'
local nationality = Player:stg_getNationality()
local dob = Player:stg_getDob()
local name = Player:stg_getName() -- { firstname, lastname }
local vehicles = Player:stg_getVehicles() -- list of owned vehiclesIdentity fields (name, gender, nationality, DOB) are cached on first read. You do not need to cache them yourself.
Global exports
Get all online players
local players = exports.stg_lib:getAllPlayers()Get jobs list
local jobs = exports.stg_lib:getJobs()Get framework
local Framework, frameworkName = exports.stg_lib:getFramework()
-- frameworkName: 'esx' | 'qbcore' | 'qbox'Register a usable item
exports.stg_lib:registerUsableItem('bread', function(source)
local Player = exports.stg_lib:getPlayer(source)
Player:stg_removeItem('bread', 1)
-- your logic
end)Still having trouble?
Open a ticket on our Discord. Our team answers around 15 hours a day.