-
Notifications
You must be signed in to change notification settings - Fork 48
/
timerbars.lua
115 lines (96 loc) · 4.49 KB
/
timerbars.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
-- Credits to rootcause
local safeZone = (1.0 - GetSafeZoneSize()) * 0.5
local timerBar = {
baseX = 0.918,
baseY = 0.984,
baseWidth = 0.165,
baseHeight = 0.035,
baseGap = 0.038,
titleX = 0.012,
titleY = -0.009,
textX = 0.0785,
textY = -0.0165,
progressX = 0.047,
progressY = 0.0015,
progressWidth = 0.0616,
progressHeight = 0.0105,
txtDict = "timerbars",
txtName = "all_black_bg",
}
function DrawTimerProgressBar(idx, title, progress, titleColor, fgColor, bgColor, usePlayerStyle)
local title = title or ""
local titleColor = titleColor or { 255, 255, 255, 255 }
local progress = progress or false
local fgColor = fgColor or { 255, 255, 255, 255 }
local bgColor = bgColor or { 255, 255, 255, 255 }
local titleScale = usePlayerStyle and 0.465 or 0.3
local titleFont = usePlayerStyle and 4 or 0
local titleFontOffset = usePlayerStyle and 0.00625 or 0.0
local yOffset = (timerBar.baseY - safeZone) - ((idx[1] or 0) * timerBar.baseGap)
if not HasStreamedTextureDictLoaded(timerBar.txtDict) then
RequestStreamedTextureDict(timerBar.txtDict, true)
local t = GetGameTimer() + 5000
repeat
Citizen.Wait(0)
until HasStreamedTextureDictLoaded(timerBar.txtDict) or (GetGameTimer() > t)
end
DrawSprite(timerBar.txtDict, timerBar.txtName, timerBar.baseX - safeZone, yOffset, timerBar.baseWidth, timerBar.baseHeight, 0.0, 255, 255, 255, 160)
BeginTextCommandDisplayText("CELL_EMAIL_BCON")
SetTextFont(titleFont)
SetTextScale(titleScale, titleScale)
SetTextColour(titleColor[1], titleColor[2], titleColor[3], titleColor[4])
SetTextRightJustify(true)
SetTextWrap(0.0, (timerBar.baseX - safeZone) + timerBar.titleX)
AddTextComponentSubstringPlayerName(title)
EndTextCommandDisplayText((timerBar.baseX - safeZone) + timerBar.titleX, yOffset + timerBar.titleY - titleFontOffset)
local progress = (progress < 0.0) and 0.0 or ((progress > 1.0) and 1.0 or progress)
local progressX = (timerBar.baseX - safeZone) + timerBar.progressX
local progressY = yOffset + timerBar.progressY
local progressWidth = timerBar.progressWidth * progress
DrawRect(progressX, progressY, timerBar.progressWidth, timerBar.progressHeight, bgColor[1], bgColor[2], bgColor[3], bgColor[4])
DrawRect((progressX - timerBar.progressWidth / 2) + progressWidth / 2, progressY, progressWidth, timerBar.progressHeight, fgColor[1], fgColor[2], fgColor[3], fgColor[4])
if idx ~= nil then
if idx[1] then
idx[1] = idx[1] + 1
end
end
end
function DrawTimerBar(idx, title, text, titleColor, textColor, usePlayerStyle)
local title = title or ""
local text = text or ""
local titleColor = titleColor or { 255, 255, 255, 255 }
local textColor = textColor or { 255, 255, 255, 255 }
local titleScale = usePlayerStyle and 0.465 or 0.3
local titleFont = usePlayerStyle and 4 or 0
local titleFontOffset = usePlayerStyle and 0.00625 or 0.0
local yOffset = (timerBar.baseY - safeZone) - ((idx[1] or 0) * timerBar.baseGap)
if not HasStreamedTextureDictLoaded(timerBar.txtDict) then
RequestStreamedTextureDict(timerBar.txtDict, true)
local t = GetGameTimer() + 5000
repeat
Citizen.Wait(0)
until HasStreamedTextureDictLoaded(timerBar.txtDict) or (GetGameTimer() > t)
end
DrawSprite(timerBar.txtDict, timerBar.txtName, timerBar.baseX - safeZone, yOffset, timerBar.baseWidth, timerBar.baseHeight, 0.0, 255, 255, 255, 160)
BeginTextCommandDisplayText("CELL_EMAIL_BCON")
SetTextFont(titleFont)
SetTextScale(titleScale, titleScale)
SetTextColour(titleColor[1], titleColor[2], titleColor[3], titleColor[4])
SetTextRightJustify(true)
SetTextWrap(0.0, (timerBar.baseX - safeZone) + timerBar.titleX)
AddTextComponentSubstringPlayerName(title)
EndTextCommandDisplayText((timerBar.baseX - safeZone) + timerBar.titleX, yOffset + timerBar.titleY - titleFontOffset)
BeginTextCommandDisplayText("CELL_EMAIL_BCON")
SetTextFont(0)
SetTextScale(0.425, 0.425)
SetTextColour(textColor[1], textColor[2], textColor[3], textColor[4])
SetTextRightJustify(true)
SetTextWrap(0.0, (timerBar.baseX - safeZone) + timerBar.textX)
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayText((timerBar.baseX - safeZone) + timerBar.textX, yOffset + timerBar.textY)
if idx ~= nil then
if idx[1] then
idx[1] = idx[1] + 1
end
end
end