forked from JaredScar/Bad-Scoreboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
144 lines (142 loc) · 4.01 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
----------------------
--- Bad-ServerList ---
----------------------
AddEventHandler('playerSpawned', function()
if not alreadySet then
TriggerServerEvent('Bad-ServerList:SetupImg')
alreadySet = true;
end
end)
alreadySet = false;
nui = false;
pageSize = Config.PageSize;
pageCount = 1;
count = 0;
function mod(a, b)
return a - (math.floor(a/b)*b)
end
curCount = 0;
Citizen.CreateThread(function()
local key = Config.KeyCode;
nui = false;
local col = true;
while true do
Wait(1);
if IsControlPressed(0, key) then
if not nui then
local left = "";
local right = "";
col = true;
local maxCount = 0;
for id, ava in pairs(avatarss) do
maxCount = maxCount + 1;
end
local counter = 0;
local keys = {}
for key, ava in pairs(avatarss) do
table.insert(keys, tonumber(key));
end
table.sort(keys);
for key = 1, #keys do
local id = tostring(keys[key]);
local ava = avatarss[id];
if (count < (pageSize * pageCount) and counter >= curCount) then
if (pingss[id] ~= nil and playerNames[id] ~= nil and discordNames[id] ~= nil) then
if col then
-- Left col
col = false;
left = left .. '<tr class="player-box">' ..
'<td><img src="' .. ava .. '" /></td>' ..
'<td>' .. discordNames[id]:gsub("<", ""):gsub(">", "") .. '</td>' ..
"<td>" .. playerNames[id]:gsub("<", ""):gsub(">", "") .. "</td>" ..
"<td>" .. id .. "</td>" ..
"<td>" .. pingss[id] .. " ms</td>" ..
"</tr>";
else
-- Right col
col = true;
right = right .. '<tr class="player-box">' ..
'<td><img src="' .. ava .. '" /></td>' ..
'<td>' .. discordNames[id]:gsub("<", ""):gsub(">", "") .. '</td>' ..
"<td>" .. playerNames[id]:gsub("<", ""):gsub(">", "") .. "</td>" ..
"<td>" .. id .. "</td>" ..
"<td>" .. pingss[id] .. " ms</td>" ..
"</tr>";
end
count = count + 1;
end
end
counter = counter + 1;
end
SendNUIMessage({
addRowLeft = left,
addRowRight = right,
playerCount = maxCount .. " / " .. Config.MaxPlayers,
page = "Page " .. pageCount,
serverName = Config.ServerName
})
if (count >= maxCount) then
count = 0;
pageCount = 1;
col = true;
curCount = 0;
end
if (count >= (pageSize * pageCount)) then
pageCount = pageCount + 1;
curCount = (pageSize * pageCount) - pageSize;
col = true;
end
SendNUIMessage({
display = true;
})
nui = true
while nui do
Wait(0)
if(IsControlPressed(0, key) == false) then
nui = false
SendNUIMessage({
display = false;
})
break
end
end
end
end
end
end)
avatarss = {}
pingss = {}
playerNames = {}
discordNames = {}
RegisterNetEvent('Bad-ServerList:DiscordUpdate')
AddEventHandler('Bad-ServerList:DiscordUpdate', function(players)
discordNames = {};
for id, discordName in pairs(players) do
--print("[" .. id .. "] Avatar == " .. ava)
discordNames[id] = discordName;
end
end)
RegisterNetEvent('Bad-ServerList:PlayerUpdate')
AddEventHandler('Bad-ServerList:PlayerUpdate', function(players)
playerNames = {};
for id, playerName in pairs(players) do
--print("[" .. id .. "] Avatar == " .. ava)
playerNames[id] = playerName;
end
end)
RegisterNetEvent('Bad-ServerList:PingUpdate')
AddEventHandler('Bad-ServerList:PingUpdate', function(pingList)
pingss = {};
for id, ping in pairs(pingList) do
--print("[" .. id .. "] Avatar == " .. ava)
pingss[id] = ping;
end
end)
RegisterNetEvent('Bad-ServerList:ClientUpdate')
AddEventHandler('Bad-ServerList:ClientUpdate', function(avas)
avatarss = {};
for id, ava in pairs(avas) do
--print("[" .. id .. "] Avatar == " .. ava)
avatarss[id] = ava;
end
end)