Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dir = { [0] = 'N', [90] = 'W', [180] = 'S', [270] = 'E', [360] = 'N'}
- local Period = "AM"
- local Hours = nil
- local Minutes = nil
- local Cruising = false
- local SeatBelt = false
- local Colours = {
- ["Blue"] = {51, 171, 240},
- ["Green"] = {88, 212, 104},
- ["LightBlue"] = {97, 217, 252},
- ["Red"] = {254, 74, 76},
- ["White"] = {255, 255, 255},
- ["Yellow"] = {250, 218, 94}
- }
- -- Settings --
- local TimeType = "American" -- "American" for 03:30 PM , "European" for 15:30
- local BarText = false
- Citizen.CreateThread(function()
- while true do
- CheckClock()
- CheckPlayerPosition()
- Citizen.Wait(1000)
- end
- end)
- -- Main --
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- local ped = PlayerPedId()
- local UI = GetMinimapAnchor()
- local HP = GetEntityHealth(ped) / 200.0
- local Armor = GetPedArmour(ped) / 100.0
- local Stamina = GetPlayerSprintStaminaRemaining(PlayerId()) / 722.0
- local Breath = GetPlayerUnderwaterTimeRemaining(PlayerId()) / 34.0
- if Armor > 1.0 then Armor = 1.0 end
- -- Backgrounds --
- DrawBack(UI.Left_x, UI.Bottom_y - 0.017, UI.Width, 0.028, 0, 0, 0, 255)
- DrawBack(UI.Left_x + 0.001 , UI.Bottom_y - 0.015, UI.Width - 0.002 , 0.009, 88, 88, 88, 200)
- DrawBack(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, UI.Width - 0.002 , 0.009, 88, 88, 88, 200)
- -- HP, Armor, Breath and Stamina --
- DrawBar(UI.Left_x + 0.001 , UI.Bottom_y - 0.015, (UI.Width -0.002) * HP , 0.009, Colours.Green, 200)
- if BarText then DrawColourText(UI.Left_x + 0.058 , UI.Bottom_y - 0.019 , 0.20, "Health", Colours.White, 200, 8) end
- if Armor > 0.05 then
- DrawBar(UI.Left_x + 0.001, UI.Bottom_y - 0.002, (UI.Width - 0.002) * Armor , 0.009, Colours.Blue, 200)
- if BarText then DrawColourText(UI.Left_x + 0.058, UI.Bottom_y - 0.007 , 0.20, "Armor", Colours.White, 200, 8) end
- elseif IsPedSwimmingUnderWater(ped) then
- DrawBar(UI.Left_x + 0.001, UI.Bottom_y - 0.002, (UI.Width - 0.002) * Breath , 0.009, Colours.LightBlue, 200)
- if BarText then DrawColourText(UI.Left_x + 0.058, UI.Bottom_y - 0.007, 0.20, "Breath", Colours.White, 200, 8) end
- elseif IsPedInAnyVehicle(ped, false) then else
- DrawBar(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) - Stamina , 0.009, Colours.Yellow, 200)
- if BarText then DrawColourText(UI.Left_x + 0.056, UI.Bottom_y - 0.007 , 0.20, "Stamina", Colours.White, 200, 8) end
- end
- if IsPedInAnyVehicle(ped, false) then
- -- Backgrounds --
- DrawBack(UI.Left_x, UI.Bottom_y - 0.215 , UI.Width, 0.038, 0, 0, 0, 55)
- DrawBack(UI.Left_x, UI.Bottom_y - 0.045 , UI.Width, 0.031, 0, 0, 0, 55)
- -- Vehicle Stuff! --
- VehicleDamage = GetVehicleEngineHealth(GetVehiclePedIsIn(ped)) / 1000
- if SeatBelt then
- DrawColourText(UI.Left_x + 0.060 , UI.Bottom_y - 0.045, 0.4, "BELT", Colours.Yellow, 255, 4)
- DisableControlAction(0, 75, true)
- DisableControlAction(27, 75, true)
- end
- local speed = math.floor(GetEntitySpeed(GetVehiclePedIsIn(ped, false)) * 2.236936)
- DisplayRadar(true) -- Activates minimap
- if VehicleDamage > 0.0 then
- DrawBar(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) * VehicleDamage , 0.009, Colours.Red, 200)
- if BarText then DrawColourText(UI.Left_x + 0.047 , UI.Bottom_y - 0.007 , 0.20, "Engine Health", Colours.White, 200, 8) end
- else
- DrawColourText(UI.Left_x + 0.046 , UI.Bottom_y - 0.007 , 0.20, "Engine Critical", Colours.Red, 150, 8)
- end
- if TimeType == "American" then -- Time positioning
- DrawColourText(UI.Left_x + 0.103, UI.Bottom_y - 0.045, 0.4, Hours .. ":" .. Minutes .. " " .. Period, Colours.White, 255, 4)
- elseif TimeType == "European" then
- DrawColourText(UI.Left_x + 0.119, UI.Bottom_y - 0.045, 0.4, Hours .. ":" .. Minutes .. " " .. Period, Colours.White, 255, 4)
- end
- DrawColourText(UI.Left_x + 0.003 , UI.Bottom_y - 0.217, 0.55, heading, Colours.Yellow, 255, 8) -- Heading
- DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.216, 0.3, GetStreetNameFromHashKey(rua), Colours.White, 255, 8) -- Street
- DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.199, 0.25, Zone, Colours.White, 255, 8) -- Area
- if not Cruising then
- DrawColourText(UI.Left_x + 0.003 , UI.Bottom_y - 0.045, 0.4, speed .. " MPH", Colours.White, 255, 4) -- Speed
- else
- DrawColourText(UI.Left_x + 0.003 , UI.Bottom_y - 0.045, 0.4, speed .. " MPH", Colours.Yellow, 255, 4)
- end
- else
- DisplayRadar(false) -- Deactivates minimap
- DrawBack(UI.Left_x, UI.Bottom_y - 0.088 , UI.Width, 0.073, 0, 0, 0, 55) -- Background
- DrawColourText(UI.Left_x + 0.001 , UI.Bottom_y - 0.09 , 0.55, Hours .. ":" .. Minutes .. " " .. Period, Colours.White, 255, 8) -- Clock
- DrawColourText(UI.Left_x + 0.002 , UI.Bottom_y - 0.059 , 0.58, heading, Colours.Yellow, 255, 8) -- Heading
- DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.057 , 0.3, GetStreetNameFromHashKey(rua), Colours.White, 255, 8) -- Street
- DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.04 , 0.25, Zone, Colours.White, 255, 8) -- Area
- end
- end
- end)
- -- Seatbelt / CruiseControl --
- Citizen.CreateThread(function()
- local ResetTop = true
- while true do
- Citizen.Wait(1)
- local playerPed = PlayerPedId()
- if IsPedInAnyVehicle(playerPed, false) then
- local vehicle = GetVehiclePedIsIn(playerPed,false)
- if GetPedInVehicleSeat(vehicle, -1) == playerPed then
- if ResetTop then
- CurrentMaxSpeed = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel")
- SetEntityMaxSpeed(vehicle, CurrentMaxSpeed)
- ResetTop = false
- end
- if IsControlJustReleased(0,29) then
- if not SeatBelt then
- PlaySound(-1, "NAV", "HUD_AMMO_SHOP_SOUNDSET", 0, 0, 1)
- Wait(500)
- SeatBelt = true
- else
- PlaySound(-1, "NAV", "HUD_AMMO_SHOP_SOUNDSET", 0, 0, 1)
- Wait(500)
- SeatBelt = false
- end
- end
- if IsControlJustReleased(0,246) and Cruising then
- Cruising = false
- CurrentMaxSpeed = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel")
- SetEntityMaxSpeed(vehicle, CurrentMaxSpeed)
- elseif IsControlJustReleased(0,246) and not Cruising then
- CruiseSpeed = GetEntitySpeed(vehicle)
- if CruiseSpeed > 11.0 then
- Cruising = true
- SetEntityMaxSpeed(vehicle, CruiseSpeed)
- CruiseSpeed = math.floor(CruiseSpeed * 2.23694 + 0.5)
- end
- end
- else
- SeatBelt = false
- ResetTop = true
- end
- end
- end
- end)
- function CheckClock()
- Hours = GetClockHours()
- if TimeType == "American" then
- if Hours > 12 then
- Hours = Hours - 12
- Period = "PM"
- else
- Period = "AM"
- end
- elseif TimeType == "European" then
- Period = ""
- else
- Period = ""
- end
- if Hours < 10 then Hours = "0" .. Hours end
- Minutes = GetClockMinutes()
- if Minutes < 10 then Minutes = "0" .. Minutes end
- for k,v in pairs(dir)do
- heading = GetEntityHeading(ped)
- if(math.abs(heading - k) < 45)then
- heading = v
- break
- end
- end
- end
- function CheckPlayerPosition()
- pos = GetEntityCoords(ped)
- rua, cross = GetStreetNameAtCoord(pos.x, pos.y, pos.z)
- Zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z))
- end
- function DrawBack(x,y,Width,height,r,g,b,a)
- DrawRect(x+Width/2,y+height/2,Width,height,r,g,b,a)
- end
- function DrawBar(x,y,Width,height,colour,a)
- DrawRect(x+Width/2,y+height/2,Width,height,colour[1],colour[2],colour[3],a)
- end
- function DrawColourText(x,y,scale,text,colour,a,font)
- SetTextFont(font)
- SetTextScale(scale,scale)
- SetTextColour(colour[1],colour[2],colour[3],a)
- SetTextOutline()
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x,y)
- end
- function disableHud()
- HideHudComponentThisFrame(6)
- HideHudComponentThisFrame(7)
- HideHudComponentThisFrame(8)
- HideHudComponentThisFrame(9)
- end
- function GetMinimapAnchor()
- local safezone = GetSafeZoneSize()
- local safezone_x = 1.0 / 20.0
- local safezone_y = 1.0 / 20.0
- local aspect_ratio = GetAspectRatio(0)
- local res_x, res_y = GetActiveScreenResolution()
- local xscale = 1.0 / res_x
- local yscale = 1.0 / res_y
- local Minimap = {}
- Minimap.Width = xscale * (res_x / (4 * aspect_ratio))
- Minimap.height = yscale * (res_y / 5.674)
- Minimap.Left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
- Minimap.Bottom_y = 1.0 - yscale * (res_y * (safezone_y * ((math.abs(safezone - 1.0)) * 10)))
- Minimap.right_x = Minimap.Left_x + Minimap.Width
- Minimap.top_y = Minimap.Bottom_y - Minimap.height
- Minimap.x = Minimap.Left_x
- Minimap.y = Minimap.top_y
- Minimap.xunit = xscale
- Minimap.yunit = yscale
- return Minimap
- end
- function showHelpNotification(msg)
- BeginTextCommandDisplayHelp("STRING")
- AddTextComponentSubstringPlayerName(msg)
- EndTextCommandDisplayHelp(0, 0, 1, -1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement