[Release] [QBCore] [Paid] Drug Sale system (momof-drugsales)

A script by momof513

No reviews yet.
[Release] [QBCore] [Paid] Drug Sale system (momof-drugsales) main image

Full Description

Do you have a QBCore server and want to explore a new drug selling system? This might be the script for you! This script has so many options for configuring and allows you to improve the QoL of your players! Many other drug selling scripts are passive or require you to stand still and people come to you. This script is different! This is a script where you go out and search for people to buy drugs. This utilizes third eye to sell to a local, but also has a keybind to bring a nearby local to you! From there you will get a configurable offer which you can accept or decline. There’s also a chance you get robbed for some of your drugs instead! To get your drugs back you need to beat the local up and take it back!

This script also has a twist of adding an NUI for the offer. It is a very simple UI but is easier for people to see and understand; not to mention it’s more performant!

Installation: Drag + Drop and edit the config.lua! If you want it to work as a command you will need to add the command, if you want to replace the qb-radialmenu Corner Selling option there are instructions on how to do so!

Documentation

Momof-DrugSales Documentation

For easier access and ability for other developers to build on this, I have created a guide and exported events that are not used in the script for easier access building on top of the script.

Client Events

  • momof-drugsales:client:ToggleDrugSales

Toggles the current state for the user’s selling state. When they’re on duty they can sell drugs, when they’re off duty they cant.

Example Server Call: TriggerClientEvent('momof-drugsales:client:ToggleDrugSales', src)

Example Client Call: TriggerEvent('momof-drugsales:client:ToggleDrugSales')


Script Transitions Instructions

QB-Core radialmenu

After making this change, the radial menu corner selling option will use momof-drugsales instead of qb-drugs corner selling. In qb-radialmenu > config.lua replace

event = 'qb-drugs:client:cornerselling',

WITH

event = 'momof-drugsales:client:ToggleDrugSales',

Commands

To make this script work with a command, here is an example piece of code you can add to your commands resource or to a new file in this resource.


RegisterCommand('drugsales', function()
TriggerEvent('momof-drugsales:client:ToggleDrugSales')
end)

Listenable Events (Server Side)

  • momof-drugsales:server:SaleSuccess

This event is called every time a sale is successful by the user. This can be used for integration with other scripts.

parameters: player source, drug name, amount of drugs sold, and price they were sold for.

example:

AddEventHandler('momof-drugsales:server:SaleSuccess', function(source, name, amount, price)
-- code here
end)
Config
Config = Config or {}

-- Range of drugs that can be sold per transaction.
Config.AmountPerSale = {
  min = 1,
  max = 10
}

-- Disable the anti-cheat if you're getting too many false positives.
Config.AntiCheatEnabled = true

-- Peds that should not be affected by the script.
Config.BlacklistedPeds = {
  `mp_m_shopkeep_01`,
  `s_m_y_ammucity_01`,
  `s_m_y_casino_01`
}

-- Price ranges per sellable item. Any item added here will become sellable.
Config.DrugPrices = {
  -- Weed
  ['weed_skunk'] = {
    min = 40,
    max = 50
  },
  ['weed_og-kush'] = {
    min = 50,
    max = 60
  },
  ['weed_white-widow'] = {
    min = 60,
    max = 70
  },
  ['weed_ak47'] = {
    min = 70,
    max = 80
  },
  ['weed_amnesia'] = {
    min = 80,
    max = 90
  },
  ['weed_purple-haze'] = {
    min = 90,
    max = 100
  },

  -- Coke
  ['cokebaggy'] = {
    min = 100,
    max = 200
  },
  ['crack_baggy'] = {
    min = 75,
    max = 150
  },

  -- Oxy
  ['oxy'] = {
    min = 250,
    max = 300
  },

  -- Meth
  ['meth1g'] = {
    min = 125,
    max = 225
  }
}

-- Image location for inventory items.
Config.InventoryImagesURL = 'nui://qb-inventory/html/images/'

-- Key used to call the closest local to the player. Leave this blank ('') if you want to disable calling of locals.
Config.Key = 'H'

