Guide

Setup Instructions

  1. Download the resource

  2. Extract the sanba-mysterybox folder to your server's resources directory

  3. Add ensure sanba-mysterybox to your server.cfg file

  4. Configure the settings in shared/config.lua

  5. Set up your Discord webhook for logging

  6. Restart your server

Configuration

Main Configuration

The main configuration file is located at shared/config.lua. Here you can adjust various settings:

Config = {}

-- Animation settings
Config.Duration = 1000 -- Duration of the spinning animation in milliseconds

-- Framework auto-detection (will be set automatically)
Config.Framework = nil -- 'qb', 'qbx', 'esx', or nil if not detected

-- Mystery box items
Config.Boxes = {
    'mystery_box',
    'mystery_box_2',
}

-- Logging configuration
Config.Logs = {
    Enabled = true,
    WebhookURL = "YOUR_DISCORD_WEBHOOK_URL_HERE",
    LogColors = {
        Open = 3447003,     -- Blue
        Reward = 5763719,   -- Green
        Error = 15548997    -- Red
    },
}

Configuring Box Items

You can configure the items that players can win from mystery boxes by editing the Config.BoxItems section:

Item Properties

  • name: Display name of the item

  • chance: Probability weight for this item (higher numbers = higher chance)

  • imageurl: URL to the item's image (can use inventory image paths)

  • amount: Quantity of the item to give to the player

Framework Integration

The system automatically detects and adapts to the framework your server is using:

QBCore/QBX

For QBCore and QBX servers, the script will automatically register usable items and handle inventory operations through the core functions.

ESX

For ESX servers, the script will use the ESX item system and money handling functions.

Discord Logging

The script includes a Discord webhook integration to log all box openings and rewards.

Setting Up Logging

  1. Create a webhook in your Discord server (Server Settings β†’ Integrations β†’ Webhooks)

  2. Copy the webhook URL

  3. Paste the URL in the Config.Logs.WebhookURL field in config.lua

Log Types

  • Box Open: Triggered when a player opens a mystery box

  • Reward Given: Triggered when a player receives a reward

  • Error: Triggered when there's an issue with processing rewards

Adding New Mystery Boxes

To add new mystery box types:

  1. Add the item to your server's items database according to your framework

  2. Add the item name to Config.Boxes in config.lua

  3. Configure the item in your inventory system

  4. Restart the resource

Example for adding a new box type:

Special Items

Money Rewards

The system has special handling for money rewards. If an item has the key "money", it will add cash to the player instead of an inventory item.

Last updated