Fixed !stats command on legacymod (refs #46)

This commit is contained in:
Timo Smit 2017-01-21 18:04:31 +01:00
parent 3231ea6c74
commit 04c78f0886

View file

@ -16,9 +16,11 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require (wolfa_getLuaPath()..".auth.auth") local auth = require (wolfa_getLuaPath()..".auth.auth")
local util = require (wolfa_getLuaPath()..".util.util")
local commands = require (wolfa_getLuaPath()..".commands.commands") local commands = require (wolfa_getLuaPath()..".commands.commands")
local util = require (wolfa_getLuaPath()..".util.util")
function commandShowStats(clientId, cmdArguments) function commandShowStats(clientId, cmdArguments)
if cmdArguments[1] == nil then if cmdArguments[1] == 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"].."\";")
@ -41,24 +43,32 @@ function commandShowStats(clientId, cmdArguments)
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("%^[^^]", ""),
["codedsname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^([^^])", "^^2%1"), ["codedsname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^([^^])", "^^2%1"),
["slot"] = cmdClient, ["slot"] = cmdClient,
["team"] = et.gentity_get(cmdClient, "sess.sessionTeam"), ["team"] = et.gentity_get(cmdClient, "sess.sessionTeam"),
["class"] = et.gentity_get(cmdClient, "sess.playerType"), ["class"] = et.gentity_get(cmdClient, "sess.playerType"),
["health"] = et.gentity_get(cmdClient, "health"), ["health"] = et.gentity_get(cmdClient, "health"),
["kills"] = et.gentity_get(cmdClient, "sess.kills"), ["kills"] = et.gentity_get(cmdClient, "sess.kills"),
["teamkills"] = et.gentity_get(cmdClient, "sess.team_kills"), ["teamkills"] = et.gentity_get(cmdClient, "sess.team_kills"),
["totalkills"] = et.gentity_get(cmdClient, "sess.kills") + et.gentity_get(cmdClient, "sess.team_kills"), ["totalkills"] = et.gentity_get(cmdClient, "sess.kills") + et.gentity_get(cmdClient, "sess.team_kills"),
["damage"] = et.gentity_get(cmdClient, "sess.damage_given"), ["damage"] = et.gentity_get(cmdClient, "sess.damage_given"),
["damagereceived"] = et.gentity_get(cmdClient, "sess.damage_received"), ["damagereceived"] = et.gentity_get(cmdClient, "sess.damage_received"),
["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage"), ["deaths"] = et.gentity_get(cmdClient, "sess.deaths")
-- ["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_received"), -- ETPro only
["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage"),
["deaths"] = et.gentity_get(cmdClient, "sess.deaths"),
["suicides"] = et.gentity_get(cmdClient, "sess.suicides")
} }
if et.trap_Cvar_Get("fs_game") == "legacy" then
stats["teamdamage"] = et.gentity_get(cmdClient, "sess.team_damage_given")
stats["totaldamage"] = et.gentity_get(cmdClient, "sess.damage_given") + et.gentity_get(cmdClient, "sess.team_damage_given")
stats["suicides"] = et.gentity_get(cmdClient, "sess.self_kills")
elseif settings.get("fs_game") == "etpro" then
stats["teamdamagereceived"] = et.gentity_get(cmdClient, "sess.team_received") -- ETPro only
else
stats["teamdamage"] = 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")
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