Exports
Server exports to add or remove coins and to count battle pass challenge progress from your own scripts.
All exports are server-side. Call them from your own server scripts after gg_coinshop has started. Never pass an amount that comes from the client: decide the amount in your server code.
AddCoins
Adds coins to an online player's balance.
local success, balance = exports.gg_coinshop:AddCoins(playerId, 100)
RemoveCoins
Removes coins from an online player's balance. It fails if the player does not have enough coins.
local success, balance = exports.gg_coinshop:RemoveCoins(playerId, 25)
Parameters and returns
| Name | Type | Description |
|---|---|---|
playerId | number | The online player's server ID |
amount | number | A whole number from 1 to 2147483647 |
success | boolean | true when the balance changed, false otherwise |
balance | number | The new balance, only when success is true |
Both exports use the same coin balance as the store, and the open store updates straight away. They do not create a Tebex transaction.
false means the amount is invalid, the player is not online, the player has too few coins (RemoveCoins) or the balance would pass 2147483647 (AddCoins).
-- Example: pay 50 coins when a player finishes your event
local ok, balance = exports.gg_coinshop:AddCoins(source, 50)
if ok then
print(("Player %s now has %d coins"):format(source, balance))
end
challenge
Counts progress on a battle pass daily challenge. Use it to make your own scripts give battle pass XP.
exports.gg_coinshop:challenge({
source = source,
challenge_id = "my_challenge_key",
count = 1,
})
| Field | Type | Description |
|---|---|---|
source | number | The player's server ID |
challenge_id | string | The challenge key you set in the Admin Panel |
count | number | Progress to add. Defaults to 1. |
To set it up:
- Open Admin Panel > Battle Pass > Challenges and create a challenge with a key, the required count and the XP it gives.
- Click Copy export string on the challenge. It copies the call above with your key filled in.
- Paste it into your server script where the action happens.
Several challenges can share one key, for example "Finish 5 routes" and "Finish 20 routes". One call counts towards each of them the player has that day. The call does nothing when daily challenges are turned off in Settings > Battle Pass.
