PivityGmodStore

Store Currencies

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'.

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

PulsarLib.Currencies Methods

PulsarLib.Currencies.Create

Description:

Creates a new currency.

Arguments:

  1. name

Returns:

  1. Currency



PulsarLib.Currencies.Get

Description:

Gets how much of the specified currency the player has.

Arguments:

  1. function(ply, steamId, amount, onSuccess, onError)

Returns:

  1. Currency



PulsarLib.Currencies.Add

Description:

Adds currency to the player.

Arguments:

  1. function(ply, steamId, amount, onSuccess, onError)

Returns:

  1. Currency



PulsarLib.Currencies.CanAfford

Description:

Checks whether the player can afford the specified amount of currency.

Arguments:

  1. function(ply, steamId, amount, onSuccess, onError)

Returns:

  1. Currency



PulsarLib.Currencies.String

Description:

Defines the display string for the currency.

The first argument is the symbol, the second determines whether it appears on the left or right of the amount.

Arguments:

  1. symbol
  2. left/right

Returns:

  1. Currency



PulsarLib.Currencies.Description

Description:

Sets a basic description of the currency.

Arguments:

  1. string

Returns:

  1. Currency



Currency:Done

Description:

Registers the currency.

Arguments:

  1. None

Returns:

  1. None