Server exports

Wallet

Server exports that hand out, remove and list cards in the Wallet app.

Use these for tickets, coupons, memberships, passes and keys. The ID card, licences and the job badge come from the character and need no export. See Wallet.

The first argument of every export is a server id (number) or a character identifier (string).

#AddCard

Adds a card to a player's Wallet.

lua---@class WalletCard
---@field kind? 'ticket'|'coupon'|'membership'|'pass'|'key'|'other' default 'pass'
---@field title string 1 to 60 characters
---@field subtitle? string up to 80 characters
---@field color? string '#RRGGBB'
---@field fields? { label: string, value: string }[] up to 8 rows; label 30 characters, value 60
---@field code? string shown as a barcode, up to 120 characters
---@field transferable? boolean true: the player can hand the card to someone else. Default false
---@field issuer? string up to 60 characters; your resource name by default
---@field expiresAt? integer unix seconds

---@param who integer|string
---@param card WalletCard
---@return integer|nil id
---@return string|nil err
exports['fx-phone']:AddCard(who, card)
lualocal id = exports['fx-phone']:AddCard(source, { kind = 'ticket', title = 'Maze Bank Arena', code = 'TKT-1108-C4', transferable = true })
  • Errors: not_found (unknown player), invalid (no title, or a title over 60 characters), limit (the character already has Config.Wallet.MaxCustomCards cards).

#RemoveCard

Removes a card.

lua---@param who integer|string
---@param id integer the card id
---@return boolean removed
exports['fx-phone']:RemoveCard(who, id)
luaexports['fx-phone']:RemoveCard(source, cardId)

#GetCards

Returns the cards scripts gave a player.

lua---@param who integer|string
---@return table[] cards
exports['fx-phone']:GetCards(who)
luafor _, card in ipairs(exports['fx-phone']:GetCards(source)) do print(card.title) end