-- Ability to change strings used.
Config.LocaleStrings = {
  ['NUIAccept'] = 'Accept',
  ['NUIDecline'] = 'Decline',
  ['OfferTarget'] = 'Offer Drugs',
  ['OutOfDrugs'] = "You don't have any drugs to sell here!",
  ['OutOfZone'] = "You can not sell drugs here!",
  ['OutOfZoneStopSelling'] = "You have left the drug area, stopping sales!",
  ['PoliceError'] = "You can't do this! You're a police officer!",
  ['PoliceNotified'] = "The cops were called on you!",
  ['PoliceOnlineError'] = "There are not enough police online!",
  ['PoliceWentOfflineError'] = "The officers have went to bed, maybe you should too!",
  ['ProgressBar'] = 'Offering drugs...',
  ['Rejected'] = 'I am not interested in any drugs.',
  ['RetrieveTarget'] = 'Retrieve Drugs',
  -- Robbed has {DrugAmount} and {DrugName} variables where you can place anywhere!
  ['Robbed'] = 'You got robbed for {DrugAmount} {DrugName}!',
  ['SoldOut'] = "You've sold all of your drugs!",
  ['StartedSelling'] = "You've started selling drugs, go talk to some locals!",
  ['StoppedSelling'] = "You've stopped selling drugs."
}

-- "markedbills" is a working example item in qb-core. This will just set a
-- metadata field named "worth" to the cash value **instead** of giving money.
-- Can be used for money cleaning. Set MarkedBillsAsReward to true to enable.
Config.MarkedBillsAsReward = false
Config.MarkedBillsName = "markedbills"

-- Config options for servers who use money as an item. MoneyItemName should be
-- the shared lua item name, and set MoneyAsAnItem = true. 
Config.MoneyItemName = "dirty_money"
Config.MoneyAsAnItem = false

-- Minimum number of Police to allow sale of drugs.
Config.MinimumPolice = 2

-- Chances of what happens when a NPC is offered drugs. This is a chance that
-- is calculated before the robbery chance is calculated. If it does not get rejected
-- then the robbery chance goes for those buyers.
Config.OfferChances = {
  Reject = 25,
  RejectAndCallPolice = 10
}

Config.Police = {
  -- Chance for Police to get called.
  ['Chance'] = 10,

  -- List of the police jobs.
  ['Jobs'] = {
    'police',
  },

  -- Message used for the police messages.
  ['Message'] = {
    ['Title'] = 'Suspicious Handoff',
    ['Body'] = 'Possible drug sale'
  },

  ['Multiplier'] = {
    -- Amount to multiply the price per drug.
    ['Amount'] = 1.25,

    -- Minimum number of police officers online to give this price multiplier.
    ['Threshold'] = 4
  },

  -- If the player should be notified when the police is notified.
  ['NotifyPlayer'] = false,

  -- Currently supported dispatches:
  -- qb-policejob
  -- cd_dispatch
  -- ps-dispatch
  -- qs-dispatch
  -- 
  -- If you have a dispatch script that is not supported, join my discord and
  -- open a ticket, I will add support for it! discord.gg/ykKzNbguZq
  ['DispatchScript'] = 'qb-policejob',

  -- Config for cd_dispatch blip
  -- flash = Set to 1 to make the UI flash, used for panic button calls etc.
  -- blip:
  --   sprite = The icon for the blip.
  --   scale = Size of the blip.
  --   colour = Colour of the blip.
  --   flashes - If set to true the blip will flash on the pause menu/mini-map, used for more important calls.
  --   time - The amount of time until the blip fades (default is 5 mins.)
  --   sound - The sound when receiving a notification: 
  --     1 = x1 sound alert, 2 = x2 sound alert's, 3 = panic button alert sound.
  ['DispatchScriptCDConfig'] = {
    ['flash'] = 0,
    ['blip'] = {
      ['sprite'] = 469,
      ['scale'] = 1.2,
      ['colour'] = 18,
      ['flashes'] = false,
      ['time'] = (5 * 60 * 1000),
      ['sound'] = 1
    }
  },

  -- Config for qs_dispatch blip
  -- flash = Set to true to make the UI flash, used for panic button calls etc.
  -- blip:
  --   sprite = The icon for the blip.
  --   scale = Size of the blip.
  --   colour = Colour of the blip.
  --   flashes - If set to true the blip will flash on the pause menu/mini-map, used for more important calls.
  --   time - The amount of time until the blip fades (default is 5 mins.)
  ['DispatchScriptQSConfig'] = {
    ['flash'] = false,
    ['blip'] = {
      ['sprite'] = 469,
      ['scale'] = 1.2,
      ['colour'] = 18,
      ['flashes'] = false,
      ['time'] = (5 * 60 * 1000),
    }
  },

  -- How frequently to fetch the number of officers online (in minutes)
  ['Timer'] = 5
}

