Server exports

Crypto

Server exports that give, take and read coins and add your own coin to the Crypto market.

coin is always a coin id, such as 'bitcoin' or the id of your own coin. The client exports GetCryptoWallet and GetCoinValue are in Other (client).

#AddCrypto

Gives a character coins.

lua---@param identifier string
---@param coin string
---@param amount number decimal amounts are allowed
---@return boolean added
exports['fx-phone']:AddCrypto(identifier, coin, amount)
luaexports['fx-phone']:AddCrypto(citizenid, 'bitcoin', 0.5)
  • Returns false for an unknown coin or an invalid amount.

#RemoveCrypto

Takes coins from a character.

lua---@param identifier string
---@param coin string
---@param amount number
---@return boolean removed false when they do not hold enough
exports['fx-phone']:RemoveCrypto(identifier, coin, amount)
luaif exports['fx-phone']:RemoveCrypto(citizenid, 'bitcoin', 0.1) then deliver() end

#GetOwnedCoin

Returns how much of a coin a character holds.

lua---@param identifier string
---@param coin string
---@return number amount 0 when they hold none
exports['fx-phone']:GetOwnedCoin(identifier, coin)
lualocal amount = exports['fx-phone']:GetOwnedCoin(citizenid, 'bitcoin')

#GetCoin

Returns a coin and its current price.

lua---@param id string
---@return { id: string, symbol: string, name: string, icon: string|nil, price: number, change24h: number, canBuy: boolean, canSell: boolean, canTransfer: boolean, history: table }|nil coin
exports['fx-phone']:GetCoin(id)
lualocal coin = exports['fx-phone']:GetCoin('bitcoin')

#AddCustomCoin

Adds your own coin to the Crypto market, or updates it.

lua---@class CustomCoin
---@field id string
---@field symbol string
---@field name string
---@field price number
---@field icon? string
---@field change24h? number
---@field canBuy? boolean
---@field canSell? boolean
---@field canTransfer? boolean

---@param def CustomCoin
---@return boolean ok
exports['fx-phone']:AddCustomCoin(def)
luaexports['fx-phone']:AddCustomCoin({ id = 'candycoin', symbol = 'CNDY', name = 'CandyCoin', price = 12.5 })
  • Call it again with the same id to change the coin. That is how a script moves the price of its own coin; the new price is pushed to every phone.