[OX] Aleks Smart Drug Dealer

Smart Drug Dealer Script
Fed up with your players trying to avoid RP by only selling their drugs when there are no players or police online to catch them? With the Smart Drug Dealer Script this problem becomes history.

The drug dealer calculates his purchase prices based on how many players are currently online. It is also possible to set whether the dealer is only on site at certain times (primetime) and/or when there are enough police officers online.

It is also possible to trigger police dispatches when something has been sold.

Features

  • Multiple dealer positions
  • Dealer can accept multiple items
  • Sell price calculated on how many players are currently online
  • Check if enough police is online (only esx and qb-core)
  • Adjustable dealer times - the dealer only spawns between defined times
  • Add Police dispatch if needed
  • Give dealer a visible weapon
  • Translate as you wish
  • Configurable notifications
  • Configurable min and max players for price calculation

Requirements

  • ox_lib
  • ox_inventory
  • ox_target
  • esx or qb-core (only if you want to use the police check)
Preview

Config
Config = {}

Config.TraderItems = {
    {
        id = 1,
        coords = vector4(1240.0295, -3004.4707, 9.3193, 49.9281),
        pedmodel = "u_m_y_proldriver_01",
        items = {
            {itemname = "packed_marihuana", itemlabel = "Packaged Marihuana", minPrice = 1800, maxPrice = 2400},
            {itemname = "packed_cocain", itemlabel = "Packaged Cocaine", minPrice = 4200, maxPrice = 4900},
        },
    },
    {
        id = 2, 
        coords = vector4(-217.8739, -2375.9097, 9.3192, 184.8092),
        pedmodel = "u_m_y_proldriver_01",
        items = {
            {itemname = "packed_crack", itemlabel = "Packaged Crack", minPrice = 4200, maxPrice = 4900},
        },
    },
    {
        id = 3, 
        coords = vector4(-360.1079, -1540.7512, 27.7264, 265.1867),
        pedmodel = "u_m_y_proldriver_01",
        items = {
            {itemname = "packed_meth", itemlabel = "Packaged Meth", minPrice = 1800, maxPrice = 2400},
        },
    }
}

Config.GiveTraderWeapon = true              -- Should the dealer get any weapon in his hands?
Config.TraderWeapon = "weapon_bat"
Config.TimeToSell = 1000 * 5                -- How long should the sale of on item take in seconds? (default: 5)

Config.TimeCheck = true                     -- if true, dealer only spawns if your server time is between Config.StartTime and Config.EndTime
Config.StartTime = 16                       -- only whole numbers (hours) possible (default: 16)
Config.EndTime = 01                         -- only whole numbers (hours) possible (default: 01)

Config.CheckForPolice = false               -- Only supported in ESX or QB
Config.PoliceJob = "police"                 -- How is the policejob called?
Config.MinimumPoliceOnline = 5              -- How many police officers need to be online for the dealer to be spawned? (default: 5)

Config.CheckData = 1000 * 60 * 5            -- Check if police is online and / or how often timecheck should run (default: every 5 minutes)

Config.PlayersForMaximum = 40
--[[
    This is the player amount needed to achieve the maximum sell price
    If you have at least this number of players online, the script calculates a random value between the defined minPrice and maxPrice in Config.TraderItems
    Even if you got more players online than this value, the calculation will always based on this number of players.

    Example calculation:
    Config.PlayersForMaximum = 40
    Players online: 15
    Defined minPrice in Config: 1000 $
    Defined maxPrice in Config: 4000 $

    Calculated minPrice: 375 $
    Calculated maxPrice: 1500 $
    Now a random price between these values is given to player on sale
    
    If you don't want to have a random price, set minPrice and maxPrice the same in Config.TraderItems
]]

Config.PlayersForMinimum = 10
--[[
    Even if you have fewer players than this value, the calculation will always be based on this number of players. 
    This prevents very low prices if there are only very few players on the server.

    Example calculation:
    Config.PlayersForMinimum = 10
    Players online: 5

    Defined minPrice in Config: 1000 $
    Defined maxPrice in Config: 4000 $

    Calculated minPrice: 250 $
    Calculated maxPrice: 1000 $
    Now a random price between these values is given to player on sale
]]

Config.Reward = "black_money" -- What item should the player get as reward (default: "black_money")
Config.Currency = "$"

Config.Translate = {
    TalkToTrader = "Talk to the Trader",
    ProcessTitle = "Selling ...",
    CurrentSellPrice = "I'll buy your stuff from",
    Sold = "You sold %sx %s!",
    NotEnough = "You don't have that much %s!",
    NoItem = "You got no %s",
    Notificationtitle = "DEALER",
    SellPromtTitle = "Sell",
    SellPromt = "How much %s do you want to sell? (You got %sx %s)",
}

-- Change Notification Style
function SendNotification(title, msg, type)
    -- type = "error", "success"
    print(title, msg, type)
end

-- Dispatch Function
Config.SendDispatch = false -- activate or deactivate dispatch on successful sale
function SendDispatch(coords, itemName, amount)
    
end

-- Framework Check (only needed for police check)
-- Do not edit unless you know what you're doing

if GetResourceState('es_extended') ~= 'missing' then 
    Config.Framework = "esx"
    ESX = exports["es_extended"]:getSharedObject()
elseif GetResourceState('qb-core') ~= 'missing' then 
    Config.Framework = "qb"
    QBCore = exports['qb-core']:GetCoreObject()
else
    print("[^3WARNING^7] NO SUPPORTED FRAMEWORK (ESX / QB) FOUND")
end

Get it now: [OX] Aleks Smart Drug Dealer

Code is accessible Config
Subscription-based No
Lines (approximately) Number of lines
Requirements ox_lib, ox_inventory
Support Yes

Is the job check accessible? would love to look into making this work with ND_Core.

1 Like

Hey, I just moved it to the open source part so you can try it. :slight_smile: