mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-01-10 15:43:00 +08:00
61 lines
1.7 KiB
Lua
61 lines
1.7 KiB
Lua
local listOn = false
|
|
|
|
Citizen.CreateThread(function()
|
|
listOn = false
|
|
while true do
|
|
Wait(0)
|
|
|
|
if IsControlPressed(0, 27)--[[ INPUT_PHONE ]] then
|
|
if not listOn then
|
|
local players = {}
|
|
ptable = GetPlayers()
|
|
for _, i in ipairs(ptable) do
|
|
local wantedLevel = GetPlayerWantedLevel(i)
|
|
r, g, b = GetPlayerRgbColour(i)
|
|
table.insert(players,
|
|
'<tr style=\"color: rgb(' .. r .. ', ' .. g .. ', ' .. b .. ')\"><td>' .. GetPlayerServerId(i) .. '</td><td>' .. sanitize(GetPlayerName(i)) .. '</td><td>' .. (wantedLevel and wantedLevel or tostring(0)) .. '</td></tr>'
|
|
)
|
|
end
|
|
|
|
SendNUIMessage({ text = table.concat(players) })
|
|
|
|
listOn = true
|
|
while listOn do
|
|
Wait(0)
|
|
if(IsControlPressed(0, 27) == false) then
|
|
listOn = false
|
|
SendNUIMessage({
|
|
meta = 'close'
|
|
})
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end)
|
|
|
|
function GetPlayers()
|
|
local players = {}
|
|
|
|
for i = 0, 31 do
|
|
if NetworkIsPlayerActive(i) then
|
|
table.insert(players, i)
|
|
end
|
|
end
|
|
|
|
return players
|
|
end
|
|
|
|
function sanitize(txt)
|
|
local replacements = {
|
|
['&' ] = '&',
|
|
['<' ] = '<',
|
|
['>' ] = '>',
|
|
['\n'] = '<br/>'
|
|
}
|
|
return txt
|
|
:gsub('[&<>\n]', replacements)
|
|
:gsub(' +', function(s) return ' '..(' '):rep(#s-1) end)
|
|
end
|