-- Chance for the user to get robbed by the local.
Config.RobberyChance = 20

-- Target resource name.
Config.Target = "qb-target"

-- Set to True if using ox_inventory
Config.UseOxInventory = false

-- Zones to allow specific drug sales in specific areas.
Config.Zones = {
  ['Enabled'] = false,
  ['Zones'] = {
    ['GroveDrugs'] = {
      -- These are the sellable drugs in this zone. Ensure they have a price above.
      Drugs = {
        'cokebaggy',
        'crack_baggy',
      },
      PolyZone = {
        vector2(90.25691986084, -1994.3848876953),
        vector2(-152.01383972168, -1780.4528808594),
        vector2(-142.83885192871, -1771.4385986328),
        vector2(-130.85748291016, -1765.1094970703),
        vector2(-93.366149902344, -1746.1839599609),
        vector2(-60.044002532959, -1732.4547119141),
        vector2(-6.1716313362122, -1778.3068847656),
        vector2(87.354377746582, -1861.6126708984),
        vector2(186.25912475586, -1906.7739257812),
        vector2(202.17477416992, -1919.5943603516),
        vector2(146.09353637695, -1986.0899658203),
        vector2(132.08726501465, -2030.7707519531),
        vector2(90.800064086914, -2029.0336914062)
      },
      MinZ = 15.0,
      MaxZ = 40.0,
      DebugPoly = false
    }
  }
}

-- Zones to allow drug sales to have higher sell prices.
Config.ZonesWithBonuses = {
  ['Enabled'] = false,
  ['Zones'] = {
    ['GroveDrugs'] = {
      BonusMultiplier = 1.5,
      PolyZone = {
        vector2(90.25691986084, -1994.3848876953),
        vector2(-152.01383972168, -1780.4528808594),
        vector2(-142.83885192871, -1771.4385986328),
        vector2(-130.85748291016, -1765.1094970703),
        vector2(-93.366149902344, -1746.1839599609),
        vector2(-60.044002532959, -1732.4547119141),
        vector2(-6.1716313362122, -1778.3068847656),
        vector2(87.354377746582, -1861.6126708984),
        vector2(186.25912475586, -1906.7739257812),
        vector2(202.17477416992, -1919.5943603516),
        vector2(146.09353637695, -1986.0899658203),
        vector2(132.08726501465, -2030.7707519531),
        vector2(90.800064086914, -2029.0336914062)
      },
      MinZ = 15.0,
      MaxZ = 40.0,
      DebugPoly = false,
    }
  }
}

Screenshot:

Features:

  • QBCore
  • Free updates and support
  • Setup instructions included
  • Custom written React front-end
  • Ability to stop locals and offer drugs
  • Ability to setup zones for drug sales
  • Configurable chances and drug prices
  • Configurable chances for the NPCs to call the police.
  • Configurable multipliers when more police are online.
  • Highly optimized & secured events (will ban players who try exploiting)
  • Drag and drop easy installation with instructions on how to replace the radial menu or turn into a function
  • Protected via FiveM Asset Escrow but source add-ons available

Dependencies:

  • QBCore

Supported Inventories:

  • qb-inventory
  • ox_inventory

Supported Dispatches:

  • qb-policejob
  • cd_dispatch
  • ps-dispatch
  • qs-dispatch

Uses escrow but can also buy react project. Full source currently unavailable.
Showcase Video: Video
Escrow: Tebex $15
Escrow + React: Tebex $30
Full Source: Currently N/A

Code is accessible No
Subscription-based No
Lines (approximately) 650 lua/200 js
Requirements QBCore
Support Yes