Code:
local ExtraHUD = {}
local extrahudx = 0.156
local extrahudy = 0.930
function ExtraHUD.tick()
playerPed = PLAYER.PLAYER_PED_ID()
player = PLAYER.GET_PLAYER_PED(playerPed)
if ((PLAYER.IS_PLAYER_DEAD(player) == false) and (CUTSCENE.IS_CUTSCENE_PLAYING() == false)) then
UI.DISPLAY_CASH(true)
UI.DISPLAY_AMMO_THIS_FRAME(true)
ExtraHUD.ShowTime()
ExtraHUD.ShowDate()
ExtraHUD.ShowDayName()
ExtraHUD.ShowExtras()
end
end
function ExtraHUD.DrawText(text, x, y, scale)
UI.SET_TEXT_FONT(1)
UI.SET_TEXT_SCALE(scale, scale)
UI.SET_TEXT_COLOUR(255, 255, 255, 255)
UI.SET_TEXT_WRAP(0.0, 1.0)
UI.SET_TEXT_CENTRE(false)
UI.SET_TEXT_DROPSHADOW(2, 2, 0, 0, 0)
UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)
UI._SET_TEXT_ENTRY("STRING")
UI._ADD_TEXT_COMPONENT_STRING(text)
UI._DRAW_TEXT(y, x)
end
function ExtraHUD.ShowExtras()
Health = ENTITY.GET_ENTITY_HEALTH(playerPed)
Armor = PED.GET_PED_ARMOUR(playerPed)
Vehicle = PED.GET_VEHICLE_PED_IS_IN(playerPed, true)
Speed = ENTITY.GET_ENTITY_SPEED(Vehicle)
Engine = VEHICLE.GET_VEHICLE_ENGINE_HEALTH(Vehicle)
ExtraHUD.DrawText("Health: " .. math.floor((Health - 100)), extrahudy, extrahudx, 0.5)
ExtraHUD.DrawText("Armor: " .. Armor, extrahudy + 0.022, extrahudx, 0.5)
if (PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)) then
ExtraHUD.DrawText("Engine: " .. math.floor((Engine / 10)), extrahudy - 0.022, extrahudx, 0.5)
ExtraHUD.DrawText("Speed: " .. math.floor((Speed * 3.6)) .. " km/h", extrahudy - 0.044, extrahudx, 0.5)
end
end
function ExtraHUD.ShowTime()
Hours = TIME.GET_CLOCK_HOURS()
Minutes = TIME.GET_CLOCK_MINUTES()
AMPM = "AM"
if(Hours == 00) then
Hours = string.format("12")
elseif(Hours < 10) then
Hours = string.format("0%d", Hours)
elseif(Hours == 13) then
Hours = string.format("01")
AMPM = "PM"
elseif(Hours == 14) then
Hours = string.format("02")
AMPM = "PM"
elseif(Hours == 15) then
Hours = string.format("03")
AMPM = "PM"
elseif(Hours == 16) then
Hours = string.format("04")
AMPM = "PM"
elseif(Hours == 17) then
Hours = string.format("05")
AMPM = "PM"
elseif(Hours == 18) then
Hours = string.format("06")
AMPM = "PM"
elseif(Hours == 19) then
Hours = string.format("07")
AMPM = "PM"
elseif(Hours == 20) then
Hours = string.format("08")
AMPM = "PM"
elseif(Hours == 21) then
Hours = string.format("09")
AMPM = "PM"
elseif(Hours == 22) then
Hours = string.format("10")
AMPM = "PM"
elseif(Hours == 23) then
Hours = string.format("11")
AMPM = "PM"
elseif(Hours == 24) then
Hours = string.format("12")
end
if(Minutes < 10) then
Minutes = string.format("0%d", Minutes)
end
Time = string.format("%s:%s %s", Hours, Minutes, AMPM)
ExtraHUD.DrawText(Time, extrahudy - 0.066, extrahudx, 0.5)
end
function ExtraHUD.ShowDate()
Month = TIME.GET_CLOCK_MONTH()
Day = TIME.GET_CLOCK_DAY_OF_MONTH()
Year = TIME.GET_CLOCK_YEAR()
Year = Year + 4
if(Month < 10) then
Month = string.format("0%d", Month)
end
if(Day < 10) then
Day = string.format("0%d", Day)
end
Date = string.format("%s-%s-%s", Month, Day, Year)
ExtraHUD.DrawText(Date, extrahudy - 0.110, extrahudx, 0.5)
end
function ExtraHUD.ShowDayName()
DayName = TIME.GET_CLOCK_DAY_OF_WEEK()
if(DayName == 0) then
DayName = "Sunday"
elseif(DayName == 1) then
DayName = "Monday"
elseif(DayName == 2) then
DayName = "Tuesday"
elseif(DayName == 3) then
DayName = "Wednesday"
elseif(DayName == 4) then
DayName = "Thursday"
elseif(DayName == 5) then
DayName = "Friday"
elseif(DayName == 6) then
DayName = "Saturday"
end
ExtraHUD.DrawText(DayName, extrahudy - 0.088, extrahudx, 0.5)
end
return ExtraHUD