currencies/meta/sh_character¶
Source: gamemode/modules/currencies/meta/sh_character.lua
Get the amount of a specific currency this character has.
Documented functions: 10
Functions¶
character:AddCurrency(amount, uniqueID, bNoNetworking, recipients)character:AddMoney(amount, uniqueID, bNoNetworking, recipients)character:GetCurrency(uniqueID)character:GetMoney(uniqueID)character:HasCurrency(amount, uniqueID)character:HasMoney(amount, uniqueID)character:SetCurrency(amount, uniqueID, bNoNetworking, recipients)character:SetMoney(amount, uniqueID, bNoNetworking, recipients)character:TakeCurrency(amount, uniqueID)character:TakeMoney(amount, uniqueID)
character:AddCurrency(amount, uniqueID, bNoNetworking, recipients)¶
Add an amount of currency to this character. Clamps the result to be non-negative.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to add (can be negative to subtract) |
uniqueID |
string |
The unique identifier of the currency (defaults to "dollars") |
bNoNetworking |
bool |
Optional flag to disable networking (server only) |
recipients |
table |
Optional specific recipients for networking (server only) |
Returns
number: The new total amount of currency
Usage
character:AddMoney(amount, uniqueID, bNoNetworking, recipients)¶
Add dollars (alias for AddCurrency with "dollars").
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to add |
bNoNetworking |
bool |
Optional flag to disable networking (server only) |
recipients |
table |
Optional specific recipients for networking (server only) |
Returns
number: The new total amount of dollars
Usage
character:GetCurrency(uniqueID)¶
Get the amount of a specific currency this character has.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
uniqueID |
string\|nil |
The unique identifier of the currency (defaults to "dollars") |
Returns
number: The amount of currency, or 0 if invalid currency or character
Usage
character:GetMoney(uniqueID)¶
Convenience aliases for the default "dollars" currency These methods use "dollars" as the default currency ID
Get dollars amount (alias for GetCurrency with "dollars").
Realm: shared
Returns
number: The amount of dollars
Usage
character:HasCurrency(amount, uniqueID)¶
Check if this character has at least the specified amount of currency.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to check |
uniqueID |
string |
The unique identifier of the currency (defaults to "dollars") |
Returns
bool: True if the character has at least this amount, false otherwise
Usage
character:HasMoney(amount, uniqueID)¶
Check if character has dollars (alias for HasCurrency with "dollars").
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to check |
Returns
bool: True if the character has at least this amount
Usage
character:SetCurrency(amount, uniqueID, bNoNetworking, recipients)¶
Set the amount of a specific currency for this character. Clamps the value to be non-negative. Use AddCurrency or TakeCurrency for modifications.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to set |
uniqueID |
string |
The unique identifier of the currency (defaults to "dollars") |
bNoNetworking |
bool |
Optional flag to disable networking (server only) |
recipients |
table |
Optional specific recipients for networking (server only) |
Usage
character:SetMoney(amount, uniqueID, bNoNetworking, recipients)¶
Set dollars amount (alias for SetCurrency with "dollars").
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to set |
bNoNetworking |
bool |
Optional flag to disable networking (server only) |
recipients |
table |
Optional specific recipients for networking (server only) |
Usage
character:TakeCurrency(amount, uniqueID)¶
Remove an amount of currency from this character. Will not go below zero. Returns false if the character doesn't have enough.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to remove (must be positive) |
uniqueID |
string |
The unique identifier of the currency (defaults to "dollars") |
Returns
bool: True if the full amount was taken, false if insufficient funds
Usage
if (character:TakeCurrency(100, "dollars")) then
print("Purchased item")
else
print("Not enough dollars")
end
character:TakeMoney(amount, uniqueID)¶
Remove dollars (alias for TakeCurrency with "dollars").
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
amount |
number |
The amount to remove |
Returns
bool: True if successful, false if insufficient funds
Usage