🎁Lootboxes

Step by step installation guide for ESX and QB, common issues & solutions, troubleshooting guide, code snippets, changelog.

1 - Installation

1ΒΊ Import script.sql in your DB. This will add the table where the lootboxes will be registered when using or buying them.

2ΒΊ Add xex_lootbox folder to your resources folder and start it.

2 - Configuration

All the configuration can be done with the config.lua file and by manipulating the images in the images folder. The images of both boxes and items must go in the /ui/img folder.

Make sure to select your framework in the configuration file.

2.1 - Crates

All crates need the metadata filled in. You can create as many as you want, they are added in order from left to right.

  • name: internal name for lootbox, must be unique

  • label: name to be displayed to the user

  • img: image name with extension included

  • payFrom: account from which the box price will be withdrawn (bank, cash, money, black_money, vipcoin, etc)

  • price: item price on choosen accoun unit

2.2 - Items

Items must be added to the database or to our framework/inventory system in order for them to be delivered correctly.

There are 4 types of items, each one has its associated metadata: Weapons / Money / Items / Vehicles.

Take a look at this setup to see the required fields:

{ type = 'item', tier = 1, label = 'Bread', img = 'bread.png', amount = 10, item = 'bread' },
{ type = 'money', tier = 3, label = 'Black Money', img = 'black_money.png', amount = 60000, account = 'black_money'},
{ type = 'weapon', tier = 4, label = 'Pistol', img = 'weapon_pistol.png', amount = 1, item = 'weapon_pistol' },
{ type = 'vehicle', tier = 5, label = 'Adder', img = 'car.png', amount = 1, vehicle = 'adder' },

Ability to use crates as items.

To use the crates as an item, you must also add the item with the name of the box to your inventory. We attach the basic script examples for ESX with legacy inventory:

INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`, `price`) VALUES ('case_normal', 'Normal Lootbox', '3', '0', '1', '1200');

And for ox_inventory config file:

['case_normal'] = {
    label = 'Normal Lootbox',
    weight = 100,
}

2.3 - Audio

Disable audio removing script.js line 20

e.play();

2.4 - Translations

Translations are unified in the translation file, although there are some strings that are found in other files indicated below:

index.html - Line 25

script.js - Line 70 / 71 / 127 / 132 / 137 / 142

2.5 - Vehicle Rewards

QB Core

In QB-Core there is a functionality that integrates with the garage of the framework and in principle you don't have to touch anything for it to work correctly. Only if we have a personalized garage will we have to adapt the function that delivers the vehicles to that garage. Specifically in the event: xex_lootbox:RewardVehicle

ESX

Updated ESX function to be able to generate license plates. Depending on your license plate format, you may need to adapt 1 line of code, below I attach different examples:

Modify line 19 in the utils.lua file to match your license plate format:

// Original line NNLLLNNN - Where N = number and L = letter (Ex: 23HGJ345)
generatedPlate = string.upper(GetRandomNumber(2) .. GetRandomLetter(3) .. GetRandomNumber(3))

// Numbers with spaces (Ex: 23 345)
generatedPlate = string.upper(GetRandomNumber(2) .. ' ' .. GetRandomNumber(3))

// Letters with space and numbers (Ex: AB 345)
generatedPlate = string.upper(GetRandomLetter(2) .. ' ' .. GetRandomNumber(3))

Everything is based on using GetRandomLetter() and GetRandomNumber() with the length we want.

2.6 Webhooks

To setup your Discord hook, paste the url of your hook in the Config.Webhook variable and fill in the bot information (name, image, etc). You can also disable it.

Last updated