Money
Reads and writes are kept separate on purpose — GetMoney never mutates, AddMoney never returns a balance. One named function per currency, no overloaded type parameter to remember.
GetMoney(source)server
Cash balance only.
| Param | Type | Returns |
|---|---|---|
| source | integer | number | nil |
example
local cash = wc:GetMoney(source)
if cash >= price then
wc:RemoveMoney(source, price)
end
GetBankMoney(source)server
Bank balance.
VORP has no native bank currency. VORP only has money / gold / rol — there's no separate bank balance in the docs this lib was built against. Calling
GetBankMoney on a VORP server prints a console warning and returns nil. On RSG it returns PlayerData.money.bank as expected.
GetGold(source)server
Gold balance.
RSG has no native gold currency. Calling
GetGold on RSG warns and returns 0, unless you've pointed WCLibConfig.Money.rsg.gold at a custom money-type key your server defines. On VORP it returns the character's actual gold balance.
wc_libs/shared/config.lua
WCLibConfig.Money.rsg.gold = 'gold' -- if your server defines this money type
AddMoney(source, amount, currencyType?)server
Adds cash by default. Pass currencyType to target a specific VORP currency index or RSG money key.
| Param | Type | Description |
|---|---|---|
| source | integer | The player's server ID. |
| amount | number | Amount to add. |
| currencyType | number | string | nil | Optional override — VORP index (0/1/2) or RSG money key. |
underneath, on —
vorp_core
character.addCurrency(0, amount) -- 0 = cash, 1 = gold, 2 = rol
rsg-core
Player.Functions.AddMoney('cash', amount)
example — reward payout
wc:AddMoney(source, 50)
wc:Notify(source, { title = "+$50" })
RemoveMoney(source, amount, currencyType?)server
Removes cash by default. Same currencyType override as AddMoney.
example — shop purchase
local cash = wc:GetMoney(source)
if cash < price then
wc:Notify(source, { variant = 'fail', title = "Not enough cash" })
return
end
wc:RemoveMoney(source, price)