Documentation
R_Store

r_store Exports

Server exports to add, remove and read r_store credits from your other resources, with syntax, parameters and example code for each one.

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. The amount comes first. Pass the player's server ID, or a stored identifier (license / citizenid) to grant credits to an offline player.

Syntax

exports['r_store']:addCoinsToPlayer(amount, playerId, identifier)

Parameters

ParameterTypeDescription
amountnumberAmount of credits to add
playerIdnumberPlayer's server ID (use this for online players)
identifierstringOptional. Stored account identifier: grant by identifier (offline)

Example Usage

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

-- Grant 100 credits to an offline player by their stored identifier
exports['r_store']:addCoinsToPlayer(100, nil, "char1:abcdef0123456789")

The player doesn't need to have opened the store before. An account row is created on the first grant, so Tebex packages and join rewards land even for brand-new players. Returns true when the credits were added.

Remove Credits from Player

Remove credits from a player. The amount comes first.

Syntax

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

Parameters

ParameterTypeDescription
amountnumberAmount of credits to remove
playerIdnumberPlayer's server ID

Example Usage

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

The removal is atomic and returns true on success. If the player doesn't have enough credits, nothing is removed and it returns false. Store purchases use the same check, so a balance can never go negative.

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"

Players then spend 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.Payment = {
    cash = true,
    bank = true,
    credits = true -- r_store credits
}

R.Credits = {
    resource = 'r_store' -- your r_store resource name
}

Troubleshooting

Common Export Issues

Having problems with exports? Check our troubleshooting guide