Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. --coke
  2. local function HarvestCoke(source)
  3.  
  4. if CopsConnected < Config.RequiredCopsCoke then
  5. TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsCoke)
  6. return
  7. end
  8.  
  9. SetTimeout(5000, function()
  10.  
  11. if PlayersHarvestingCoke[source] == true then
  12.  
  13. local xPlayer = ESX.GetPlayerFromId(source)
  14.  
  15. local coke = xPlayer.getInventoryItem('coke')
  16.  
  17. if coke.limit ~= 10 and coke.count >= coke.limit then
  18. TriggerClientEvent('customNotification', source, _U('inv_full_coke'), 2000, true, 'error')
  19. else
  20. xPlayer.addInventoryItem('coke', 1)
  21. HarvestCoke(source)
  22. end
  23.  
  24. end
  25. end)
  26. end
  27.  
  28. RegisterServerEvent('esx_drugs:startHarvestCoke')
  29. AddEventHandler('esx_drugs:startHarvestCoke', function()
  30.  
  31. local _source = source
  32.  
  33. PlayersHarvestingCoke[_source] = true
  34.  
  35. TriggerClientEvent('customNotification', _source, _U('pickup_in_prog'), 2000, true, 'success')
  36.  
  37. HarvestCoke(_source)
  38.  
  39. end)
  40.  
  41. RegisterServerEvent('esx_drugs:stopHarvestCoke')
  42. AddEventHandler('esx_drugs:stopHarvestCoke', function()
  43.  
  44. local _source = source
  45.  
  46. PlayersHarvestingCoke[_source] = false
  47.  
  48. end)
  49.  
  50. local function TransformCoke(source)
  51.  
  52. if CopsConnected < Config.RequiredCopsCoke then
  53. TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsCoke)
  54. return
  55. end
  56.  
  57. SetTimeout(10000, function()
  58.  
  59. if PlayersTransformingCoke[source] == true then
  60.  
  61. local xPlayer = ESX.GetPlayerFromId(source)
  62.  
  63. local cokeQuantity = xPlayer.getInventoryItem('coke').count
  64. local poochQuantity = xPlayer.getInventoryItem('coke_pooch').count
  65.  
  66. if poochQuantity > 300 then
  67. TriggerClientEvent('customNotification', source, _U('too_many_pouches'), 2000, true, 'error')
  68. elseif cokeQuantity < 3 then
  69. TriggerClientEvent('customNotification', source, _U('not_enough_coke'), 2000, true, 'error')
  70. else
  71. xPlayer.removeInventoryItem('coke', 3)
  72. xPlayer.addInventoryItem('coke_pooch', 1)
  73.  
  74. TransformCoke(source)
  75. end
  76.  
  77. end
  78. end)
  79. end
  80.  
  81. RegisterServerEvent('esx_drugs:startTransformCoke')
  82. AddEventHandler('esx_drugs:startTransformCoke', function()
  83.  
  84. local _source = source
  85.  
  86. PlayersTransformingCoke[_source] = true
  87.  
  88. TriggerClientEvent('customNotification', _source, _U('packing_in_prog'), 2000, true, 'success')
  89.  
  90. TransformCoke(_source)
  91.  
  92. end)
  93.  
  94. RegisterServerEvent('esx_drugs:stopTransformCoke')
  95. AddEventHandler('esx_drugs:stopTransformCoke', function()
  96.  
  97. local _source = source
  98.  
  99. PlayersTransformingCoke[_source] = false
  100.  
  101. end)
  102.  
  103. local function SellCoke(source)
  104.  
  105. if CopsConnected < Config.RequiredCopsCoke then
  106. TriggerClientEvent('customNotification', source, _U('act_imp_police') .. CopsConnected .. '/' .. Config.RequiredCopsCoke)
  107. return
  108. end
  109.  
  110. SetTimeout(7500, function()
  111.  
  112. if PlayersSellingCoke[source] == true then
  113.  
  114. local xPlayer = ESX.GetPlayerFromId(source)
  115.  
  116. local poochQuantity = xPlayer.getInventoryItem('coke_pooch').count
  117.  
  118. if poochQuantity == 0 then
  119. TriggerClientEvent('customNotification', source, _U('no_pouches_sale'), 2000, true, 'error')
  120. else
  121. xPlayer.removeInventoryItem('coke_pooch', 10)
  122. xPlayer.addAccountMoney('black_money', 1600)
  123. TriggerClientEvent('customNotification', source, _U('sold_one_coke'), 2000, true, 'success')
  124. end
  125.  
  126. SellCoke(source)
  127. end
  128.  
  129. end)
  130. end
  131.  
  132. RegisterServerEvent('esx_drugs:startSellCoke')
  133. AddEventHandler('esx_drugs:startSellCoke', function()
  134. local id = GetPlayerIdentifiers(source)[1]
  135. local result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier',
  136. {
  137. ['@identifier'] = id
  138. })
  139. local user = result[1]
  140. local _source = source
  141. local job = user['job']
  142.  
  143. PlayersSellingCoke[_source] = true
  144.  
  145. TriggerClientEvent('customNotification', _source, _U('sale_in_prog'), 2000, true, 'success')
  146.  
  147. SellCoke(_source)
  148. end)
  149.  
  150. RegisterServerEvent('esx_drugs:stopSellCoke')
  151. AddEventHandler('esx_drugs:stopSellCoke', function()
  152.  
  153. local _source = source
  154.  
  155. PlayersSellingCoke[_source] = false
  156.  
  157. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement