Skip to content

Selling ​

np_drugs owns the sale: it takes the item, pays the money, records the stamp and fires the sold event. Every sale runs through one engine, exports.np_drugs:Sell, whoever starts it: np_drugs' own street sale, np_gangs' corners or your resource.

The price ​

price per item = unit price × units × grade × stamp × demand (× opened)
Factor From
Unit price Config.Substances[*].price: one unit at grade A, demand 1.0, no stamp (cocaine 75, heroin 90, meth 65, …)
Grade A × 1.0, B × 0.8, C × 0.6, D × 0.4
Stamp The tier of its reputation, × 0.75 (burned) to × 1.10 (trusted); no stamp × 0.95
Demand The first Config.Demand area that contains the spot (Vinewood loves cocaine and ecstasy, Davis weed and heroin, Sandy Shores meth), else 1.0; clamped to 0.25..3.0
Opened A portion someone has been at sells for what is left × 0.8

GetPrice(item, coords, src) returns that quote with every factor. beforeSale hooks may change the price or set payees (np_gangs' turf prices, its outsider tax), but never above Config.Sale.priceCeiling × the base price (8×).

The street sale ​

The street sale

The basic sale np_drugs ships is deliberately simple: offer product to a passer-by (an ambient or scenario ped, checked on the server with OneSync) through a target option or the interact key.

  • The card shows what they ask for and roughly what they carry (40 to 320 in the wallet). Three in four buy at all.
  • Pick the item and set a price on a meter from cheap (0.5×) to greedy (1.6×). Each buyer has a walk-away line (1.0 to 1.3× the base price), shown a little off so the last dollars are a gamble.
  • Outcomes: buys, haggles once (just above the line), walks, calls it in (a witness report with your description) or tries to take it, more likely when no other player is around.
  • Heat: standing in one place too long thins out the buyers and lowers what they pay, per player and area. It falls by itself.
  • A passer-by takes the product too: their high rates the stamp (at a quarter weight), and a fentanyl cut can kill them.
  • Player-to-player sales are ordinary trades; np_drugs only records them when the buyer uses the product.

beforeSale hooks see these sales with channel = 'street', and the street card asks them for a quote (preview = true) before the player offers, so a gang's outsider tax shows honestly on the card.

With np_gangs: corners ​

While np_gangs runs, the street sale steps aside (Config.Street.disableWith = { 'np_gangs' }; {} keeps both) and np_gangs' corners replace it: shifts with a seller, a lookout and a runner, a drop, turf prices the OG sets, a split between seller, crew and back room. The sale itself still runs through np_drugs with channel = 'corner'. How the two fit: np_gangs + np_drugs.

Selling from your resource ​

lua
-- server: sell 2 items from slot 3 to an NPC buyer
local ok, result = exports.np_drugs:Sell(src, {
  slot = 3, count = 2, price = 90, channel = 'my_resource',
  buyer = { type = 'npc' }, coords = GetEntityCoords(GetPlayerPed(src)),
})
if not ok then print('sale refused: ' .. tostring(result)) end

-- server: tax every sale in your territory
exports.np_drugs:registerHook('beforeSale', function(p)
  if not inMyTerritory(p.coords) then return end
  -- p.preview = true is only a quote: answer the same, do nothing else
  return { payees = { { to = 'stash:my_territory_stash', percent = 15 } } }
end, { resource = GetCurrentResourceName() })

Payees are a character identifier (dirty cash, to pockets when online) or stash:<inventory id>. Whatever is not assigned goes to the seller; payees who are offline or have full pockets are paid at the next login (within 14 days). The full contract is on Exports & hooks.

All numbers are defaults in sale.lua, demand.lua, stamps.lua and street.lua (Configuration → Selling).