mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-10 06:41:53 +00:00
Aligned (team) damage in !stats
This commit is contained in:
parent
dc066b7fba
commit
074999037a
1 changed files with 27 additions and 27 deletions
|
@ -24,24 +24,24 @@ local util = require (wolfa_getLuaPath()..".util.util")
|
||||||
function commandShowStats(clientId, command, victim)
|
function commandShowStats(clientId, command, victim)
|
||||||
if victim == nil then
|
if victim == nil then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.getadmin("stats")["syntax"].."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats usage: "..commands.getadmin("stats")["syntax"].."\";")
|
||||||
|
|
||||||
return true
|
return true
|
||||||
elseif tonumber(victim) == nil or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
elseif tonumber(victim) == nil or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||||
cmdClient = et.ClientNumberFromString(victim)
|
cmdClient = et.ClientNumberFromString(victim)
|
||||||
else
|
else
|
||||||
cmdClient = tonumber(victim)
|
cmdClient = tonumber(victim)
|
||||||
end
|
end
|
||||||
|
|
||||||
if cmdClient == -1 or cmdClient == nil then
|
if cmdClient == -1 or cmdClient == nil then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no or multiple matches for '^7"..victim.."^9'.\";")
|
||||||
|
|
||||||
return true
|
return true
|
||||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no connected player by that name or slot #\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9no connected player by that name or slot #\";")
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local stats = {
|
local stats = {
|
||||||
["name"] = et.gentity_get(cmdClient, "pers.netname"),
|
["name"] = et.gentity_get(cmdClient, "pers.netname"),
|
||||||
["cleanname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^[^^]", ""),
|
["cleanname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^[^^]", ""),
|
||||||
|
@ -57,7 +57,7 @@ function commandShowStats(clientId, command, victim)
|
||||||
["damagereceived"] = et.gentity_get(cmdClient, "sess.damage_received"),
|
["damagereceived"] = et.gentity_get(cmdClient, "sess.damage_received"),
|
||||||
["deaths"] = et.gentity_get(cmdClient, "sess.deaths")
|
["deaths"] = et.gentity_get(cmdClient, "sess.deaths")
|
||||||
}
|
}
|
||||||
|
|
||||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||||
stats["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage_given")
|
stats["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage_given")
|
||||||
stats["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_damage_received")
|
stats["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_damage_received")
|
||||||
|
@ -75,7 +75,7 @@ function commandShowStats(clientId, command, victim)
|
||||||
stats["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage")
|
stats["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage")
|
||||||
stats["suicides"] = et.gentity_get(cmdClient, "sess.suicides")
|
stats["suicides"] = et.gentity_get(cmdClient, "sess.suicides")
|
||||||
end
|
end
|
||||||
|
|
||||||
if stats["totalkills"] == 0 then stats["totalkills"] = 1 end
|
if stats["totalkills"] == 0 then stats["totalkills"] = 1 end
|
||||||
if stats["totaldamage"] == 0 then stats["totaldamage"] = 1 end
|
if stats["totaldamage"] == 0 then stats["totaldamage"] = 1 end
|
||||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||||
|
@ -83,46 +83,46 @@ function commandShowStats(clientId, command, victim)
|
||||||
if stats["totalgibs"] == 0 then stats["totalgibs"] = 1 end
|
if stats["totalgibs"] == 0 then stats["totalgibs"] = 1 end
|
||||||
if stats["totaldamagereceived"] == 0 then stats["totaldamagereceived"] = 1 end
|
if stats["totaldamagereceived"] == 0 then stats["totaldamagereceived"] = 1 end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ for key, value in pairs(stats) do
|
--[[ for key, value in pairs(stats) do
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..string.format("%-15s", key..":").." ^7"..value.."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..string.format("%-15s", key..":").." ^7"..value.."\";")
|
||||||
end ]]
|
end ]]
|
||||||
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dStatistics for ^7"..stats["name"].."^d:\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dStatistics for ^7"..stats["name"].."^d:\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dName: ^2"..stats["cleanname"].." ("..stats["codedsname"]..")\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dName: ^2"..stats["cleanname"].." ("..stats["codedsname"]..")\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dSlot: ^2"..stats["slot"]..(stats["slot"] < tonumber(et.trap_Cvar_Get("sv_privateClients")) and " ^9(private)" or "").."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dSlot: ^2"..stats["slot"]..(stats["slot"] < tonumber(et.trap_Cvar_Get("sv_privateClients")) and " ^9(private)" or "").."\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dTeam: ^2"..util.getTeamName(stats["team"]).."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dTeam: ^2"..util.getTeamName(stats["team"]).."\";")
|
||||||
|
|
||||||
if stats["team"] ~= et.TEAM_SPECTATORS then
|
if stats["team"] ~= et.TEAM_SPECTATORS then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dClass: ^2"..util.getClassName(stats["class"]).."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dClass: ^2"..util.getClassName(stats["class"]).."\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dHealth: ^2"..(stats["health"] < 0 and "dead" or stats["health"]).."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dHealth: ^2"..(stats["health"] < 0 and "dead" or stats["health"]).."\";")
|
||||||
end
|
end
|
||||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDamage given: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam damage given: ^2"..stats["teamdamage"].." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDmg gvn: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam dmg gvn: ^2"..string.format("%-4s", stats["teamdamage"]).." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDamage recvd: ^2"..string.format("%-8s", stats["damagereceived"]).." ^dTeam damage recvd: ^2"..stats["teamdamagereceived"].." ^9("..string.format("%0.2f", (stats["teamdamagereceived"] / (stats["totaldamagereceived"] or 1) * 100)).." percent)\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDmg rcvd: ^2"..string.format("%-8s", stats["damagereceived"]).." ^dTeam dmg rcvd: ^2"..string.format("%-4s", stats["teamdamagereceived"]).." ^9("..string.format("%0.2f", (stats["teamdamagereceived"] / (stats["totaldamagereceived"] or 1) * 100)).." percent)\";")
|
||||||
else
|
else
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDamage: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam damage: ^2"..stats["teamdamage"].." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDamage: ^2"..string.format("%-8s", stats["damage"]).." ^dTeam damage: ^2"..string.format("%-4s", stats["teamdamage"]).." ^9("..string.format("%0.2f", (stats["teamdamage"] / (stats["totaldamage"] or 1) * 100)).." percent)\";")
|
||||||
end
|
end
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dKills: ^2"..string.format("%-8s", stats["kills"]).." ^dTeam kills: ^2"..stats["teamkills"].." ^9("..string.format("%0.2f", (stats["teamkills"] / (stats["totalkills"] or 1) * 100)).." percent)\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dKills: ^2"..string.format("%-8s", stats["kills"]).." ^dTeam kills: ^2"..string.format("%-4s", stats["teamkills"]).." ^9("..string.format("%0.2f", (stats["teamkills"] / (stats["totalkills"] or 1) * 100)).." percent)\";")
|
||||||
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
if et.trap_Cvar_Get("fs_game") == "legacy" then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSelf kills: ^2"..stats["selfkills"].." ^9("..string.format("%0.2f", (stats["selfkills"] / (stats["totaldeaths"] or 1) * 100)).." percent)\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSelf kills: ^2"..string.format("%-4s", stats["selfkills"]).." ^9("..string.format("%0.2f", (stats["selfkills"] / (stats["totaldeaths"] or 1) * 100)).." percent)\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dGibs: ^2"..string.format("%-8s", stats["gibs"]).." ^dTeam gibs: ^2"..stats["teamgibs"].." ^9("..string.format("%0.2f", (stats["teamgibs"] / (stats["totalgibs"] or 1) * 100)).." percent)\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dGibs: ^2"..string.format("%-8s", stats["gibs"]).." ^dTeam gibs: ^2"..string.format("%-4s", stats["teamgibs"]).." ^9("..string.format("%0.2f", (stats["teamgibs"] / (stats["totalgibs"] or 1) * 100)).." percent)\";")
|
||||||
else
|
else
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSuicides: ^2"..stats["suicides"].."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dDeaths: ^2"..string.format("%-8s", stats["deaths"]).." ^dSuicides: ^2"..string.format("%-8s", stats["suicides"]).."\";")
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dK/D: ^2"..string.format("%0.2f", (stats["kills"] / ((stats["deaths"] > 0) and stats["deaths"] or 1))).."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dK/D: ^2"..string.format("%0.2f", (stats["kills"] / ((stats["deaths"] > 0) and stats["deaths"] or 1))).."\";")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- NQ 1.3.0 and higher
|
-- NQ 1.3.0 and higher
|
||||||
--[[ for key, value in ipairs(stats["weapstats"]) do
|
--[[ for key, value in ipairs(stats["weapstats"]) do
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..stats["weapstats"].."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..stats["weapstats"].."\";")
|
||||||
end ]]
|
end ]]
|
||||||
|
|
||||||
-- NQ 1.3.0 and higher
|
-- NQ 1.3.0 and higher
|
||||||
--[[ local weapstats = et.gentity_get(cmdClient, "sess.aWeaponStats", WP_THOMPSON)
|
--[[ local weapstats = et.gentity_get(cmdClient, "sess.aWeaponStats", WP_THOMPSON)
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..weapstats.."\";") ]]
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dstats: ^9"..weapstats.."\";") ]]
|
||||||
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dstats: ^9stats for ^7"..stats["name"].." ^9were printed to the console.\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dstats: ^9stats for ^7"..stats["name"].." ^9were printed to the console.\";")
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
commands.addadmin("stats", commandShowStats, auth.PERM_LISTSTATS, "display the statistics for a specific player", "^9[^3name|slot#^9]")
|
commands.addadmin("stats", commandShowStats, auth.PERM_LISTSTATS, "display the statistics for a specific player", "^9[^3name|slot#^9]")
|
||||||
|
|
Loading…
Reference in a new issue