Facebook
From sasa, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 482
  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. -- Create Blips
  182. Citizen.CreateThread(function()
  183.  
  184.   local blip = AddBlipForCoord(Config.Zones.WeedFarm.x, Config.Zones.WeedFarm.y, Config.Zones.WeedFarm.z)
  185.  
  186.   SetBlipSprite (blip, 140)
  187.   SetBlipDisplay(blip, 4)
  188.   SetBlipScale  (blip, 1.0)
  189.   SetBlipColour (blip, 49)
  190.   SetBlipAsShortRange(blip, true)
  191.  
  192.   BeginTextCommandSetBlipName("STRING")
  193.   AddTextComponentString("Ziolo")
  194.   EndTextCommandSetBlipName(blip)
  195.  
  196. end)
  197. -- Create Blips
  198. Citizen.CreateThread(function()
  199.  
  200.   local blip = AddBlipForCoord(Config.Zones.WeedTreatment.x, Config.Zones.WeedTreatment.y, Config.Zones.WeedTreatment.z)
  201.  
  202.   SetBlipSprite (blip, 140)
  203.   SetBlipDisplay(blip, 4)
  204.   SetBlipScale  (blip, 1.0)
  205.   SetBlipColour (blip, 49)
  206.   SetBlipAsShortRange(blip, true)
  207.  
  208.   BeginTextCommandSetBlipName("STRING")
  209.   AddTextComponentString("Przerabianie")
  210.   EndTextCommandSetBlipName(blip)
  211.  
  212. end)
  213. -- Create Blips
  214. Citizen.CreateThread(function()
  215.  
  216.   local blip = AddBlipForCoord(Config.Zones.WeedResell.x, Config.Zones.WeedResell.y, Config.Zones.WeedResell.z)
  217.  
  218.   SetBlipSprite (blip, 140)
  219.   SetBlipDisplay(blip, 4)
  220.   SetBlipScale  (blip, 0.9)
  221.   SetBlipColour (blip, 49)
  222.   SetBlipAsShortRange(blip, true)
  223.  
  224.   BeginTextCommandSetBlipName("STRING")
  225.   AddTextComponentString("Sprzedaz")
  226.   EndTextCommandSetBlipName(blip)
  227.  
  228. end)
  229.  
  230.  
  231. -- Weed Effect
  232. RegisterNetEvent('esx_drugs:onPot')
  233. AddEventHandler('esx_drugs:onPot', function()
  234.     RequestAnimSet("MOVE_M@DRUNK@SLIGHTLYDRUNK")
  235.     while not HasAnimSetLoaded("MOVE_M@DRUNK@SLIGHTLYDRUNK") do
  236.         Citizen.Wait(0)
  237.     end
  238.     TaskStartScenarioInPlace(GetPlayerPed(-1), "WORLD_HUMAN_SMOKING_POT", 0, true)
  239.     Citizen.Wait(5000)
  240.     DoScreenFadeOut(1000)
  241.     Citizen.Wait(1000)
  242.     ClearPedTasksImmediately(GetPlayerPed(-1))
  243.     SetTimecycleModifier("spectator5")
  244.     SetPedMotionBlur(GetPlayerPed(-1), true)
  245.     SetPedMovementClipset(GetPlayerPed(-1), "MOVE_M@DRUNK@SLIGHTLYDRUNK", true)
  246.     SetPedIsDrunk(GetPlayerPed(-1), true)
  247.     DoScreenFadeIn(1000)
  248.     Citizen.Wait(600000)
  249.     DoScreenFadeOut(1000)
  250.     Citizen.Wait(1000)
  251.     DoScreenFadeIn(1000)
  252.     ClearTimecycleModifier()
  253.     ResetScenarioTypesEnabled()
  254.     ResetPedMovementClipset(GetPlayerPed(-1), 0)
  255.     SetPedIsDrunk(GetPlayerPed(-1), false)
  256.     SetPedMotionBlur(GetPlayerPed(-1), false)
  257. end)
  258. -- Coke Effect
  259. RegisterNetEvent('esx_drugs:onCoke')
  260. AddEventHandler('esx_drugs:onCoke', function()
  261.     RequestAnimSet("MOVE_M@DRUNK@SLIGHTLYDRUNK")
  262.     while not HasAnimSetLoaded("MOVE_M@DRUNK@SLIGHTLYDRUNK") do
  263.         Citizen.Wait(0)
  264.     end
  265.     TaskStartScenarioInPlace(GetPlayerPed(-1), "WORLD_HUMAN_SMOKING_POT", 0, true)
  266.     Citizen.Wait(5000)
  267.     DoScreenFadeOut(1000)
  268.     Citizen.Wait(1000)
  269.     ClearPedTasksImmediately(GetPlayerPed(-1))
  270.     SetTimecycleModifier("spectator5")
  271.     SetPedMotionBlur(GetPlayerPed(-1), true)
  272.     SetPedMovementClipset(GetPlayerPed(-1), "MOVE_M@DRUNK@SLIGHTLYDRUNK", true)
  273.     SetPedIsDrunk(GetPlayerPed(-1), true)
  274.     DoScreenFadeIn(1000)
  275.     Citizen.Wait(360000)
  276.     DoScreenFadeOut(1000)
  277.     Citizen.Wait(1000)
  278.     DoScreenFadeIn(1000)
  279.     ClearTimecycleModifier()
  280.     ResetScenarioTypesEnabled()
  281.     ResetPedMovementClipset(GetPlayerPed(-1), 0)
  282.     SetPedIsDrunk(GetPlayerPed(-1), false)
  283.     SetPedMotionBlur(GetPlayerPed(-1), false)
  284.     SetPedArmour(GetPlayerPed(-1), 100)
  285. end)
  286.  
  287. -- Render markers
  288. Citizen.CreateThread(function()
  289.     while true do
  290.  
  291.         Wait(0)
  292.  
  293.         local coords = GetEntityCoords(GetPlayerPed(-1))
  294.  
  295.         for k,v in pairs(Config.Zones) do
  296.             if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.DrawDistance) then
  297.                 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)
  298.             end
  299.         end
  300.  
  301.     end
  302. end)
  303.  
  304. -- RETURN NUMBER OF ITEMS FROM SERVER
  305. RegisterNetEvent('esx_drugs:ReturnInventory')
  306. AddEventHandler('esx_drugs:ReturnInventory', function(cokeNbr, cokepNbr, methNbr, methpNbr, weedNbr, weedpNbr, opiumNbr, opiumpNbr, jobName, currentZone)
  307.     cokeQTE       = cokeNbr
  308.     coke_poochQTE = cokepNbr
  309.     methQTE       = methNbr
  310.     meth_poochQTE = methpNbr
  311.     weedQTE       = weedNbr
  312.     weed_poochQTE = weedpNbr
  313.     opiumQTE       = opiumNbr
  314.     opium_poochQTE = opiumpNbr
  315.     myJob         = jobName
  316.     TriggerEvent('esx_drugs:hasEnteredMarker', currentZone)
  317. end)
  318.  
  319. -- Activate menu when player is inside marker
  320. Citizen.CreateThread(function()
  321.     while true do
  322.  
  323.         Wait(0)
  324.  
  325.         local coords      = GetEntityCoords(GetPlayerPed(-1))
  326.         local isInMarker  = false
  327.         local currentZone = nil
  328.  
  329.         for k,v in pairs(Config.Zones) do
  330.             if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.ZoneSize.x / 2) then
  331.                 isInMarker  = true
  332.                 currentZone = k
  333.             end
  334.         end
  335.  
  336.         if isInMarker and not hasAlreadyEnteredMarker then
  337.             hasAlreadyEnteredMarker = true
  338.             lastZone                = currentZone
  339.             TriggerServerEvent('esx_drugs:GetUserInventory', currentZone)
  340.         end
  341.  
  342.         if not isInMarker and hasAlreadyEnteredMarker then
  343.             hasAlreadyEnteredMarker = false
  344.             TriggerEvent('esx_drugs:hasExitedMarker', lastZone)
  345.         end
  346.  
  347.     end
  348. end)
  349.  
  350. -- Key Controls
  351. Citizen.CreateThread(function()
  352.     while true do
  353.         Citizen.Wait(0)
  354.         if CurrentAction ~= nil then
  355.             SetTextComponentFormat('STRING')
  356.             AddTextComponentString(CurrentActionMsg)
  357.             DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  358.             if IsControlJustReleased(0, 38) then
  359.                 if CurrentAction == 'coke_harvest' then
  360.                     TriggerServerEvent('esx_drugs:startHarvestCoke')
  361.                 end
  362.                 if CurrentAction == 'coke_treatment' then
  363.                     TriggerServerEvent('esx_drugs:startTransformCoke')
  364.                 end
  365.                 if CurrentAction == 'coke_resell' then
  366.                     TriggerServerEvent('esx_drugs:startSellCoke')
  367.                 end
  368.                 if CurrentAction == 'meth_harvest' then
  369.                     TriggerServerEvent('esx_drugs:startHarvestMeth')
  370.                 end
  371.                 if CurrentAction == 'meth_treatment' then
  372.                     TriggerServerEvent('esx_drugs:startTransformMeth')
  373.                 end
  374.                 if CurrentAction == 'meth_resell' then
  375.                     TriggerServerEvent('esx_drugs:startSellMeth')
  376.                 end
  377.                 if CurrentAction == 'weed_harvest' then
  378.                     TriggerServerEvent('esx_drugs:startHarvestWeed')
  379.                 end
  380.                 if CurrentAction == 'weed_treatment' then
  381.                     TriggerServerEvent('esx_drugs:startTransformWeed')
  382.                 end
  383.                 if CurrentAction == 'weed_resell' then
  384.                     TriggerServerEvent('esx_drugs:startSellWeed')
  385.                 end
  386.                 if CurrentAction == 'opium_harvest' then
  387.                     TriggerServerEvent('esx_drugs:startHarvestOpium')
  388.                 end
  389.                 if CurrentAction == 'opium_treatment' then
  390.                     TriggerServerEvent('esx_drugs:startTransformOpium')
  391.                 end
  392.                 if CurrentAction == 'opium_resell' then
  393.                     TriggerServerEvent('esx_drugs:startSellOpium')
  394.                 end
  395.                 CurrentAction = nil
  396.             end
  397.         end
  398.     end
  399. end)
  400.