Defines the cw.currency library, a registry of named currency objects that each carry a world model and a default amount.

cw.currency:Add creates a currency and cw.currency:Get returns one, creating it if needed. A currency object can be called like a function to query its data.

Summary

Methods

Creates and stores a new currency.
Get(name)shared
Returns a currency, creating it if it does not exist yet.
GetAll()shared
Returns every stored currency.

Methods

cw.currency:Add(name, model, defaultValue)

shared gamemodes/catwork/gamemode/core/libraries/sh_currency.lua:102

Creates and stores a new currency.

The key is the name lowercased with whitespace replaced by underscores. Does nothing if a currency with that key already exists.

Parameters

  • name String Display name of the currency
  • model String optional, defaults to nil World model path
  • defaultValue Number optional, defaults to nil Default amount

Returns

  • Map The new currency object, or nil if the currency already exists

Returns a currency, creating it if it does not exist yet.

Returns an empty table while the cash_enabled config is off.

Parameters

  • name String Display name or key of the currency

Returns

  • Map The currency object

Returns every stored currency.

Returns an empty table while the cash_enabled config is off.

Returns

  • Map<Map> Currency objects keyed by currency key

Defined in