πŸ’Š Sell Drugs

Access a comprehensive guide that includes a detailed installation process, examples of code, previews of configurations.

INSTALLATION GUIDE

Step 0 - First Steps

Download is_selldrugs from KeyMaster and install is_bridge & is_lib.

Step 1 - Configure Resource

You must read and configure the config.lua file in is_selldrugs to meet your needs.

Step 2 - Adding Items

For the script to function correctly, it's essential to add specific items to your game's database. This section guides you through adding these items, particularly focusing on the phone item and new drugs.

- Adding a Phone Item

To use the Trap Phone and receive wholesale orders, you first need to add the phone to your engine (QBCore/ESX). The item name for the Trap Phone should match the one specified in config.lua (default trap_phone). You can download the image for the Trap Phone that we use from here.

Adding a Trap Phone to ESX Framework

  1. Access the Database: Log in to your server's database management tool (like phpMyAdmin).

  2. Navigate to the items Table: In your database, find the items table. This is where all the items for the game are defined.

  3. Insert New Item: Add a new entry for the trap_phone. You can do this manually using the tool's interface, or you can run an SQL command.

  4. SQL Command for Adding Trap Phone: To quickly add the item, execute the following SQL command:

    INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
    ('trap_phone', 'Trap Phone', 1, 0, 1);
    • name: 'trap_phone' (This is the identifier used in your script)

    • label: 'Trap Phone' (The display name for the item)

    • weight: 1 (The weight of the item)

    • rare: 0 (Indicates the rarity, 0 for common)

    • can_remove: 1 (Whether the item can be removed from inventory)

Adding a Trap Phone to QB-Core Framework

  1. Edit the QB-Core Shared File:

    • Navigate to the qb-core folder.

    • Open the shared/items.lua file.

    • Add a line for the new item in the items list. For example:

      ['trap_phone'] = {['name'] = 'trap_phone', ['label'] = 'Trap Phone', ['weight'] = 500, ['type'] = 'item', ['image'] = 'trapPhone.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Maybe you will find more serious clients to talk to here.'},
    • This line defines the item's properties like name, label, weight, and image file.

  2. Add Image to QB-Inventory:

    • Go to the qb-inventory folder.

    • Place the image for the item in the appropriate directory (usually in html/img).

    • Ensure the image file name matches the one specified in the shared file (trapPhone.png).

- Adding a Drugs Item

In the config.lua file, you need to configure the list of items that players can sell. You need to provide data such as the item name, wholesale price, and retail price. When adding a new drug, you also need to add its image, for example, from your inventory system. To do this, you need to obtain the item image (.png), then name it the same as the drug name, and move it to is_selldrugs/html/img/inventory.

Step 3 - SQL Database

For the script to work correctly, it needs integration with the database. You can add it using the following SQL command or import the SQL file provided with the script.

CREATE TABLE `selldrugs_players` (
  `player` varchar(255) DEFAULT NULL,
  `respect` int(11) NOT NULL DEFAULT 0,
  `sale_skill` int(11) NOT NULL DEFAULT 0,
  `mole` varchar(1000) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
CREATE TABLE `selldrugs_phone` (
  `player` varchar(255) NOT NULL,
  `settings` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

Step 4 - Install Dependencies

To use the script, the following resources are required:

Using a Trigger instead of a Command

In config.lua, set the value in the cfg.commands.status table to nil to disable the command. Once you've done that, use a Trigger to activate/deactivate retail sales.

TriggerServerEvent("is_selldrugs:changeRetailStatus")

Adding to Radial Menu

The above triggers may not work because some scripts, such as qb-radialmenu, send information about a table in the argument instead of the arguments or player ID we send. This can be solved by adding the following code to config.lua. We use it with the trigger type client and paste the trigger name, which is is_selldrugs:radialMenu.

RegisterNetEvent("is_selldrugs:radialMenu", function()
    TriggerServerEvent("is_selldrugs:changeRetailStatus")
end)

Last updated