Skip to main content

💷 Currencies

Currencies are the different types of currency that you can use in Pulsar Store. You can have as many currencies as you want, but you need at least one. The default currency is 'Pulsar Credits'.#

warning

Removing the default currency is NOT recommended, as it is used for a lot of things.
The addon may not function correctly if you remove the default currency.
No support will be given if you remove the default currency.

Creating a currency

To create a currency, create a new file in addons/pulsar-store/lua/pulsar-store/config/currencies/ with the name sh_<mycurrency>.lua. Creating a currency needs 4 basic functions and 2 strings to work properly.

Example

PulsarStore = PulsarStore or {}
PulsarStore.Currencies = PulsarStore.Currencies or {}

PulsarStore.Currencies.Create("DarkRP")
:Get(function(ply, steamId, onSuccess, onError)
local money = ply:getDarkRPVar("money")
onSuccess(money)
end)
:Add(function(ply, steamId, amount, onSuccess, onError)
ply:addMoney(amount)
onSuccess()
end)
:CanAfford(function(ply, steamId, amount, onSuccess, onError)
local canAfford = ply:canAfford(amount)
onSuccess(canAfford) -- onSuccess as the function is still ran. onError is only ran if the function fails.
end)
:String("$", "left") -- The second argument is whether it should be on the left or right side of the amount
:Description("DarkRP Money")
:Done()

Currency Functions

Currency PulsarLib.Currencies.Create( name )

Creates a new currency

Currency PulsarLib.Currencies.Get( function(ply, steamId, amount, onSuccess, onError) )

The function that gets how much of said currency the player has.

Currency PulsarLib.Currencies.Add( function(ply, steamId, amount, onSuccess, onError) )

The function that adds the currency to the player.

Currency PulsarLib.Currencies.CanAfford( function(ply, steamId, amount, onSuccess, onError) )

The function that checks if the player can afford the amount of currency.

Currency PulsarLib.Currencies.String( symbol, left/right )

A string that is used for the currency. The first argument is the string, the second is whether it should be on the left or right side of the amount.

Currency PulsarLib.Currencies.Description( string )

A basic description of the currency.

Currency:Done()

Registers the currency