-
Notifications
You must be signed in to change notification settings - Fork 6
/
client.lua
99 lines (87 loc) · 3.75 KB
/
client.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
local ESX, PlayerData = nil, {}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end)
Citizen.Wait(10)
end
while not ESX.GetPlayerData().job do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent("esx:playerLoaded", function(xPlayer) PlayerData = xPlayer end)
RegisterNetEvent("esx:setJob", function(job) PlayerData.job = job end)
function GetCurrentPlayers()
local TotalPlayers = 0
for _, player in ipairs(GetActivePlayers()) do
TotalPlayers = TotalPlayers + 1
end
return TotalPlayers
end
Citizen.CreateThread(function()
while true do
ESX.TriggerServerCallback('callbackplayers', function(data)
cpolice = data.cpolice
cmedic = data.cmedic
cstaffs = data.cstaffs
cmechanic = data.cmechanic
players = GetCurrentPlayers()
end)
Citizen.Wait(Config.UpdateTime)
end
end)
RegisterCommand('scoreboard', function()
Scoreboard()
end)
RegisterKeyMapping('scoreboard', 'Open Scoreboard Menu' , 'keyboard', 'F10')
Scoreboard = function()
local elements = {}
if Config.Hide0 then
if cpolice >= 1 then
table.insert(elements, {label = '👮🏻♂️ Officers: '..cpolice..'', value = 'pol'})
end
if cmedic >= 1 then
table.insert(elements, {label = '👨🏻⚕️ Medics: '..cmedic..'', value = 'med'} )
end
if cmechanic >= 1 then
table.insert(elements, {label = '👨🏻🔧 Mechanics: '..cmechanic..'', value = 'mec'} )
end
if cstaffs >= 1 then
table.insert(elements, {label = '🧙🏻 Connected Staffs: '..cstaffs..'', value = 'staff'} )
end
table.insert(elements, {label = '👤Connected Players: '..players..'', value = 'ply'} )
table.insert(elements, {label = 'Close', value = 'close'} )
else
table.insert(elements, {label = '👮🏻♂️ Officers: '..cpolice..'', value = 'pol'})
table.insert(elements, {label = '👨🏻⚕️ Medics: '..cmedic..'', value = 'med'} )
table.insert(elements, {label = '👨🏻🔧 Mechanics: '..cmechanic..'', value = 'mec'} )
table.insert(elements, {label = '🧙🏻 Connected Staffs: '..cstaffs..'', value = 'staff'} )
table.insert(elements, {label = '👤 Connected Players: '..players..'', value = 'ply'} )
table.insert(elements, {label = 'Close', value = 'close'} )
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'score',
{
title = 'Player List',
align = Config.Align,
elements = elements,
},
function(data, menu)
local action = data.current.value
if action == 'pol' then
ESX.ShowNotification("There are "..cpolice.." police officers on duty")
elseif action == 'med' then
ESX.ShowNotification("There are "..cmedic.." medics on duty")
elseif action == 'mec' then
ESX.ShowNotification("There are "..cmechanic.." mechanics on duty")
elseif action == 'staff' then
ESX.ShowNotification("There are "..cstaffs.." Staffs connected")
elseif action == 'ply' then
ESX.ShowNotification("There are "..players.." Players connected")
elseif action == 'close' then
ESX.UI.Menu.CloseAll()
end
end,
function(data, menu)
menu.close()
end)
end