Cube Scripts

Drug market

How drug selling, prices and the demand per zone work.

Players sell drugs to local peds with the target, or with a key if Config.Keys.sellDrugs is set. Every sale is validated by the server: distance, cooldowns, police count and inventory.

A sale, step by step#

  1. The player targets a ped and picks Sell. The first drug of

    Config.Drugs.items they carry is used.

  2. The ped reacts after duration milliseconds, according to chances:
    • accept - the ped buys between quantity.min and quantity.max units;
    • reject - nothing happens;
    • report - the ped refuses and the police receive a dispatch alert.
  3. On a sale, the player is paid, the gang earns Config.Points.drugSale points

    per unit and gains the drug's influence per unit in the current territory.

The same ped cannot be sold to again for pedCooldown seconds, and a player has to wait playerCooldown seconds between two sales.

Price#

Code
price = random(price.min, price.max) × amount × territory multiplier × drug demand

Territory multiplier#

config.luaLua
multipliers = { owned = 1.25, neutral = 1.0, rival = 0.8 },
WhereMultiplier
A territory owned by the seller's gangowned
A neutral territory, or outside every territoryneutral
A territory owned by another gangrival

Drug demand#

config.luaLua
preferences = {
    enabled = true,
    rotation = 60,
    liked = 1,
    disliked = 1,
    bonus = 1.3,
    malus = 0.7,
},

Each territory randomly wants liked drugs more (bonus) and disliked drugs less (malus). The demand changes every rotation minutes, so gangs have to adapt what they sell and where.

The current demand is shown on the pause map when hovering a territory, and is available to your scripts in the drugs field of GetPlayerZone and GetCurrentZone.

Adding a drug#

config.luaLua
items = {
    { name = 'weed', price = { min = 40, max = 60 }, influence = 1.0 },
    { name = 'meth', price = { min = 70, max = 95 }, influence = 1.5 },
    { name = 'cocaine', price = { min = 90, max = 120 }, influence = 2.0 },
    { name = 'heroin', price = { min = 110, max = 150 }, influence = 2.5 },
},

name must be an item that exists in your inventory. The order matters: when a player carries several drugs, the first one of the list is sold.

Police#

config.luaLua
Config.PoliceJobs = { 'police', 'sheriff' }

Config.Drugs = {
    minPolice = 2,
    dispatch = {
        code = '10-31',
        duration = 120,
        blip = { sprite = 51, color = 1, scale = 1.0, radius = 80.0 },
    },
}

minPolice is the number of on-duty officers required to sell. Police officers cannot sell drugs themselves. Reports use your dispatch resource, or the built-in blip when none is detected.