daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ESX                            = nil
  2. local CopsConnected            = 0
  3. local PlayersHarvestingCoke    = {}
  4. local PlayersTransformingCoke  = {}
  5. local PlayersSellingCoke       = {}
  6. local PlayersHarvestingMeth    = {}
  7. local PlayersTransformingMeth  = {}
  8. local PlayersSellingMeth       = {}
  9. local PlayersHarvestingWeed    = {}
  10. local PlayersTransformingWeed  = {}
  11. local PlayersSellingWeed       = {}
  12. local PlayersHarvestingOpium   = {}
  13. local PlayersTransformingOpium = {}
  14. local PlayersSellingOpium      = {}
  15.  
  16. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  17.  
  18. function CountCops()
  19.  
  20.     local xPlayers = ESX.GetPlayers()
  21.  
  22.     CopsConnected = 0
  23.  
  24.     for i=1, #xPlayers, 1 do
  25.         local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
  26.         if xPlayer.job.name == 'police' then
  27.             CopsConnected = CopsConnected + 1
  28.         end
  29.     end
  30.  
  31.     SetTimeout(5000, CountCops)
  32.  
  33. end
  34.  
  35. CountCops()
  36.  
  37. --coke
  38. local function HarvestCoke(source)
  39.  
  40.     if CopsConnected < Config.RequiredCopsCoke then
  41.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsCoke)
  42.         return
  43.     end
  44.  
  45.     SetTimeout(5000, function()
  46.  
  47.         if PlayersHarvestingCoke[source] == true then
  48.  
  49.             local xPlayer  = ESX.GetPlayerFromId(source)
  50.  
  51.             local coke = xPlayer.getInventoryItem('coke')
  52.  
  53.             if coke.limit ~= 3 and coke.count >= coke.limit then
  54.                 TriggerClientEvent('customNotification', source, _U('inv_full_coke'),  2000, true, 'error')
  55.             else
  56.                 xPlayer.addInventoryItem('coke', 1)
  57.                 HarvestCoke(source)
  58.             end
  59.  
  60.         end
  61.     end)
  62. end
  63.  
  64. RegisterServerEvent('esx_drugs:startHarvestCoke')
  65. AddEventHandler('esx_drugs:startHarvestCoke', function()
  66.  
  67.     local _source = source
  68.  
  69.     PlayersHarvestingCoke[_source] = true
  70.  
  71.     TriggerClientEvent('customNotification', _source, _U('pickup_in_prog'), 2000, true, 'success')
  72.  
  73.     HarvestCoke(_source)
  74.  
  75. end)
  76.  
  77. RegisterServerEvent('esx_drugs:stopHarvestCoke')
  78. AddEventHandler('esx_drugs:stopHarvestCoke', function()
  79.  
  80.     local _source = source
  81.  
  82.     PlayersHarvestingCoke[_source] = false
  83.  
  84. end)
  85.  
  86. local function TransformCoke(source)
  87.  
  88.     if CopsConnected < Config.RequiredCopsCoke then
  89.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsCoke)
  90.         return
  91.     end
  92.  
  93.     SetTimeout(10000, function()
  94.  
  95.         if PlayersTransformingCoke[source] == true then
  96.  
  97.             local xPlayer  = ESX.GetPlayerFromId(source)
  98.  
  99.             local cokeQuantity = xPlayer.getInventoryItem('coke').count
  100.             local poochQuantity = xPlayer.getInventoryItem('coke_pooch').count
  101.  
  102.             if poochQuantity > 300 then
  103.                 TriggerClientEvent('customNotification', source, _U('too_many_pouches'), 2000, true, 'error')
  104.             elseif cokeQuantity < 3 then
  105.                 TriggerClientEvent('customNotification', source, _U('not_enough_coke'), 2000, true, 'error')
  106.             else
  107.                 xPlayer.removeInventoryItem('coke', 3)
  108.                 xPlayer.addInventoryItem('coke_pooch', 1)
  109.            
  110.                 TransformCoke(source)
  111.             end
  112.  
  113.         end
  114.     end)
  115. end
  116.  
  117. RegisterServerEvent('esx_drugs:startTransformCoke')
  118. AddEventHandler('esx_drugs:startTransformCoke', function()
  119.  
  120.     local _source = source
  121.  
  122.     PlayersTransformingCoke[_source] = true
  123.  
  124.     TriggerClientEvent('customNotification', _source, _U('packing_in_prog'), 2000, true, 'success')
  125.  
  126.     TransformCoke(_source)
  127.  
  128. end)
  129.  
  130. RegisterServerEvent('esx_drugs:stopTransformCoke')
  131. AddEventHandler('esx_drugs:stopTransformCoke', function()
  132.  
  133.     local _source = source
  134.  
  135.     PlayersTransformingCoke[_source] = false
  136.  
  137. end)
  138.  
  139. local function SellCoke(source)
  140.  
  141.     if CopsConnected < Config.RequiredCopsCoke then
  142.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsCoke)
  143.         return
  144.     end
  145.  
  146.     SetTimeout(7500, function()
  147.  
  148.         if PlayersSellingCoke[source] == true then
  149.  
  150.             local xPlayer  = ESX.GetPlayerFromId(source)
  151.  
  152.             local poochQuantity = xPlayer.getInventoryItem('coke_pooch').count
  153.  
  154.             if poochQuantity == 0 then
  155.                 TriggerClientEvent('customNotification', source, _U('no_pouches_sale'), 2000, true, 'error')
  156.             else
  157.                 xPlayer.removeInventoryItem('coke_pooch', 10)
  158.                     xPlayer.addAccountMoney('black_money', 1600)
  159.                     TriggerClientEvent('customNotification', source, _U('sold_one_coke'), 2000, true, 'success')
  160.                 end
  161.                
  162.                 SellCoke(source)
  163.             end
  164.  
  165.         end)
  166.     end
  167.  
  168. RegisterServerEvent('esx_drugs:startSellCoke')
  169. AddEventHandler('esx_drugs:startSellCoke', function()
  170.     local id = GetPlayerIdentifiers(source)[1]
  171.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  172.     {
  173.         ['@identifier'] = id
  174.     })
  175.     local user      = result[1]
  176.     local _source = source
  177.     local job = user['job']
  178.  
  179.     PlayersSellingCoke[_source] = true
  180.  
  181.     TriggerClientEvent('customNotification', _source, _U('sale_in_prog'), 2000, true, 'success')
  182.  
  183.     SellCoke(_source)
  184. end)
  185.  
  186. RegisterServerEvent('esx_drugs:stopSellCoke')
  187. AddEventHandler('esx_drugs:stopSellCoke', function()
  188.  
  189.     local _source = source
  190.  
  191.     PlayersSellingCoke[_source] = false
  192.  
  193. end)
  194.  
  195. --meth
  196. local function HarvestMeth(source)
  197.  
  198.     if CopsConnected < Config.RequiredCopsMeth then
  199.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsMeth)
  200.         return
  201.     end
  202.    
  203.     SetTimeout(5000, function()
  204.  
  205.         if PlayersHarvestingMeth[source] == true then
  206.  
  207.             local xPlayer  = ESX.GetPlayerFromId(source)
  208.             local meth = xPlayer.getInventoryItem('meth')
  209.  
  210.             if meth.limit ~= -1 and meth.count >= meth.limit then
  211.                 TriggerClientEvent('customNotification', source, _U('inv_full_meth'), 2000, true, 'error')
  212.             else
  213.                 xPlayer.addInventoryItem('meth', 1)
  214.                 HarvestMeth(source)
  215.             end
  216.  
  217.         end
  218.     end)
  219. end
  220.  
  221. RegisterServerEvent('esx_drugs:startHarvestMeth')
  222. AddEventHandler('esx_drugs:startHarvestMeth', function()
  223.     local id = GetPlayerIdentifiers(source)[1]
  224.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  225.     {
  226.         ['@identifier'] = id
  227.     })
  228.     local user      = result[1]
  229.     local _source = source
  230.     local job = user['job']
  231.  
  232.     PlayersHarvestingMeth[_source] = true
  233.  
  234.     TriggerClientEvent('customNotification', _source, _U('pickup_in_prog'), 2000, true, 'success')
  235.  
  236.     HarvestMeth(_source)
  237.  
  238. end)
  239.  
  240. RegisterServerEvent('esx_drugs:stopHarvestMeth')
  241. AddEventHandler('esx_drugs:stopHarvestMeth', function()
  242.  
  243.     local _source = source
  244.  
  245.     PlayersHarvestingMeth[_source] = false
  246.  
  247. end)
  248.  
  249. local function TransformMeth(source)
  250.  
  251.     if CopsConnected < Config.RequiredCopsMeth then
  252.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsMeth)
  253.         return
  254.     end
  255.  
  256.     SetTimeout(12000, function()
  257.  
  258.         if PlayersTransformingMeth[source] == true then
  259.  
  260.             local xPlayer  = ESX.GetPlayerFromId(source)
  261.  
  262.             local methQuantity = xPlayer.getInventoryItem('meth').count
  263.             local poochQuantity = xPlayer.getInventoryItem('meth_pooch').count
  264.  
  265.             if poochQuantity > 300 then
  266.                 TriggerClientEvent('customNotification', source, _U('too_many_pouches'), 2000, true, 'error')
  267.             elseif methQuantity < 3 then
  268.                 TriggerClientEvent('customNotification', source, _U('not_enough_meth'), 2000, true, 'error')
  269.             else
  270.                 xPlayer.removeInventoryItem('meth', 3)
  271.                 xPlayer.addInventoryItem('meth_pooch', 1)
  272.                
  273.                 TransformMeth(source)
  274.             end
  275.  
  276.         end
  277.     end)
  278. end
  279.  
  280. RegisterServerEvent('esx_drugs:startTransformMeth')
  281. AddEventHandler('esx_drugs:startTransformMeth', function()
  282.     local id = GetPlayerIdentifiers(source)[1]
  283.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  284.     {
  285.         ['@identifier'] = id
  286.     })
  287.     local user      = result[1]
  288.     local _source = source
  289.     local job = user['job']
  290.  
  291.     local _source = source
  292.  
  293.     PlayersTransformingMeth[_source] = true
  294.  
  295.     TriggerClientEvent('customNotification', _source, _U('packing_in_prog'), 2000, true, 'success')
  296.  
  297.     TransformMeth(_source)
  298. end)
  299.  
  300. RegisterServerEvent('esx_drugs:stopTransformMeth')
  301. AddEventHandler('esx_drugs:stopTransformMeth', function()
  302.  
  303.     local _source = source
  304.  
  305.     PlayersTransformingMeth[_source] = false
  306.  
  307. end)
  308.  
  309. local function SellMeth(source)
  310.  
  311.     if CopsConnected < Config.RequiredCopsMeth then
  312.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsMeth)
  313.         return
  314.     end
  315.  
  316.     SetTimeout(7500, function()
  317.  
  318.         if PlayersSellingMeth[source] == true then
  319.  
  320.             local xPlayer  = ESX.GetPlayerFromId(source)
  321.  
  322.             local poochQuantity = xPlayer.getInventoryItem('meth_pooch').count
  323.  
  324.             if poochQuantity == 0 then
  325.                 TriggerClientEvent('customNotification', source, _U('no_pouches_sale'), 2000, true, 'error')
  326.             else
  327.                 xPlayer.removeInventoryItem('meth_pooch', 10)
  328.                     xPlayer.addAccountMoney('black_money', 6400)
  329.                     TriggerClientEvent('customNotification', source, _U('sold_one_meth'), 2000, true, 'success')
  330.                 end
  331.                
  332.                 SellMeth(source)
  333.             end
  334.     end)
  335. end
  336.  
  337. RegisterServerEvent('esx_drugs:startSellMeth')
  338. AddEventHandler('esx_drugs:startSellMeth', function()
  339.     local id = GetPlayerIdentifiers(source)[1]
  340.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  341.     {
  342.         ['@identifier'] = id
  343.     })
  344.     local user      = result[1]
  345.     local _source = source
  346.     local job = user['job']
  347.  
  348.     PlayersSellingMeth[_source] = true
  349.  
  350.     TriggerClientEvent('customNotification', _source, _U('sale_in_prog'),  2000, true, 'success')
  351.  
  352.     SellMeth(_source)
  353. end)
  354.  
  355. RegisterServerEvent('esx_drugs:stopSellMeth')
  356. AddEventHandler('esx_drugs:stopSellMeth', function()
  357.  
  358.     local _source = source
  359.  
  360.     PlayersSellingMeth[_source] = false
  361.  
  362. end)
  363.  
  364. --weed
  365. local function HarvestWeed(source)
  366.  
  367.     if CopsConnected < Config.RequiredCopsWeed then
  368.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsWeed)
  369.         return
  370.     end
  371.  
  372.     SetTimeout(5000, function()
  373.  
  374.         if PlayersHarvestingWeed[source] == true then
  375.  
  376.             local xPlayer  = ESX.GetPlayerFromId(source)
  377.  
  378.             local weed = xPlayer.getInventoryItem('weed')
  379.  
  380.             if weed.limit ~= 10 and weed.count >= weed.limit then
  381.                 TriggerClientEvent('customNotification', source, _U('inv_full_weed'), 2000, true, 'error')
  382.             else
  383.                 xPlayer.addInventoryItem('weed', 1)
  384.                 HarvestWeed(source)
  385.             end
  386.  
  387.         end
  388.     end)
  389. end
  390.  
  391. RegisterServerEvent('esx_drugs:startHarvestWeed')
  392. AddEventHandler('esx_drugs:startHarvestWeed', function()
  393.  
  394.     local _source = source
  395.  
  396.     PlayersHarvestingWeed[_source] = true
  397.  
  398.     TriggerClientEvent('customNotification', _source, _U('pickup_in_prog'), 2000, true, 'success')
  399.  
  400.     HarvestWeed(_source)
  401.  
  402. end)
  403.  
  404. RegisterServerEvent('esx_drugs:stopHarvestWeed')
  405. AddEventHandler('esx_drugs:stopHarvestWeed', function()
  406.  
  407.     local _source = source
  408.  
  409.     PlayersHarvestingWeed[_source] = false
  410.  
  411. end)
  412.  
  413. local function TransformWeed(source)
  414.  
  415.     if CopsConnected < Config.RequiredCopsWeed then
  416.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsWeed)
  417.         return
  418.     end
  419.  
  420.     SetTimeout(7500, function()
  421.  
  422.         if PlayersTransformingWeed[source] == true then
  423.  
  424.             local xPlayer  = ESX.GetPlayerFromId(source)
  425.  
  426.             local weedQuantity = xPlayer.getInventoryItem('weed').count
  427.             local poochQuantity = xPlayer.getInventoryItem('weed_pooch').count
  428.  
  429.             if poochQuantity > 300 then
  430.                 TriggerClientEvent('customNotification', source, _U('too_many_pouches'), 2000, true, 'error')
  431.             elseif weedQuantity < 3 then
  432.                 TriggerClientEvent('customNotification', source, _U('not_enough_weed'), 2000, true, 'error')
  433.             else
  434.                 xPlayer.removeInventoryItem('weed', 3)
  435.                 xPlayer.addInventoryItem('weed_pooch', 1)
  436.                
  437.                 TransformWeed(source)
  438.             end
  439.  
  440.         end
  441.     end)
  442. end
  443.  
  444. RegisterServerEvent('esx_drugs:startTransformWeed')
  445. AddEventHandler('esx_drugs:startTransformWeed', function()
  446.  
  447.     local _source = source
  448.  
  449.     PlayersTransformingWeed[_source] = true
  450.  
  451.     TriggerClientEvent('customNotification', _source, _U('packing_in_prog'), 2000, true, 'success')
  452.  
  453.     TransformWeed(_source)
  454.  
  455. end)
  456.  
  457. RegisterServerEvent('esx_drugs:stopTransformWeed')
  458. AddEventHandler('esx_drugs:stopTransformWeed', function()
  459.  
  460.     local _source = source
  461.  
  462.     PlayersTransformingWeed[_source] = false
  463.  
  464. end)
  465.  
  466. local function SellWeed(source)
  467.  
  468.     if CopsConnected < Config.RequiredCopsWeed then
  469.         TriggerClientEvent('esx_weedjob:showNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsWeed)
  470.         return
  471.     end
  472.  
  473.     SetTimeout(7500, function()
  474.  
  475.         if PlayersSellingWeed[source] == true then
  476.  
  477.             local xPlayer  = ESX.GetPlayerFromId(source)
  478.  
  479.             local poochQuantity = xPlayer.getInventoryItem('weed_pooch').count
  480.  
  481.             if poochQuantity == 0 then
  482.                 TriggerClientEvent('customNotification', source, _U('no_pouches_sale'), 2000, true, 'error')
  483.             else
  484.                 xPlayer.removeInventoryItem('weed_pooch', 10)
  485.                     xPlayer.addAccountMoney('black_money', 2400)
  486.                     TriggerClientEvent('customNotification', source, _U('sold_one_weed'), 2000, true, 'success')
  487.                 end
  488.                
  489.                 SellWeed(source)
  490.             end
  491.     end)
  492. end
  493.  
  494. RegisterServerEvent('esx_drugs:startSellWeed')
  495. AddEventHandler('esx_drugs:startSellWeed', function()
  496.     local id = GetPlayerIdentifiers(source)[1]
  497.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  498.     {
  499.         ['@identifier'] = id
  500.     })
  501.     local user      = result[1]
  502.     local _source = source
  503.     local job = user['job']
  504.     PlayersSellingWeed[_source] = true
  505.  
  506.     TriggerClientEvent('customNotification', _source, _U('sale_in_prog'), 2000, true, 'success')
  507.  
  508.     SellWeed(_source)
  509. end)
  510.  
  511. RegisterServerEvent('esx_drugs:stopSellWeed')
  512. AddEventHandler('esx_drugs:stopSellWeed', function()
  513.  
  514.     local _source = source
  515.  
  516.     PlayersSellingWeed[_source] = false
  517.  
  518. end)
  519.  
  520.  
  521. --opium
  522.  
  523. local function HarvestOpium(source)
  524.  
  525.     if CopsConnected < Config.RequiredCopsOpium then
  526.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsOpium)
  527.         return
  528.     end
  529.  
  530.     SetTimeout(5000, function()
  531.  
  532.         if PlayersHarvestingOpium[source] == true then
  533.  
  534.             local xPlayer  = ESX.GetPlayerFromId(source)
  535.  
  536.             local opium = xPlayer.getInventoryItem('opium')
  537.  
  538.             if opium.limit ~= -1 and opium.count >= opium.limit then
  539.                 TriggerClientEvent('customNotification', source, _U('inv_full_opium'))
  540.             else
  541.                 xPlayer.addInventoryItem('opium', 1)
  542.                 HarvestOpium(source)
  543.             end
  544.  
  545.         end
  546.     end)
  547. end
  548.  
  549. RegisterServerEvent('esx_drugs:startHarvestOpium')
  550. AddEventHandler('esx_drugs:startHarvestOpium', function()
  551.     local id = GetPlayerIdentifiers(source)[1]
  552.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  553.     {
  554.         ['@identifier'] = id
  555.     })
  556.     local user      = result[1]
  557.     local _source = source
  558.     local job = user['job']
  559.  
  560.     local _source = source
  561.  
  562.     PlayersHarvestingOpium[_source] = true
  563.  
  564.     TriggerClientEvent('customNotification', _source, _U('pickup_in_prog'), 2000, true, 'success')
  565.  
  566.     HarvestOpium(_source)
  567. end)
  568.  
  569. RegisterServerEvent('esx_drugs:stopHarvestOpium')
  570. AddEventHandler('esx_drugs:stopHarvestOpium', function()
  571.  
  572.     local _source = source
  573.  
  574.     PlayersHarvestingOpium[_source] = false
  575.  
  576. end)
  577.  
  578. local function TransformOpium(source)
  579.  
  580.     if CopsConnected < Config.RequiredCopsOpium then
  581.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsOpium)
  582.         return
  583.     end
  584.  
  585.     SetTimeout(10000, function()
  586.  
  587.         if PlayersTransformingOpium[source] == true then
  588.  
  589.             local xPlayer  = ESX.GetPlayerFromId(source)
  590.  
  591.             local opiumQuantity = xPlayer.getInventoryItem('opium').count
  592.             local poochQuantity = xPlayer.getInventoryItem('opium_pooch').count
  593.  
  594.             if poochQuantity > 300 then
  595.                 TriggerClientEvent('customNotification', source, _U('too_many_pouches'), 2000, true, 'error')
  596.             elseif opiumQuantity < 3 then
  597.                 TriggerClientEvent('customNotification', source, _U('not_enough_opium'), 2000, true, 'error')
  598.             else
  599.                 xPlayer.removeInventoryItem('opium', 3)
  600.                 xPlayer.addInventoryItem('opium_pooch', 1)
  601.            
  602.                 TransformOpium(source)
  603.             end
  604.  
  605.         end
  606.     end)
  607. end
  608.  
  609. RegisterServerEvent('esx_drugs:startTransformOpium')
  610. AddEventHandler('esx_drugs:startTransformOpium', function()
  611.     local id = GetPlayerIdentifiers(source)[1]
  612.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  613.     {
  614.         ['@identifier'] = id
  615.     })
  616.     local user      = result[1]
  617.     local _source = source
  618.     local job = user['job']
  619.  
  620.     local _source = source
  621.  
  622.     PlayersTransformingOpium[_source] = true
  623.  
  624.     TriggerClientEvent('customNotification', _source, _U('packing_in_prog'), 2000, true, 'success')
  625.  
  626.     TransformOpium(_source)
  627.  
  628. end)
  629.  
  630. RegisterServerEvent('esx_drugs:stopTransformOpium')
  631. AddEventHandler('esx_drugs:stopTransformOpium', function()
  632.  
  633.     local _source = source
  634.  
  635.     PlayersTransformingOpium[_source] = false
  636.  
  637. end)
  638.  
  639. local function SellOpium(source)
  640.  
  641.     if CopsConnected < Config.RequiredCopsOpium then
  642.         TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsOpium)
  643.         return
  644.     end
  645.  
  646.     SetTimeout(7500, function()
  647.  
  648.         if PlayersSellingOpium[source] == true then
  649.  
  650.             local xPlayer  = ESX.GetPlayerFromId(source)
  651.  
  652.             local poochQuantity = xPlayer.getInventoryItem('opium_pooch').count
  653.  
  654.             if poochQuantity == 0 then
  655.                 TriggerClientEvent('customNotification', source, _U('no_pouches_sale'), 2000, true, 'error')
  656.             else
  657.                 xPlayer.removeInventoryItem('opium_pooch', 10)
  658.                     xPlayer.addAccountMoney('black_money', 4400)
  659.                     TriggerClientEvent('customNotification', source, _U('sold_one_opium'), 2000, true, 'success')
  660.                 end
  661.                
  662.                 SellOpium(source)
  663.             end
  664.     end)
  665. end
  666.  
  667. RegisterServerEvent('esx_drugs:startSellOpium')
  668. AddEventHandler('esx_drugs:startSellOpium', function()
  669.     local id = GetPlayerIdentifiers(source)[1]
  670.     local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  671.     {
  672.         ['@identifier'] = id
  673.     })
  674.     local user      = result[1]
  675.     local _source = source
  676.     local job = user['job']
  677.     PlayersSellingOpium[_source] = true
  678.  
  679.     TriggerClientEvent('customNotification', _source, _U('sale_in_prog'), 2000, true, 'success')
  680.  
  681.     SellOpium(_source)
  682. end)
  683.  
  684. RegisterServerEvent('esx_drugs:stopSellOpium')
  685. AddEventHandler('esx_drugs:stopSellOpium', function()
  686.  
  687.     local _source = source
  688.  
  689.     PlayersSellingOpium[_source] = false
  690.  
  691. end)
  692.  
  693.  
  694. -- RETURN INVENTORY TO CLIENT
  695. RegisterServerEvent('esx_drugs:GetUserInventory')
  696. AddEventHandler('esx_drugs:GetUserInventory', function(currentZone)
  697.     local _source = source
  698.     local xPlayer  = ESX.GetPlayerFromId(_source)
  699.     TriggerClientEvent('esx_drugs:ReturnInventory',
  700.         _source,
  701.         xPlayer.getInventoryItem('coke').count,
  702.         xPlayer.getInventoryItem('coke_pooch').count,
  703.         xPlayer.getInventoryItem('meth').count,
  704.         xPlayer.getInventoryItem('meth_pooch').count,
  705.         xPlayer.getInventoryItem('weed').count,
  706.         xPlayer.getInventoryItem('weed_pooch').count,
  707.         xPlayer.getInventoryItem('opium').count,
  708.         xPlayer.getInventoryItem('opium_pooch').count,
  709.         xPlayer.job.name,
  710.         currentZone
  711.     )
  712. end)
  713.  
  714. -- Register Usable Item
  715. ESX.RegisterUsableItem('weed', function(source)
  716.  
  717.     local _source = source
  718.     local xPlayer  = ESX.GetPlayerFromId(source)
  719.  
  720.     xPlayer.removeInventoryItem('weed', 1)
  721.  
  722.     TriggerClientEvent('esx_drugs:onPot', _source)
  723.     TriggerClientEvent('customNotification', _source, _U('used_one_weed'),  2000, true, 'success')
  724.  
  725. end)
  726.  
  727.  
  728.  
  729. ESX.RegisterUsableItem('piwo', function(source)
  730.  
  731.     local _source = source
  732.     local xPlayer  = ESX.GetPlayerFromId(source)
  733.  
  734.     xPlayer.removeInventoryItem('piwo', 1)
  735.  
  736.     TriggerClientEvent('esx_drugs:onZbieranie', _source)
  737.  
  738. end)
  739.  
  740. ESX.RegisterUsableItem('vodka', function(source)
  741.  
  742.     local _source = source
  743.     local xPlayer  = ESX.GetPlayerFromId(source)
  744.  
  745.     xPlayer.removeInventoryItem('vodka', 1)
  746.  
  747.     TriggerClientEvent('esx_drugs:onZbieranie', _source)
  748.  
  749. end)
  750.  
  751. ESX.RegisterUsableItem('whiskey', function(source)
  752.  
  753.     local _source = source
  754.     local xPlayer  = ESX.GetPlayerFromId(source)
  755.  
  756.     xPlayer.removeInventoryItem('whiskey', 1)
  757.  
  758.     TriggerClientEvent('esx_drugs:onZbieranie', _source)
  759.  
  760. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top