FiveM · Tebex Integration

TWTEBEX

Multi-framework Tebex reward redemption for FiveM. Handles webhooks, subscription tiers, one-off packages, vehicle rewards, custom inventory bridges, and a fully independent permission system.

ESXQBCoreQBox ox_inventoryqs-inventory jg-advancedgaragescd_garageop_garageoxmysql
Tiers
Recurring subscriptions with first-purchase, renewal, and per-payment rewards.
Packages
One-off purchases granting items, money, vehicles, or custom rewards.
Revoke
Cancellation/refund hooks call handlers and fire events automatically.
15+ Locales
All player notifications translated, with sub-locale fallback.
Requirements

Everything you need before installing.

required
oxmysql
Must start before this resource.
required
ESX / QBCore / QBox
One framework. Auto-detected or set manually.
optional
ox_inventory
SetMaxWeight + item images.
optional
qs-inventory
Item and weapon grants.
optional
jg-advancedgarages
Direct DB insert for vehicle rewards.
optional
cd_garage
Alternative garage bridge.
optional
op_garage
Uses framework tables + vehicleGarage index.
Installation

Four steps from download to live store.

1
Import the database

Run [INSTALL]/database.sql. Creates tw_subscriptions, tw_transaction_log, tw_milestones_claimed, tw_physical_claims, tw_permissions.

2
Add to server.cfg
set sv_tebexSecret "YOUR_SECRET_HERE"
ensure oxmysql
ensure es_extended     # or qb-core / qbx_core
ensure cfx_tw-tebexstore
3
Configure Tebex webhooks
# On Purchase — set as "Commands → Run on Purchase"
purchase_package_tebex {"transid":"{transaction}","packageid":{packageId}}
# On Refund / Chargeback
revoke_package_tebex {"transid":"{transaction}","packageid":{packageId},"reason":"refunded"}
4
Configure and start

Edit shared/config.lua. Set your Package IDs, locale, garage system, inventory system. Start and test with /loja in-game.

Config Options

All settings are in shared/config.lua.

KeyDefaultDescription
Config.Framework"auto"Auto-detects ESX/QB/QBX. Force: "ESX", "QB", "QBX".
Config.Locale"pt"Player notification language code.
Config.StoreCommand"loja"Command to open the store UI.
Config.SubscriptionDays30Days one payment covers.
Config.ExpiryCheckInterval5Minutes between expiry sweeps.
Config.CarRewardGarage"legion"Garage where vehicle rewards land. For "op" this must be a number (the garage Index), e.g. 1.
Config.GarageSystem"auto"Force: "jg", "cd", "op", "default".
Config.InventorySystem"auto"Force: "ox", "qs", "native", "custom".
Config.DiscordLogstrueEnable Discord webhook logging.
Config.UseOxInventoryImages"auto"Use ox item images in UI. Override per-item with image = "…".
Config.SpaceInLicensePlatefalsetrue → "ABC 123", false → "ABC123".
Reward Types

Each reward entry has a type. Built-in types are handled automatically; anything else routes to Config.RewardHandlers or the fallback event.

item
Inventory Item
name = item name, amount = qty.
weapon
Weapon + Ammo
name = hash string, amount = ammo count.
account
Money
name = "bank"/"cash", amount = value.
car
Vehicle
model = spawn name. Plate auto-generated. Goes straight to garage DB.
physical
Physical Reward
Logged for staff to fulfil. Milestones only.
custom
Anything else
Routes to RewardHandlers or fires tw_tebexstore:customReward.
{ type="item",    name="lockpick",      amount=5,     label="5x Lockpick" }
{ type="weapon",  name="WEAPON_PISTOL",  amount=120,  label="Pistol + Ammo" }
{ type="account", name="bank",           amount=50000, label="$50,000 Bank" }
{ type="car",     model="sultanrs",      label="Sultan RS" }
{ type="physical", label="TW T-Shirt",   image="img/tshirt.png" }
Custom Handlers

Map any custom reward type to direct export calls. grant fires on purchase, revoke on cancellation or refund.

ℹWhen a handler is defined for a type, tw_tebexstore:customReward is NOT fired for that type — the handler IS the implementation.
Config.RewardHandlers = {
    skillpoints = {
        grant  = function(src, amount)
            exports['your_skilltree']:AddPoints(src, amount)
        end,
        revoke = function(src, amount)
            exports['your_skilltree']:RemovePoints(src, amount)
        end,
    },
    invweight = {
        grant  = function(src, amount)
            local cur = exports.ox_inventory:GetMaxWeight(src)
            exports.ox_inventory:SetMaxWeight(src, cur + amount * 1000)
        end,
        revoke = function(src, amount)
            local cur = exports.ox_inventory:GetMaxWeight(src)
            exports.ox_inventory:SetMaxWeight(src, cur - amount * 1000)
        end,
    },
    storecredit = {
        grant = function(src, amount)
            exports['your_standvip']:AddCredit(src, amount)
        end,
        -- no revoke: credits are non-refundable
    },
}
⚠Built-in types (item, weapon, account, car) are never auto-revoked — items may already be consumed or sold.
Tiers & Packages

