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)
Real Wild County example — stagecoach mission payout
wc_stagecoach pays the driver once a delivery run completes, after re-checking the mission is still marked active server-side (never trusting a client "I'm done" event alone).
wc_stagecoach/server/main.lua
RegisterNetEvent('wc_stagecoach:missionComplete', function()
local src = source
if not ActiveRuns[src] then return end -- server never started a run for this player
local reward = ActiveRuns[src].reward or 50
ActiveRuns[src] = nil
wc:AddMoney(src, reward, 0)
wc:Notify(src, { title = ("Stagecoach Complete: +$%d"):format(reward), variant = 'avanced' })
end)
Common mistakes
- Calling
AddMoney/RemoveMoneyfrom the client — both are server-only. Trigger a server event and mutate money there. - Trusting a client-sent
amountfor a purchase or reward. Always compute the price/reward on the server from your own config or database. - Passing a negative number to
AddMoneyto "remove" money — useRemoveMoneyinstead so intent stays obvious in logs and call sites. - Calling
GetGoldon an RSG server and expecting a real balance without settingWCLibConfig.Money.rsg.goldfirst — it silently returns0. - Assuming
GetBankMoneyworks on VORP — VORP has no bank currency; it always warns and returnsnilthere.
Security notes
Security. Never let the client tell the server how much a reward, refund, or purchase costs. Compute prices from server-side config/database, validate the player can afford it with
GetMoney before calling RemoveMoney, and only call AddMoney after the corresponding action (item removed, mission verified, etc.) has actually happened server-side.
Troubleshooting
- If
AddMoney/RemoveMoneyreturnfalse: the player's character couldn't be resolved — check thatsourceis a currently-connected player and that the framework finished loading them. - If money changes but the HUD doesn't update: that's a framework/HUD-resource issue, not wc_libs — VORP/RSG update their own HUDs off the underlying
addCurrency/AddMoneycall, which wc_libs already triggers. - If
GetMoneyreturnsnil: the character isn't loaded yet, or no framework was detected — check server console on resource start.