Economy integration
Connect roulette chips to a framework account or inventory item by adapting the server exports in sv_config.lua.
Choose how chips are stored
Numeric balance
The chip balance export must return a number, regardless of the account or inventory system behind it.
Framework access
Initialize your framework object in sv_config.lua before using framework-specific player functions.
Adapt the examples
The examples use ESX, but the same export contract can be connected to another framework.
Inventory responsibility
When chips are items, register the item and provide a separate way for players to obtain it.
Account balance
Use this approach when bets and payouts should use an existing cash or bank account.
Connect a framework account
This ESX example reads from and writes to the player's bank account. Change the account name or framework calls to match your server.
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
exports('getPlayerChips', function(source)
local Amount = 0
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
local Bank = xPlayer.getAccount('bank')
if Bank then
Amount = Bank.money
end
end
return Amount
end)
exports('givePlayerChips', function(source, amount)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
xPlayer.addAccountMoney('bank', amount)
end
end)
exports('removePlayerChips', function(source, amount)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
xPlayer.removeAccountMoney('bank', amount)
end
end)
exports('getPlayerName', function(source)
local Name = GetPlayerName(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
Name = xPlayer.getName()
end
return Name
end)
Inventory item
Use this approach when each chip should exist as an inventory item instead of an account balance.
Connect an inventory item
This ESX example uses an item named chips. Register the item and provide a shop or another gameplay method for obtaining it.
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
exports('getPlayerChips', function(source)
local Amount = 0
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
local Item = xPlayer.getInventoryItem('chips')
if Item then
Amount = Item.count
end
end
return Amount
end)
exports('givePlayerChips', function(source, amount)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
xPlayer.addInventoryItem('chips', amount)
end
end)
exports('removePlayerChips', function(source, amount)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
xPlayer.removeInventoryItem('chips', amount)
end
end)
exports('getPlayerName', function(source)
local Name = GetPlayerName(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
Name = xPlayer.getName()
end
return Name
end)