mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-21 20:01:18 +00:00
Added aka print to !listplayers and fixed display of connecting clients
This commit is contained in:
parent
71c8de4c0d
commit
5aeb70d179
4 changed files with 47 additions and 17 deletions
|
@ -19,10 +19,13 @@ local auth = wolfa_requireModule("auth.auth")
|
||||||
|
|
||||||
local commands = wolfa_requireModule("commands.commands")
|
local commands = wolfa_requireModule("commands.commands")
|
||||||
|
|
||||||
|
local db = wolfa_requireModule("db.db")
|
||||||
|
|
||||||
local fireteams = wolfa_requireModule("game.fireteams")
|
local fireteams = wolfa_requireModule("game.fireteams")
|
||||||
|
|
||||||
local players = wolfa_requireModule("players.players")
|
local players = wolfa_requireModule("players.players")
|
||||||
|
|
||||||
|
local constants = wolfa_requireModule("util.constants")
|
||||||
local settings = wolfa_requireModule("util.settings")
|
local settings = wolfa_requireModule("util.settings")
|
||||||
local util = wolfa_requireModule("util.util")
|
local util = wolfa_requireModule("util.util")
|
||||||
|
|
||||||
|
@ -37,6 +40,19 @@ function commandListPlayers(clientId, command)
|
||||||
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dCurrently ^7"..(#playersOnline).." ^dplayers online^d:\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dCurrently ^7"..(#playersOnline).." ^dplayers online^d:\";")
|
||||||
for _, player in pairs(playersOnline) do
|
for _, player in pairs(playersOnline) do
|
||||||
|
local teamColor, teamCode
|
||||||
|
|
||||||
|
if et.gentity_get(player, "pers.connected") == constants.CON_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 level = auth.isPlayerAllowed(player, auth.PERM_INCOGNITO) and 0 or auth.getPlayerLevel(player)
|
||||||
|
local levelName = auth.getLevelName(level)
|
||||||
|
|
||||||
local guidStub
|
local guidStub
|
||||||
|
|
||||||
if players.isBot(player) then
|
if players.isBot(player) then
|
||||||
|
@ -45,26 +61,20 @@ function commandListPlayers(clientId, command)
|
||||||
guidStub = players.getGUID(player):sub(-8)
|
guidStub = players.getGUID(player):sub(-8)
|
||||||
end
|
end
|
||||||
|
|
||||||
local level = auth.isPlayerAllowed(player, auth.PERM_INCOGNITO) and 0 or auth.getPlayerLevel(player)
|
|
||||||
local levelName = auth.getLevelName(level)
|
|
||||||
|
|
||||||
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), ""
|
local fireteamId, fireteamName = fireteams.getPlayerFireteamId(player), ""
|
||||||
|
|
||||||
if fireteamId then
|
if fireteamId then
|
||||||
fireteamName = fireteams.getName(fireteamId):sub(1, 1)
|
fireteamName = fireteams.getName(fireteamId):sub(1, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%2i %s%s ^7%-2i %20s ^7(*%s) ^1%1s ^3%1s ^7%s ^7%s%s^7%s",
|
local aka = ""
|
||||||
|
|
||||||
|
local mostUsedAlias = db.getMostUsedAlias(db.getPlayerId(player))["alias"]
|
||||||
|
if not players.isBot(player) and not auth.isPlayerAllowed(player, auth.PERM_INCOGNITO) and players.getName(player) ~= mostUsedAlias then
|
||||||
|
aka = "(a.k.a. "..mostUsedAlias.."^7)"
|
||||||
|
end
|
||||||
|
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%2i %s%s ^7%-2i %20s ^7(*%s) ^1%1s ^3%1s ^7%s ^7%s",
|
||||||
player, -- slot
|
player, -- slot
|
||||||
teamColor, -- team
|
teamColor, -- team
|
||||||
teamCode, -- team
|
teamCode, -- team
|
||||||
|
@ -74,9 +84,7 @@ function commandListPlayers(clientId, command)
|
||||||
(players.isMuted(player) and "M" or ""), -- muted
|
(players.isMuted(player) and "M" or ""), -- muted
|
||||||
fireteamName, -- fireteam
|
fireteamName, -- fireteam
|
||||||
players.getName(player), -- name
|
players.getName(player), -- name
|
||||||
"", -- alias open
|
aka -- alias
|
||||||
"", -- alias
|
|
||||||
"" -- alias close
|
|
||||||
).."\";")
|
).."\";")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,15 @@ function mysql.getAliasByName(playerid, aliasname)
|
||||||
return alias
|
return alias
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mysql.getMostUsedAlias(playerid)
|
||||||
|
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `used` DESC LIMIT 1"))
|
||||||
|
|
||||||
|
local alias = cur:fetch({}, "a")
|
||||||
|
cur:close()
|
||||||
|
|
||||||
|
return alias
|
||||||
|
end
|
||||||
|
|
||||||
function mysql.getLastAlias(playerid)
|
function mysql.getLastAlias(playerid)
|
||||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,15 @@ function sqlite3.getAliasByName(playerid, aliasname)
|
||||||
return alias
|
return alias
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function sqlite3.getMostUsedAlias(playerid)
|
||||||
|
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `used` DESC LIMIT 1"))
|
||||||
|
|
||||||
|
local alias = cur:fetch({}, "a")
|
||||||
|
cur:close()
|
||||||
|
|
||||||
|
return alias
|
||||||
|
end
|
||||||
|
|
||||||
function sqlite3.getLastAlias(playerid)
|
function sqlite3.getLastAlias(playerid)
|
||||||
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,10 @@ constants.TEAM_SPECTATORS_COLOR = "^2"
|
||||||
constants.TEAM_AXIS_COLOR_NAME = "red"
|
constants.TEAM_AXIS_COLOR_NAME = "red"
|
||||||
constants.TEAM_ALLIES_COLOR_NAME = "blue"
|
constants.TEAM_ALLIES_COLOR_NAME = "blue"
|
||||||
|
|
||||||
|
constants.CON_DISCONNECTED = 0
|
||||||
|
constants.CON_CONNECTING = 1
|
||||||
|
constants.CON_CONNECTED = 2
|
||||||
|
|
||||||
constants.CLASS_SOLDIER = 0
|
constants.CLASS_SOLDIER = 0
|
||||||
constants.CLASS_MEDIC = 1
|
constants.CLASS_MEDIC = 1
|
||||||
constants.CLASS_ENGINEER = 2
|
constants.CLASS_ENGINEER = 2
|
||||||
|
|
Loading…
Reference in a new issue