Tiers are recurring subscriptions. Packages are one-off purchases.

Subscription Tier
{
  id          = "benfeitor",
  PackageId   = 7455661,
  PackageName = "Passe Benfeitor",
  Label       = "Passe Benfeitor",
  Group       = "vip_benfeitor",
  MaxWeight   = 100000,
  Privileges  = { "100 kg inventory", "Queue priority" },

  FirstPurchaseRewards = { --[[ once, on first sub ]] },
  RenewalRewards       = { --[[ every renewal ]] },
  Items                = { --[[ every payment incl. first ]] },
}
One-off Package
{
  PackageId   = 7455682,
  PackageName = "$100,000 Bank",
  Items = {
    { type="account", name="bank", amount=100000, label="$100,000 Bank" },
  },
}
Milestones — loyalty rewards after N months
Config.Milestones = {
  benfeitor = {
    [3] = { { type="item",     name="lockpick", amount=10 } },
    [6] = { { type="physical", label="TW T-Shirt" } },
  },
}
Locales / i18n

Set Config.Locale in shared/config.lua. Sub-locales fall back automatically: pt-br → pt → en.

Config.Locale = "pt"
en English pt Portuguese (PT) pt-br Portuguese (BR) es Spanish de German fr French pl Polish ru Russian tr Turkish nl Dutch sv Swedish zh Chinese ja Japanese it Italian ro Romanian

To add a new language, create locales/xx.lua with all keys from locales/en.lua. All 18 keys must be present or they fall back to English.

Groups & Permissions

Independent DB-backed system — no ESX/QB dependency. Cache populated on join, cleared on drop.

exports.tw_tebexstore:SetGroup(source, group)
Grant a group. Writes DB, updates cache, fires tw_tebexstore:groupSet.
exports.tw_tebexstore:RevokeGroup(source, group)
Remove a group. Deletes from DB and cache, fires tw_tebexstore:groupRevoked.
exports.tw_tebexstore:HasGroup(source, group) → boolean
Cache hit — no DB call. Ideal for ACL checks.
exports.tw_tebexstore:GetPlayerGroups(source) → string[]
Returns all groups the player currently holds.
DB TableColumns
tw_permissionsidentifier, group, granted_at
Events Reference

Server-side events fired by tw-tebexstore. Listen in any resource.

tw_tebexstore:customReward
(src, type, amount, label)
Fired for custom types with no handler in Config.RewardHandlers.
tw_tebexstore:revokeSubscription
(src, identifier, tierId, reason)
Tier cancelled or refunded. src = -1 if player is offline.
tw_tebexstore:revokePackage
(src, identifier, packageName, reason)
One-off package refunded/charged back.
tw_tebexstore:revokeReward
(src, type, amount, label, identifier)
Every individual reward during any revoke. Use for audit logs.
tw_tebexstore:groupSet
(src, identifier, group)
Fired after a group is granted.
tw_tebexstore:groupRevoked
(src, identifier, group)
Fired after a group is removed.
AddEventHandler('tw_tebexstore:revokeSubscription',
function(src, identifier, tierId, reason)
    if tierId == 'prestigio' then
        exports['your_whitelist']:Remove(identifier)
    end
end)
Garage Bridge

Vehicles are inserted directly into the garage database — no client-side spawn needed. The bridge in shared/garage.lua auto-detects the system.

jg
jg-advancedgarages
Inserts into jg_garages_vehicles. Recommended for modern setups.
cd
cd_garage
Inserts into cd_garage_vehicles.
op
op_garage
No own table — uses framework tables with the vehicleGarage index. QB: vehicle=model, hash, mods=props. ESX: vehicle=props.
default
Framework default
ESX → owned_vehicles. QB → player_vehicles.
Config.GarageSystem    = "auto"     -- auto | jg | cd | op | default
Config.CarRewardGarage = "legion"   -- garage ID in your system (op → a NUMBER, e.g. 1)
-- Reward entry:
{ type="car", model="sultanrs", label="Sultan RS" }
⚠op_garage: run the op_garage SQL first (it ALTERs player_vehicles), and set Config.CarRewardGarage to a numeric garage Index that exists in opgarages_garages2 / opgarages_ownedgarages. A non-numeric value falls back to 1.
✓The plate is auto-generated using Config.LicensePlateLetters / Config.LicensePlateNumbers and checked for uniqueness against the DB.