Home Scripts Docs Customers Contact
All documentation DD Gift Codes

Create a code,
hand it out.

Setup, configuration and exports for DD-Giftcodes, written alongside the code and shipped with every download.

A gift code system for FiveM. Staff create codes in a glass admin panel and pick rewards from a live list of your server's items; players redeem them in a single-field panel. Works on QBCore, Qbox and ESX, with ox_inventory and qb-inventory style inventories, all detected automatically.

Requirements

Nothing. No database, no ox_lib, no external dependencies.

If you already run ox_lib, ox_inventory or qb-inventory, they are detected and used automatically.

Installation

  1. Drop the DD-Giftcodes folder into your resources directory.
  2. Add this to server.cfg, after your framework and inventory:
    ensure DD-Giftcodes
  3. Give your staff access. Either add them to a framework group listed in Config.Admin.groups (admin, superadmin, god by default), or use an ACE:
    add_ace group.admin DD-Giftcodes.admin allow
  4. Restart the server.

The console prints what was detected:

[DigitalDEN] DD-Giftcodes v1.0.0 started
[DigitalDEN] Framework: qb  |  Inventory: ox  |  Notify: custom  |  Codes loaded: 0

That is the whole install. No SQL file is needed. Codes are stored in data/codes.json inside the resource and persist through restarts, so there is nothing to import and nothing to maintain.

Commands

CommandWhoDescription
/giftcodeEveryoneOpens the redeem panel
/giftcodesadminStaffOpens the gift code manager

Both names are set in config.lua. An optional rebindable keybind is there too, off by default:

Config.Keybind = {
    enabled = true,
    key = 'F7',
    description = 'Open Gift Codes'
}

Framework and inventory

Everything lives in config.lua, which stays editable after purchase.

Config.Framework = 'auto'   -- 'auto' | 'qbx' | 'qb' | 'esx'
Config.Inventory = 'auto'   -- 'auto' | 'ox'  | 'qb' | 'esx'
DetectedFramework sourceInventory source
qbx_coreQboxox_inventory
qb-coreQBCoreqb / ps / lj / qs-inventory
es_extendedESXox_inventory or ESX inventory

Notifications

Config.Notify = 'custom' -- 'custom' | 'ox' | 'qb' | 'esx' | 'event'

custom is the built-in DigitalDEN toast, styled to match the panels. To route notifications into your own system instead:

Config.Notify = 'event'
Config.NotifyEvent = 'myNotify:show'
-- fired client side as: TriggerEvent(name, message, type)
-- type: 'success' | 'error' | 'info'

Money accounts

The admin panel builds its money fields from this list, so add whatever accounts your framework uses:

Config.Accounts = {
    { name = 'cash', label = 'Cash' },
    { name = 'bank', label = 'Bank' }
}

Item images

Item icons in the picker come from your detected inventory. Override the folder for a custom inventory:

Config.ItemImages = {
    path = 'nui://my-inventory/html/images/',
    extension = '.png'
}

Reward presets

Presets appear as one-click chips under the create form:

Config.Presets = {
    {
        label = 'Starter Pack',
        reward = {
            accounts = { cash = 5000 },
            items = { { name = 'bread', amount = 5 } }
        }
    }
}

Anti-abuse

Config.Codes = {
    cooldown = 3,                 -- seconds between redeem attempts
    maxFailedAttempts = 8,        -- wrong guesses before a timeout
    failedAttemptsTimeout = 300   -- length of that timeout, in seconds
}

Branding and language

Config.UI sets the server name, panel title and accent colour, and the accent drives the glow, borders and buttons across the whole interface.

Config.LocaleUI holds every word shown inside the panels and Config.Locale holds every notification message, so the script can be fully translated without touching any other file.

What it does

  • Item picker. No typing item names. Staff browse every detected item as image tiles, or search by item name or display label.
  • Reward types. Any number of money accounts and any number of items per code.
  • Limits. Max uses, expiry in days, and a one-redeem-per-player toggle. Claims are tracked per character.
  • Live management. Enable, disable or delete codes, with a search box and live usage counters.
  • Code generator. One click builds a random code from a configurable charset that excludes look-alike characters (O/0, I/1).
  • Inventory space check. Rewards are never granted if the player cannot carry the items, so nothing is lost.
  • Server-side validation. Every admin action re-checks permission on the server. Nothing trusts the client.
  • Glass UI. Frosted panels with a live blur of the game behind them, in a single theme colour you control.

Exports and events

Server

Create a code from another script: a Discord bot, a vote reward, a shop.

exports['DD-Giftcodes']:CreateCode('WELCOME2025', {
    accounts = { cash = 5000 },
    items = { { name = 'bread', amount = 2 } }
}, {
    maxUses = 100,
    oncePerPlayer = true,
    expires = os.time() + 604800  -- optional unix timestamp, 0 or nil = never
})

exports['DD-Giftcodes']:DeleteCode('WELCOME2025')
exports['DD-Giftcodes']:GetCodes()               -- every code with its usage
exports['DD-Giftcodes']:GetCode('WELCOME2025')   -- one code, or nil

Client

exports['DD-Giftcodes']:OpenRedeem()
exports['DD-Giftcodes']:OpenAdmin()
exports['DD-Giftcodes']:IsAdmin()

Events

Fired on the server after every successful redeem, which is what you want for Discord logging:

AddEventHandler('DD-Giftcodes:server:onRedeem', function(source, code, reward)
    print(('%s redeemed %s'):format(GetPlayerName(source), code))
end)
Still stuck?

Open a ticket and bring your console output from resource start. The banner tells us exactly which framework, inventory and notification system were detected. Support is 11:00 to 23:00 UK, every day.

Open a ticket