Skip to main content

Available Exports

R_Store provides three server-side exports for managing player credits:

Add Credits

Give credits to a player

Remove Credits

Take credits from a player

Get Balance

Check player’s credit balance

Add Credits to Player

Give credits to a player by their server ID.

Syntax

exports['r_store']:addCoinsToPlayer(source, amount)

Parameters

ParameterTypeDescription
sourcenumberPlayer’s server ID
amountnumberAmount of credits to add

Example Usage

-- Give 100 credits to player ID 1
exports['r_store']:addCoinsToPlayer(1, 100)

Remove Credits from Player

Remove credits from a player by their server ID.

Syntax

exports['r_store']:removeCoinsFromPlayer(source, amount)

Parameters

ParameterTypeDescription
sourcenumberPlayer’s server ID
amountnumberAmount of credits to remove

Example Usage

-- Remove 50 credits from player ID 1
exports['r_store']:removeCoinsFromPlayer(1, 50)

Get Player Coin Balance

Retrieve a player’s current credit balance.

Syntax

exports['r_store']:getPlayerCoinBalance(source)

Parameters

ParameterTypeDescription
sourcenumberPlayer’s server ID

Returns

TypeDescription
numberPlayer’s current credit balance

Example Usage

-- Check balance of player ID 1
local balance = exports['r_store']:getPlayerCoinBalance(1)
print("Player 1 has " .. balance .. " credits")

Integration with R_Casino

If using both R_Store and R_Casino, you can share the credit system:

In R_Casino config.lua

R.UseRStoreCoins = true
R.RStoreResourceName = "r_store"
This allows players to use their R_Store credits in the casino!

Integration with R_FFA

R_FFA can use R_Store credits for wager matches:

In R_FFA config.lua

R.UseRStoreCredits = true
R.RStoreResourceName = "r_store"

Best Practices

Before removing credits, always check if the player has enough:
local balance = exports['r_store']:getPlayerCoinBalance(source)
if balance >= cost then
    exports['r_store']:removeCoinsFromPlayer(source, cost)
end
Always validate amounts to prevent negative values or exploits:
local amount = tonumber(args[1])
if not amount or amount <= 0 then
    -- Invalid input
    return
end
Implement proper error handling:
local success, result = pcall(function()
    return exports['r_store']:getPlayerCoinBalance(source)
end)

if not success then
    print('Error getting balance: ' .. result)
end

Troubleshooting

Common Export Issues

Having problems with exports? Check our troubleshooting guide