mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-12-02 08:51:47 +00:00
86 lines
3.3 KiB
Lua
86 lines
3.3 KiB
Lua
|
|
||
|
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||
|
-- Copyright (C) 2015-2016 Timo 'Timothy' Smit
|
||
|
|
||
|
-- This program is free software: you can redistribute it and/or modify
|
||
|
-- it under the terms of the GNU General Public License as published by
|
||
|
-- the Free Software Foundation, either version 3 of the License, or
|
||
|
-- at your option any later version.
|
||
|
|
||
|
-- This program is distributed in the hope that it will be useful,
|
||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
-- GNU General Public License for more details.
|
||
|
|
||
|
-- You should have received a copy of the GNU General Public License
|
||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
local auth = require "luascripts.wolfadmin.auth.auth"
|
||
|
|
||
|
local commands = require "luascripts.wolfadmin.commands.commands"
|
||
|
|
||
|
local game = require "luascripts.wolfadmin.game.game"
|
||
|
local fireteams = require "luascripts.wolfadmin.game.fireteams"
|
||
|
|
||
|
local stats = require "luascripts.wolfadmin.players.stats"
|
||
|
|
||
|
local constants = require "luascripts.wolfadmin.util.constants"
|
||
|
local settings = require "luascripts.wolfadmin.util.settings"
|
||
|
local util = require "luascripts.wolfadmin.util.util"
|
||
|
|
||
|
function commandListPlayers(clientId, cmdArguments)
|
||
|
local players = {}
|
||
|
|
||
|
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||
|
if wolfa_isPlayer(playerId) then
|
||
|
table.insert(players, playerId)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dCurrently ^7"..(#players).." ^dplayers online^d:\";")
|
||
|
for _, player in pairs(players) do
|
||
|
local guidStub
|
||
|
|
||
|
if stats.get(player, "isBot") then
|
||
|
guidStub = "OMNIBOT-"
|
||
|
else
|
||
|
guidStub = stats.get(player, "playerGUID"):sub(-8)
|
||
|
end
|
||
|
|
||
|
local teamColor, teamCode
|
||
|
|
||
|
if et.gentity_get(player, "pers.connected") then
|
||
|
teamColor = util.getTeamColor(tonumber(et.gentity_get(player, "sess.sessionTeam")))
|
||
|
teamCode = util.getTeamCode(tonumber(et.gentity_get(player, "sess.sessionTeam"))):upper():sub(1,1)
|
||
|
else
|
||
|
teamColor = "^8"
|
||
|
teamCode = "C"
|
||
|
end
|
||
|
|
||
|
local fireteamId, fireteamName = fireteams.getPlayerFireteamId(player), ""
|
||
|
|
||
|
if fireteamId then
|
||
|
fireteamName = fireteams.getName(fireteamId):sub(1, 1)
|
||
|
end
|
||
|
|
||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%2i %s ^7%-2i %20s ^7(*%s) ^1%1s ^3%1s ^7%s ^7%s%s^7%s",
|
||
|
player, -- slot
|
||
|
teamCode, -- team
|
||
|
auth.getlevel(player), -- level
|
||
|
"Guest", -- levelname
|
||
|
guidStub, -- guid stub
|
||
|
(stats.get(player, "playerMuted") and "M" or ""), -- muted
|
||
|
fireteamName, -- fireteam
|
||
|
stats.get(player, "playerName"), -- name
|
||
|
"", -- alias open
|
||
|
"", -- alias
|
||
|
"" -- alias close
|
||
|
).."\";")
|
||
|
end
|
||
|
|
||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistplayers: ^9current player info was printed to the console.\";")
|
||
|
|
||
|
return true
|
||
|
end
|
||
|
commands.addadmin("listplayers", commandListPlayers, auth.PERM_LISTPLAYERS, "display a list of connected players, their slot numbers as well as their admin levels", nil, (settings.get("g_standalone") == 0))
|