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#
- The player targets a ped and picks Sell. The first drug of
Config.Drugs.itemsthey carry is used. - The ped reacts after
durationmilliseconds, according tochances:- accept - the ped buys between
quantity.minandquantity.maxunits; - reject - nothing happens;
- report - the ped refuses and the police receive a dispatch alert.
- accept - the ped buys between
- On a sale, the player is paid, the gang earns
Config.Points.drugSalepointsper unit and gains the drug's
influenceper 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#
price = random(price.min, price.max) × amount × territory multiplier × drug demandTerritory multiplier#
multipliers = { owned = 1.25, neutral = 1.0, rival = 0.8 },| Where | Multiplier |
|---|---|
| A territory owned by the seller's gang | owned |
| A neutral territory, or outside every territory | neutral |
| A territory owned by another gang | rival |
Drug demand#
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#
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.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.