Cuxial Tablet exposes its coins, the season pass XP, the VIP history and the tablet window to other resources, plus a few state bags to know what a player is doing. Everything else is internal.
Server exports
GetCoins
Returns the coin balance of an online player.
---@param src integer
---@return integer
local coins = exports.cuxial_tablet:GetCoins(source)AddCoins
Adds coins to an online player, records the movement in the wallet and refreshes the tablet. Returns whether it succeeded and the balance after it.
---@param src integer
---@param amount integer 1 or more
---@param reason? string shown in the wallet history
---@return boolean ok, integer balance
local ok, balance = exports.cuxial_tablet:AddCoins(source, 500, 'Tournament prize')RemoveCoins
Removes coins from an online player. Fails when the player cannot afford the amount.
---@param src integer
---@param amount integer
---@param reason? string
---@return boolean ok, integer balance
local ok, balance = exports.cuxial_tablet:RemoveCoins(source, 100, 'Casino entry')
if not ok then
-- not enough coins
endGrantPassXp
Gives season pass XP. The player levels up as needed and sees the gain on screen when online. Returns nil when the pass is disabled or the player is unknown.
---@param src integer|string server id or citizenid (works for offline players)
---@param amount integer
---@param source? string daily | shop | cases | job | playtime | mission | admin (default admin)
---@return { level: integer, xp: integer, leveled: boolean }?
local result = exports.cuxial_tablet:GrantPassXp(source, 250, 'job')EmitJobCompleted
Tells the tablet that a player completed a job. The pass grants pass.xpSources.jobComplete XP and the weekly job missions advance. Call it from the server only.
---@param src integer
---@param info? { job?: string, money?: number }
exports.cuxial_tablet:EmitJobCompleted(source, { job = 'trucker', money = 1200 })With cuxial_jobs running, the tablet listens to its cuxial_jobs:server:JobCompleted event and you do not need to call this.
LogHistory
Adds an entry to the player's VIP history, the list shown in the History tab.
---@param src integer|string server id or citizenid
---@param entry { source: string, title: string, subtitle?: string, amount?: integer, currency?: 'coins'|'cash'|'item', itemKey?: string, rarity?: string, ref?: string }
---@return boolean
exports.cuxial_tablet:LogHistory(source, {
source = 'admin',
title = 'Event reward',
amount = 200,
currency = 'coins',
})source is one of shop, cases, daily, pass, wallet, code, gift, loyalty, admin or mission. For coins, amount is negative when spent and positive when received.
getSetting
Returns a copy of a settings section as it is now, after the changes made from the admin panel.
---@param id string config.tablet | config.vip | config.daily | config.pass | config.cases | config.news | config.live | config.crosshair | config.jobs | data.shop | data.daily | data.pass | data.cases | data.missions | data.jobsOnline | data.jobsCity
---@return table?
local vip = exports.cuxial_tablet:getSetting('config.vip')
print(vip.codes.prefix)Client exports
Open, Close, Toggle, IsOpen
Control the tablet window. Open accepts a page id; without it, the tablet opens on its usual page. The tablet still refuses to open when the player is in a state that tablet.canOpen forbids.
---@param page? 'player'|'news'|'jobsOnline'|'jobsCity'|'crosshair'|'vip'
exports.cuxial_tablet:Open('news')
exports.cuxial_tablet:Close()
exports.cuxial_tablet:Toggle()
---@return boolean
local open = exports.cuxial_tablet:IsOpen()SetPage
Changes the page while the tablet is open. Returns false when the page does not exist or is turned off in tablet.pages.
---@param page string
---@return boolean
exports.cuxial_tablet:SetPage('vip')IsCrosshairActive
Tells whether the player's custom crosshair is drawn at the moment.
---@return boolean
local active = exports.cuxial_tablet:IsCrosshairActive()State bags
| Bag | Where | Value |
|---|---|---|
cuxialTablet:open | Player | true while that player has the tablet open. |
cuxialTablet:live | Player | The id of the stream while that player is broadcasting. |
cuxialTabletLives | Global | A counter that grows each time a stream starts or ends. |
cuxialTabletCatalogRev | Global | A counter that grows each time the shop, the daily reward, the pass or the cases change. |
-- server
local open = Player(src).state['cuxialTablet:open']
-- client
AddStateBagChangeHandler('cuxialTablet:live', nil, function(bagName, _, value)
-- value is the stream id, or nil when it ends
end)Events
cuxial_tablet:settingsApplied
Server and client, local to the resource's side. Fired after a settings section changes, with the section id. Listen to it from your own resources with AddEventHandler to react to live edits.
AddEventHandler('cuxial_tablet:settingsApplied', function(id)
if id == 'data.shop' then
-- the shop catalogue changed
end
end)Events it listens to
| Event | Side | Effect |
|---|---|---|
cuxial_jobs:server:JobCompleted | Server | Grants pass XP and advances the job missions, when cuxial_jobs is running |
Hooks
The profile data (vehicles, properties, worked hours, extra stats), the pass XP for jobs and the item images come from the adapters in hooks/. They are plain Lua files you can edit to connect your own resources. See Hooks.
Internal events
Every other event and callback starting with cuxial_tablet: is internal. They check the caller on the server and may change without notice. Do not trigger them from your own resources.
