💊Documentation

All information you need foredit and use the script

Setup your framework

Config

Config.framework = "esx"

Setup your inventory system

Config

Config.inventoryType = "esx"

Config

Money type

Config.moneyType            = "money" -- Money type from your framework

After each sell you get $$, chose your

It's 'money' by default

Use ox_target

Config.useOxTarget          = true -- Use ox_target or not

This script can works with ox_target

If you don't use ox_target, you can configure IN-GAME, the keybind. By default T

RegisterKeyMapping('sellDrugs', 'Sell Drugs', 'keyboard', 't')

Cops required and Count

Config.copsCountRefreshTime = 5     -- Time in minutes to refresh cops count
Config.minCopsOnline        = 0         -- Cops required to sell drugs

Ped reject and Ped Call Cops

Config.pedReject            = 25    -- Percent chance that the ped will reject the drugs
Config.pedCallCops          = 25    -- Percent chance that the ped will call the cops

You can configure the percentage of chance that the ped will refuse your drugs and the percentage that he will call the police after the refusal

BlacklistedJobs and CallCopsJobs

Config.blacklistedJobs      = { "police", "bcso", "ambulance" } -- Job that can't sell drugs
Config.callCopsJos          = { "police", "bcso" }   -- Job who receive alert when ped call cops

BlacklistestJobs are not allowed to sell drugs

CallCopsJobs will receive alerte after peds call him

Max drugs to sell

Config.maxDrugsToSell       = 10    -- Max drugs to sell at once

Tha maxium amount of drugs you can sell at once

Drugs amount for price variation and PriceVariation

Config.drugsSellQttyForVariation = 10 --Qtty of drugs to sell for price variation
Config.drugsPriceVariation       = 0.05   -- 0.5% of variation

drugsSellQttyForVariation represents the amount of drugs that all players must sell for a price variation to occur drugsPriceVariation represents the variation in % which will be applied to the current price

Drugs

Config.Drugs = {
    weed = {            -- Item name
        price = 60,     -- Price of the item
        min = 40,       -- Min price of the item
        max = 80,        -- Max price of the item
        variation = {   -- Item variation when you sell more than Config.drugsSellQttyForVariation
            'meth'      -- Item name
        }
    },
    coke = {
        price = 80,
        min = 60,
        max = 100,
        variation = {
            'weed',
            'meth'
        }
    },
    meth = {
        price = 70,
        min = 50,
        max = 90,
        variation = {
            'cook'
        }
    }
}

Here you can add your own drugs

  • The array must be the name item name in your database (Not the label)

  • price : The default price of the item

  • min : The minimum price of the item (cannot go under after variation)

  • max : The maximum price of the item (cannot go upper after variation)

  • variation : The list of other drugs which impacted by the variation (see exemple above)

Client : Notify.lua

Notify

You can change the lib.notify by your own notification system

---@param message string
---@param type 'success' | 'error'
function notify(message, type)
    lib.notify({
        title = locale('sell_drugs'),
        description = message,
        type = type,
    })
end

Call cops event

You can implemente your system for cops notification after peds calling them

---@param streetName string
---@param coords vector3
---@param pedMugshot image
RegisterNetEvent('axio_sellDrugs:client:callCops', function(streetName, coords, pedMugshot)
 ...
end)

Client : inventory.lua

Si vous n'utilisez pas les inventaires ESX ou QB par default, vous pouvez configurer le votre ici

You must respect the format indicated in the file

Server : functions.lua

removeItemAndGiveMoney

Here is the function call for remove the item from player inventory and give him money after selling drugs You can change for your own system with the param

---@param source int
---@param drug string
---@param qtty int
---@param price int
function removeItemAndGiveMoney(source, drug, qtty, price)
    if Config.framework == "esx" then
        player = ESX.GetPlayerFromId(source)
    elseif Config.framework == "qbcore" then
        player = QB.Functions.GetPlayer(source)
    end

    --[[ Remove item ]]
    if Config.inventoryType == "esx" then
        player.removeInventoryItem(drug, qtty)
    elseif Config.inventoryType == "qbcore" then
        player.Functions.RemoveItem(drug, qtty)
    end

    --[[ Give money ]]
    if Config.framework == "esx" then
        player.addAccountMoney(Config.moneyType, price)
    elseif Config.framework == "qbcore" then
        player.Functions.AddMoney(Config.moneyType, price)
    end
end

call Cops Event

This event is trigger when a ped call the cops

---@param streetName string
---@param coords vector3
---@param pedMugshot image
RegisterNetEvent('axio_sellDrugs:server:callCops', function(streetName, coords, pedMugshot)
 ...
end)

Last updated