Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.40 KB | None | 0 0
  1. local Keys = {
  2.     ["ESC"] = 322, ["BACKSPACE"] = 177, ["E"] = 38, ["ENTER"] = 18, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173
  3. }
  4.  
  5. local menuIsShowed = false
  6. local hasAlreadyEnteredMarker = false
  7. local isInMarker = false
  8.  
  9. ESX = nil
  10.  
  11. Citizen.CreateThread(function()
  12.     while ESX == nil do
  13.         TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  14.         Citizen.Wait(0)
  15.     end
  16. end)
  17. --Text for Progress Bar
  18. function drawHelpTxt(x,y ,width,height,scale, text, r,g,b,a,font)
  19.     SetTextFont(font)
  20.     SetTextProportional(0)
  21.     SetTextScale(scale, scale)
  22.     SetTextColour(r, g, b, a)
  23.     SetTextDropShadow(0, 0, 0, 0,255)
  24.     SetTextEdge(1, 0, 0, 0, 255)
  25.     SetTextDropShadow()
  26.     SetTextOutline()
  27.     SetTextEntry("STRING")
  28.     AddTextComponentString(text)
  29.     DrawText(x - width/2, y - height/2 + 0.005)
  30. end
  31. --Interactive Progress Bar
  32. function DrawTimerBar(startT, endT, r, g, b)
  33.     local value = math.floor(((startT + endT) - GetGameTimer())*0.001)
  34.     local maxvalue = math.floor(endT*0.001)
  35.     local width = 0.2
  36.     local height = 0.025
  37.     local xvalue = 0.38
  38.     local yvalue = 0.05
  39.     local outlinecolour = {0, 0, 0, 150}
  40.     local barcolour = {r, g, b}
  41.     local minutes = math.floor(value/60)
  42.     local time = ""..minutes.." minutes and "..math.floor(value - (minutes*60)).." seconds"
  43.     DrawRect(xvalue + (width/2), yvalue, width + 0.004, height + 0.006705, outlinecolour[1], outlinecolour[2], outlinecolour[3], outlinecolour[4]) -- Box that creates outline
  44.     drawHelpTxt(xvalue + (((maxvalue/2)/((maxvalue/2)/width))/2), yvalue + 0.0275, 0.1, 0.1, 0.5, time, 255, 255, 255, 255, 6) -- Text display of timer
  45.     DrawRect(xvalue + (width/2), yvalue, width, height, barcolour[1], barcolour[2], barcolour[3], 75) --  Static full bar
  46.     DrawRect(xvalue + ((value/(maxvalue/width))/2), yvalue, value/(maxvalue/width), height, barcolour[1], barcolour[2], barcolour[3], 255) -- Moveable Bar  
  47. end
  48.  
  49. --Initiate Brewing
  50. function BrewMoonshine()
  51.     local startT = GetGameTimer()
  52.     local endT = GetGameTimer() + Config.BrewTime
  53.     local r = 242
  54.     local g = 142
  55.     local b = 28
  56.     DrawTimerBar(startT, endT, r, g, b)
  57. end
  58.  
  59. AddEventHandler('chill_moonshine:hasExitedMarker', function(zone)
  60.     --ESX.UI.Menu.CloseAll()
  61. end)
  62.  
  63. -- Activate menu when player is inside marker, and draw markers
  64. Citizen.CreateThread(function()
  65.     while true do
  66.         Citizen.Wait(1)
  67.  
  68.         local coords = GetEntityCoords(PlayerPedId())
  69.         isInMarker = false
  70.  
  71.         for i=1, #Config.Zones, 1 do
  72.             local distance = GetDistanceBetweenCoords(coords, Config.Zones[i], true)
  73.  
  74.             if distance < Config.DrawDistance then
  75.                 DrawMarker(Config.MarkerType, Config.Zones[i], 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)
  76.             end
  77.  
  78.             if distance < (Config.ZoneSize.x + 0.5) then
  79.                 isInMarker = true
  80.                 ESX.ShowHelpNotification(_U('brew_moonshine'))
  81.             end
  82.         end
  83.  
  84.         if isInMarker and not hasAlreadyEnteredMarker then
  85.             hasAlreadyEnteredMarker = true
  86.         end
  87.  
  88.         if not isInMarker and hasAlreadyEnteredMarker then
  89.             hasAlreadyEnteredMarker = false
  90.             TriggerEvent('chill_moonshine:hasExitedMarker')
  91.         end
  92.     end
  93. end)
  94.  
  95.  
  96. -- Menu Controls
  97. Citizen.CreateThread(function()
  98.     while true do
  99.         Citizen.Wait(0)
  100.  
  101.         if IsControlJustReleased(0, Keys['E']) and isInMarker and not menuIsShowed then
  102.             --ESX.UI.Menu.CloseAll()
  103.             BrewMoonshine()
  104.         end
  105.     end
  106. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement