πŸ’Š Sell Drugs

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

Links:

INSTALLATION GUIDE

Step 0 - First Steps

1. Download your resource from FiveM's Keymaster 2. Unzip the inside-selldrugsfolder and place this folder in your server's resource folder. 3. Add the resource to your server start config (server.cfg): ensure inside-selldrugs If you are using a framework, it must be placed anywhere below your framework resource e.g., es_extended, not above.

ensure es_extended ensure inside-selldrugs

Step 1 - Configure Resource

You MUST read all configurable options inside the[inside-selldrugs/config.lua] file and configure them to suit your server's needs.

# cfg.Time

cfg.Time               = {				-- Actually configured for "GMT +1"
    ["Zone"]           = "plus", 			-- "plus" or "minus"
    ["Zone_Count"]     = 1,
    ["Format"]         = 24 				-- 24 or 12 (PM/AM)
}

Zone specifies whether your time zone is ahead (plus) or behind (minus) GMT.

Zone_Count sets how many hours you are from GMT. For example, for GMT+1, set Zone to "plus" and Zone_Count to 1.

Format decides if time is in 24-hour (set to 24) or 12-hour AM/PM format (set to 12).

# cfg.Drug_List

cfg.Drug_List 		   = {
	["cokebaggy"] = {average_price = 300},
	["crack_baggy"] = {average_price = 150},
	["meth"] = {average_price = 75},
	["xtcbaggy"] = {average_price = 50},
	["weed_amnesia"] = {average_price = 40},
	["weed_og-kush"] = {average_price = 35}
}

cfg.Drug_List defines default prices for drugs like "cokebaggy", "meth", etc. Each has an average_price for retail. Wholesale prices are typically half this amount.

Ensure these items are added to your item database to make them accessible in-game.

When adding new items, place their images in inside-selldrugs/html/img/inventory/, naming the file as item_name.png. This ensures the correct display of the drug's image in the game.

# cfg.Phone

cfg.Phone       	   = {
	Price = 500,
	Item_Name = "trap_phone"
}

cfg.Phone sets up phone items in the game. It specifies the Price as 500 and the Item_Name as "trap_phone". Ensure "trap_phone" is already added as an item in your item database for it to spawn correctly in-game.

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

The script requires a phone item to be added to your database. This item is crucial for various script functionalities.

Download the Image Here

Adding a New Item to ESX Framework

To add a new item, such as a 'trap phone', to your ESX server, follow these steps:

  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);

    This command inserts a new item with the following properties:

    • 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)

  5. Update Script Configuration: In your config.lua, set the phone item's name to match the one you've added to the database, in this case, 'trap_phone'.

Adding a New Item to QB-Core Framework

To add a new item, such as a 'trap phone', to your QB-Core server, follow these steps:

  1. Edit the QB-Core Shared File:

    • Navigate to the qb-core folder.

    • Open the shared folder.

    • 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).

  3. Restart the Server:

    • After making these changes, restart your FiveM server.

    • This is necessary for the server to recognize and load the new item configuration.

- Adding a Drugs Item

For ESX:

  1. Database Entry: As with the 'trap_phone', add the new drug item to your ESX server's database using an SQL command. Adjust the name, label, and other properties for the drug item.

    INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('drug_name', 'Drug Label', weight, 0, 1);

For QB-Core:

  1. Shared File Update: Follow the same process as for the 'trap phone' in QB-Core. Add your drug item in the shared folder of qb-core, customizing the properties. Set useable to false for drugs, unless they have a specific use case in the game.

    ['drug_name'] = {['name'] = 'drug_name', ['label'] = 'Drug Label', ['weight'] = weight, ['type'] = 'item', ['image'] = 'drugImage.png', ['unique'] = false, ['useable'] = false, ...},
  2. Image Addition: Place the drug image in the qb-inventory directory.

Common Steps:

  • Update Script Configuration: For QB-Core, add the new drug to cfg.Drug_List.

  • Restart the Server: After making these changes in either framework, restart your server to implement the new items.

Step 3 - SQL Database

To set up your database for the game, you'll need to create two tables:selldrugs_players andselldrugs_phone. Use the following SQL commands to create these tables:

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

For the script to function properly, it requires the resources listed below.

To avoid any issues with the script's performance, ensure that you're using the Latest Version of the Framework or Previous Versions that include the same features.

QBCORE

qb-target or ox_target (ox_lib for ox_target also)

oxmysql - Currently available in the latest version of the Framework

ESX

qb-target or ox_target (ox_lib for ox_target also)

oxmysql - Currently available in the latest version of the Framework

How can I change my notifications?

To properly set up the clientNotify and serverNotify functions in your FiveM script, follow these steps:

  1. Identify Your Notification System: First, determine the notification system your server uses.

  2. Learn How to Trigger Notifications: Once you've identified the notification system, find out how to trigger these notifications. Look for documentation or examples in your existing scripts. Pay attention to the format and arguments required for triggering notifications.

  3. Modify the Notification Functions:

    • In clientNotify and serverNotify, replace QBCore:Notify or esx:showNotification with the appropriate event or function call from your notification system.

    • Ensure you fill in the arguments correctly. Each notification system has its specific requirements for message text, notification type, duration, and possibly other parameters.

  4. Test Your Notifications: After setting up, test the notifications in various scenarios to confirm they work correctly. This helps ensure that players receive the right messages at the right time.

Custom event (radial menu)

If someone doesn't want to use a command or doesn't like it, you can add event triggering to your e.g. radial menu.

Client-Side: TriggerServerEvent("SellDrugs:Status_Selling_Drugs")
Server-Side: TriggerEvent("SellDrugs:Status_Selling_Drugs", source)

Last updated