Koja Scripts
KOJA-LIB

Money

Functions for reading and modifying a player's money on the server.

Money

Functions for reading and modifying a player's money on the server.

getMoney

Get the amount of money a player has of a given type.

local amount = KOJA.Server.getMoney(source, mtype)
ParameterTypeDescription
sourcenumberPlayer server ID
mtypestringMoney type — "cash", "bank", "black"

Returns number

addMoney

Add money to a player's account.

local ok = KOJA.Server.addMoney(source, amount, mtype, reason)
ParameterTypeDescription
sourcenumberPlayer server ID
amountnumberAmount to add
mtypestringMoney type — "cash", "bank", "black"
reasonstring?Reason (logged by some frameworks)

Returns boolean

removeMoney

Remove money from a player's account.

local ok = KOJA.Server.removeMoney(source, amount, mtype, reason)

Same parameters as addMoney.

Returns boolean

Money Types

ValueESXQBCore
"cash"money accountcash money type
"bank"bank accountbank money type
"black"black_money accountcrypto money type

Examples

-- Read balances
local cash = KOJA.Server.getMoney(source, 'cash')
local bank = KOJA.Server.getMoney(source, 'bank')
print(('Cash: $%d | Bank: $%d'):format(cash, bank))

-- Pay out a reward
KOJA.Server.addMoney(source, 500, 'cash', 'job_reward')

-- Charge for a service
local price = 250
if KOJA.Server.getMoney(source, 'bank') < price then
    KOJA.Server.SendNotify({ source = source, type = 'error', desc = 'Not enough bank balance.' })
    return
end

KOJA.Server.removeMoney(source, price, 'bank', 'shop_purchase')
KOJA.Server.addInventoryItem(source, 'burger', 1)
  • Police — Functions for checking how many police officers are online.
  • Callbacks — The callback system allows server scripts to handle requests from clients and vice versa.
  • Licenses — Check whether a player holds a specific driving or skill license.
  • Inventory — Server-side inventory functions.
  • Notifications — Send notifications to a player from the server side.
  • Player — Functions for reading player information on the server.
  • Server API — back to the section overview