-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathclient.lua
More file actions
71 lines (57 loc) · 1.36 KB
/
client.lua
File metadata and controls
71 lines (57 loc) · 1.36 KB
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
Board = {
visible = false,
setVisible = function(self, state)
self.visible = state
SendNUIMessage({
visible = state
})
SetNuiFocus(state, false)
if ESX?.UI?.HUD then
ESX.UI.HUD.SetDisplay(state and 0 or 1)
end
DisplayRadar(not state)
if state then
self:update()
CreateThread(function()
while self.visible do
self:update()
Wait(1000 * 5)
end
end)
end
end,
init = function(_, cb)
local sendFunc = cb or SendNUIMessage
ESX.TriggerServerCallback("getScoreboardConfig", function(slots, Factions)
CONFIG.slots = slots
CONFIG.toggleKey = TOGGLE_KEY
sendFunc({
CONFIG = CONFIG,
Factions = Factions,
})
end)
end,
update = function(self)
ESX.TriggerServerCallback("getScorePlayers", function(players, myData)
SendNUIMessage({
players = players,
myData = myData,
})
end)
end
}
Board.__index = Board
RegisterNUICallback("getConfig", function(_, cb)
Board:init(cb)
end)
RegisterNUICallback("close", function(_, cb)
Board:setVisible(false)
cb('ok')
end)
RegisterNetEvent("esx:playerLoaded", function()
Board:init()
end)
RegisterCommand("scoreboard", function()
Board:setVisible(not Board.visible)
end)
RegisterKeyMapping("scoreboard", "Toggle Scoreboard", "keyboard", TOGGLE_KEY)