Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Keys = {
- ["ESC"] = 322, ["BACKSPACE"] = 177, ["E"] = 38, ["ENTER"] = 18, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173
- }
- local menuIsShowed = false
- local hasAlreadyEnteredMarker = false
- local isInMarker = false
- ESX = nil
- Citizen.CreateThread(function()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(0)
- end
- end)
- --Text for Progress Bar
- function drawHelpTxt(x,y ,width,height,scale, text, r,g,b,a,font)
- SetTextFont(font)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(1, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x - width/2, y - height/2 + 0.005)
- end
- --Interactive Progress Bar
- function DrawTimerBar(startT, endT, r, g, b)
- local value = math.floor(((startT + endT) - GetGameTimer())*0.001)
- local maxvalue = math.floor(endT*0.001)
- local width = 0.2
- local height = 0.025
- local xvalue = 0.38
- local yvalue = 0.05
- local outlinecolour = {0, 0, 0, 150}
- local barcolour = {r, g, b}
- local minutes = math.floor(value/60)
- local time = ""..minutes.." minutes and "..math.floor(value - (minutes*60)).." seconds"
- DrawRect(xvalue + (width/2), yvalue, width + 0.004, height + 0.006705, outlinecolour[1], outlinecolour[2], outlinecolour[3], outlinecolour[4]) -- Box that creates outline
- 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
- DrawRect(xvalue + (width/2), yvalue, width, height, barcolour[1], barcolour[2], barcolour[3], 75) -- Static full bar
- DrawRect(xvalue + ((value/(maxvalue/width))/2), yvalue, value/(maxvalue/width), height, barcolour[1], barcolour[2], barcolour[3], 255) -- Moveable Bar
- end
- --Initiate Brewing
- function BrewMoonshine()
- local startT = GetGameTimer()
- local endT = GetGameTimer() + Config.BrewTime
- local r = 242
- local g = 142
- local b = 28
- DrawTimerBar(startT, endT, r, g, b)
- end
- AddEventHandler('chill_moonshine:hasExitedMarker', function(zone)
- --ESX.UI.Menu.CloseAll()
- end)
- -- Activate menu when player is inside marker, and draw markers
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- local coords = GetEntityCoords(PlayerPedId())
- isInMarker = false
- for i=1, #Config.Zones, 1 do
- local distance = GetDistanceBetweenCoords(coords, Config.Zones[i], true)
- if distance < Config.DrawDistance then
- 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)
- end
- if distance < (Config.ZoneSize.x + 0.5) then
- isInMarker = true
- ESX.ShowHelpNotification(_U('brew_moonshine'))
- end
- end
- if isInMarker and not hasAlreadyEnteredMarker then
- hasAlreadyEnteredMarker = true
- end
- if not isInMarker and hasAlreadyEnteredMarker then
- hasAlreadyEnteredMarker = false
- TriggerEvent('chill_moonshine:hasExitedMarker')
- end
- end
- end)
- -- Menu Controls
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if IsControlJustReleased(0, Keys['E']) and isInMarker and not menuIsShowed then
- --ESX.UI.Menu.CloseAll()
- BrewMoonshine()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement