-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscoreboard_top_right_corner.lua
98 lines (90 loc) · 2.92 KB
/
scoreboard_top_right_corner.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
-- Ref: https://discord.com/channels/192358910387159041/643437814104457217/1023938148243341432
local scoreboard = false
RegisterCommand("scoreboard", function(source, args, raw)
TriggerEvent("scoreboard")
end)
RegisterNetEvent("scoreboard", function()
if scoreboard then
scoreboard = false
return
else
scoreboard = true
end
local team1 = "TEAM 1"
local team2 = "TEAM 2"
local score1 = 1
local score2 = 2
local a = DatabindingAddDataContainerFromPath("", "helperTextfields");
DatabindingAddDataString(a, "rawLabel0", team1);
DatabindingAddDataString(a, "rawLabel1", team2);
DatabindingAddDataString(a, "rawValue0", tostring(score1));
DatabindingAddDataString(a, "rawValue1", tostring(score2));
while scoreboard do
Citizen.Wait(1)
Citizen.InvokeNative(0xC9CAEAEEC1256E54, -66088566)
end
end)
--- OR: https://discord.com/channels/846719561020473364/987235576308703292/1146012003983429642
local scoreboard = false
local function ScoreBoardUI(ui_data)
if scoreboard then
scoreboard = false
return
else
scoreboard = true
end
local a = {}
a.container = DatabindingAddDataContainerFromPath("", "helperTextfields");
a.rawLabel0 = DatabindingAddDataString(a.container, "rawLabel0", ui_data.team1);
a.rawLabel1 = DatabindingAddDataString(a.container, "rawLabel1", ui_data.team2);
a.rawValue0 = DatabindingAddDataString(a.container, "rawValue0", tostring(ui_data.score1));
a.rawValue1 = DatabindingAddDataString(a.container, "rawValue1", tostring(ui_data.score2));
self = {
container = a,
ui_data = ui_data,
updating = false,
Update = function(newInfo)
for i,v in pairs(newInfo) do
ui_data[i] = v
DatabindingWriteDataString(self.container[i], v)
end
end,
Close = function()
scoreboard = false
DatabindingRemoveDataEntry(self.container.container)
end
}
return self
end
Citizen.CreateThread(function()
while true do
local t = 1
if scoreboard then
Citizen.InvokeNative(0xC9CAEAEEC1256E54, -66088566)
else
t = 500
end
Wait(t)
end
end)
RegisterCommand("score_ui", function(source, args, raw)
local score_data = {
team1 = "TEAM 1",
team2 = "TEAM 2",
score1 = 1,
score2 = 2,
}
local score_ui = ScoreBoardUI(score_data)
Wait(0)
score_ui.Update({rawLabel0 = "New Team 1", rawLabel1 = "New Team 2", rawValue0 = "0", rawValue1 = "0"})
Wait(2000)
score_ui.Update({rawValue0 = "1", rawValue1 = "0"})
Wait(2000)
score_ui.Update({rawValue0 = "1", rawValue1 = "1"})
Wait(2000)
score_ui.Update({rawValue0 = "2", rawValue1 = "1"})
Wait(2000)
score_ui.Update({rawValue0 = "3", rawValue1 = "1"})
Wait(2000)
score_ui.Close()
end)