Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.15 KB | None | 0 0
  1. local Keys = {
  2. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12.  
  13. local PID = 0
  14. local GUI = {}
  15. local cokeQTE = 0
  16. ESX = nil
  17. GUI.Time = 0
  18. local coke_poochQTE = 0
  19. local weedQTE = 0
  20. local weed_poochQTE = 0
  21. local methQTE = 0
  22. local meth_poochQTE = 0
  23. local opiumQTE = 0
  24. local opium_poochQTE = 0
  25. local myJob = nil
  26. local PlayerData = {}
  27. local GUI = {}
  28. local HasAlreadyEnteredMarker = false
  29. local LastZone = nil
  30. local CurrentAction = nil
  31. local CurrentActionMsg = ''
  32. local CurrentActionData = {}
  33.  
  34. Citizen.CreateThread(function()
  35. while ESX == nil do
  36. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  37. Citizen.Wait(0)
  38. end
  39. end)
  40.  
  41. AddEventHandler('esx_drugs:hasEnteredMarker', function(zone)
  42.  
  43. ESX.UI.Menu.CloseAll()
  44.  
  45. --coke
  46. if zone == 'CokeFarm' then
  47. if myJob ~= "police" then
  48. CurrentAction = 'coke_harvest'
  49. CurrentActionMsg = _U('press_collect_coke')
  50. CurrentActionData = {}
  51. end
  52. end
  53.  
  54. if zone == 'CokeTreatment' then
  55. if myJob ~= "police" then
  56. if cokeQTE >= 5 then
  57. CurrentAction = 'coke_treatment'
  58. CurrentActionMsg = _U('press_process_coke')
  59. CurrentActionData = {}
  60. end
  61. end
  62. end
  63.  
  64. if zone == 'CokeResell' then
  65. if myJob ~= "police" then
  66. if coke_poochQTE >= 1 then
  67. CurrentAction = 'coke_resell'
  68. CurrentActionMsg = _U('press_sell_coke')
  69. CurrentActionData = {}
  70. end
  71. end
  72. end
  73.  
  74. --meth
  75. if zone == 'MethFarm' then
  76. if myJob ~= "police" then
  77. CurrentAction = 'meth_harvest'
  78. CurrentActionMsg = _U('press_collect_meth')
  79. CurrentActionData = {}
  80. end
  81. end
  82.  
  83. if zone == 'MethTreatment' then
  84. if myJob ~= "police" then
  85. if methQTE >= 5 then
  86. CurrentAction = 'meth_treatment'
  87. CurrentActionMsg = _U('press_process_meth')
  88. CurrentActionData = {}
  89. end
  90. end
  91. end
  92.  
  93. if zone == 'MethResell' then
  94. if myJob ~= "police" then
  95. if meth_poochQTE >= 1 then
  96. CurrentAction = 'meth_resell'
  97. CurrentActionMsg = _U('press_sell_meth')
  98. CurrentActionData = {}
  99. end
  100. end
  101. end
  102.  
  103. --weed
  104. if zone == 'WeedFarm' then
  105. if myJob ~= "police" then
  106. CurrentAction = 'weed_harvest'
  107. CurrentActionMsg = _U('press_collect_weed')
  108. CurrentActionData = {}
  109. end
  110. end
  111.  
  112. if zone == 'WeedTreatment' then
  113. if myJob ~= "police" then
  114. if weedQTE >= 5 then
  115. CurrentAction = 'weed_treatment'
  116. CurrentActionMsg = _U('press_process_weed')
  117. CurrentActionData = {}
  118. end
  119. end
  120. end
  121.  
  122. if zone == 'WeedResell' then
  123. if myJob ~= "police" then
  124. if weed_poochQTE >= 1 then
  125. CurrentAction = 'weed_resell'
  126. CurrentActionMsg = _U('press_sell_weed')
  127. CurrentActionData = {}
  128. end
  129. end
  130. end
  131.  
  132. --opium
  133. if zone == 'OpiumFarm' then
  134. if myJob ~= "police" then
  135. CurrentAction = 'opium_harvest'
  136. CurrentActionMsg = _U('press_collect_opium')
  137. CurrentActionData = {}
  138. end
  139. end
  140.  
  141. if zone == 'OpiumTreatment' then
  142. if myJob ~= "police" then
  143. if opiumQTE >= 5 then
  144. CurrentAction = 'opium_treatment'
  145. CurrentActionMsg = _U('press_process_opium')
  146. CurrentActionData = {}
  147. end
  148. end
  149. end
  150.  
  151. if zone == 'OpiumResell' then
  152. if myJob ~= "police" then
  153. if opium_poochQTE >= 1 then
  154. CurrentAction = 'opium_resell'
  155. CurrentActionMsg = _U('press_sell_opium')
  156. CurrentActionData = {}
  157. end
  158. end
  159. end
  160. end)
  161.  
  162. AddEventHandler('esx_drugs:hasExitedMarker', function(zone)
  163.  
  164. CurrentAction = nil
  165. ESX.UI.Menu.CloseAll()
  166.  
  167. TriggerServerEvent('esx_drugs:stopHarvestCoke')
  168. TriggerServerEvent('esx_drugs:stopTransformCoke')
  169. TriggerServerEvent('esx_drugs:stopSellCoke')
  170. TriggerServerEvent('esx_drugs:stopHarvestMeth')
  171. TriggerServerEvent('esx_drugs:stopTransformMeth')
  172. TriggerServerEvent('esx_drugs:stopSellMeth')
  173. TriggerServerEvent('esx_drugs:stopHarvestWeed')
  174. TriggerServerEvent('esx_drugs:stopTransformWeed')
  175. TriggerServerEvent('esx_drugs:stopSellWeed')
  176. TriggerServerEvent('esx_drugs:stopHarvestOpium')
  177. TriggerServerEvent('esx_drugs:stopTransformOpium')
  178. TriggerServerEvent('esx_drugs:stopSellOpium')
  179. end)
  180.  
  181. -- Weed Effect
  182. RegisterNetEvent('esx_drugs:onPot')
  183. AddEventHandler('esx_drugs:onPot', function()
  184. RequestAnimSet("MOVE_M@DRUNK@SLIGHTLYDRUNK")
  185. while not HasAnimSetLoaded("MOVE_M@DRUNK@SLIGHTLYDRUNK") do
  186. Citizen.Wait(0)
  187. end
  188. TaskStartScenarioInPlace(GetPlayerPed(-1), "WORLD_HUMAN_SMOKING_POT", 0, true)
  189. Citizen.Wait(5000)
  190. DoScreenFadeOut(1000)
  191. Citizen.Wait(1000)
  192. ClearPedTasksImmediately(GetPlayerPed(-1))
  193. SetTimecycleModifier("spectator5")
  194. SetPedMotionBlur(GetPlayerPed(-1), true)
  195. SetPedMovementClipset(GetPlayerPed(-1), "MOVE_M@DRUNK@SLIGHTLYDRUNK", true)
  196. SetPedIsDrunk(GetPlayerPed(-1), true)
  197. DoScreenFadeIn(1000)
  198. Citizen.Wait(600000)
  199. DoScreenFadeOut(1000)
  200. Citizen.Wait(1000)
  201. DoScreenFadeIn(1000)
  202. ClearTimecycleModifier()
  203. ResetScenarioTypesEnabled()
  204. ResetPedMovementClipset(GetPlayerPed(-1), 0)
  205. SetPedIsDrunk(GetPlayerPed(-1), false)
  206. SetPedMotionBlur(GetPlayerPed(-1), false)
  207. end)
  208.  
  209. -- Create Blips
  210. Citizen.CreateThread(function()
  211.  
  212. for i=1, #Config.Map, 1 do
  213.  
  214. local blip = AddBlipForCoord(Config.Map[i].x, Config.Map[i].y, Config.Map[i].z)
  215. SetBlipSprite (blip, Config.Map[i].id)
  216. SetBlipDisplay(blip, 4)
  217. SetBlipColour (blip, Config.Map[i].color)
  218. SetBlipScale (blip, Config.Map[i].scale)
  219. SetBlipAsShortRange(blip, true)
  220.  
  221. BeginTextCommandSetBlipName("STRING")
  222. AddTextComponentString(Config.Map[i].name)
  223. EndTextCommandSetBlipName(blip)
  224. end
  225.  
  226. end)
  227.  
  228. -- Render markers
  229. Citizen.CreateThread(function()
  230. while true do
  231.  
  232. Wait(0)
  233.  
  234. local coords = GetEntityCoords(GetPlayerPed(-1))
  235.  
  236. for k,v in pairs(Config.Zones) do
  237. if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.DrawDistance) then
  238. DrawMarker(Config.MarkerType, v.x, v.y, v.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ZoneSize.x, Config.ZoneSize.y, Config.ZoneSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
  239. end
  240. end
  241.  
  242. end
  243. end)
  244.  
  245. -- RETURN NUMBER OF ITEMS FROM SERVER
  246. RegisterNetEvent('esx_drugs:ReturnInventory')
  247. AddEventHandler('esx_drugs:ReturnInventory', function(cokeNbr, cokepNbr, methNbr, methpNbr, weedNbr, weedpNbr, opiumNbr, opiumpNbr, jobName, currentZone)
  248. cokeQTE = cokeNbr
  249. coke_poochQTE = cokepNbr
  250. methQTE = methNbr
  251. meth_poochQTE = methpNbr
  252. weedQTE = weedNbr
  253. weed_poochQTE = weedpNbr
  254. opiumQTE = opiumNbr
  255. opium_poochQTE = opiumpNbr
  256. myJob = jobName
  257. TriggerEvent('esx_drugs:hasEnteredMarker', currentZone)
  258. end)
  259.  
  260. -- Activate menu when player is inside marker
  261. Citizen.CreateThread(function()
  262. while true do
  263.  
  264. Wait(0)
  265.  
  266. local coords = GetEntityCoords(GetPlayerPed(-1))
  267. local isInMarker = false
  268. local currentZone = nil
  269.  
  270. for k,v in pairs(Config.Zones) do
  271. if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.ZoneSize.x / 2) then
  272. isInMarker = true
  273. currentZone = k
  274. end
  275. end
  276.  
  277. if isInMarker and not hasAlreadyEnteredMarker then
  278. hasAlreadyEnteredMarker = true
  279. lastZone = currentZone
  280. TriggerServerEvent('esx_drugs:GetUserInventory', currentZone)
  281. end
  282.  
  283. if not isInMarker and hasAlreadyEnteredMarker then
  284. hasAlreadyEnteredMarker = false
  285. TriggerEvent('esx_drugs:hasExitedMarker', lastZone)
  286. end
  287.  
  288. end
  289. end)
  290.  
  291. -- Key Controls
  292. Citizen.CreateThread(function()
  293. while true do
  294. Citizen.Wait(0)
  295. if CurrentAction ~= nil then
  296. SetTextComponentFormat('STRING')
  297. AddTextComponentString(CurrentActionMsg)
  298. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  299. if IsControlJustReleased(0, 38) then
  300. if CurrentAction == 'coke_harvest' then
  301. TriggerServerEvent('esx_drugs:startHarvestCoke')
  302. end
  303. if CurrentAction == 'coke_treatment' then
  304. TriggerServerEvent('esx_drugs:startTransformCoke')
  305. end
  306. if CurrentAction == 'coke_resell' then
  307. TriggerServerEvent('esx_drugs:startSellCoke')
  308. end
  309. if CurrentAction == 'meth_harvest' then
  310. TriggerServerEvent('esx_drugs:startHarvestMeth')
  311. end
  312. if CurrentAction == 'meth_treatment' then
  313. TriggerServerEvent('esx_drugs:startTransformMeth')
  314. end
  315. if CurrentAction == 'meth_resell' then
  316. TriggerServerEvent('esx_drugs:startSellMeth')
  317. end
  318. if CurrentAction == 'weed_harvest' then
  319. TriggerServerEvent('esx_drugs:startHarvestWeed')
  320. end
  321. if CurrentAction == 'weed_treatment' then
  322. TriggerServerEvent('esx_drugs:startTransformWeed')
  323. end
  324. if CurrentAction == 'weed_resell' then
  325. TriggerServerEvent('esx_drugs:startSellWeed')
  326. end
  327. if CurrentAction == 'opium_harvest' then
  328. TriggerServerEvent('esx_drugs:startHarvestOpium')
  329. end
  330. if CurrentAction == 'opium_treatment' then
  331. TriggerServerEvent('esx_drugs:startTransformOpium')
  332. end
  333. if CurrentAction == 'opium_resell' then
  334. TriggerServerEvent('esx_drugs:startSellOpium')
  335. end
  336. CurrentAction = nil
  337. end
  338. end
  339. end
  340. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement