Added logging module and log chat (issue #65)

This commit is contained in:
Timo Smit 2017-01-28 15:24:34 +01:00
parent f2458bb3a5
commit 72f5b32cd2
6 changed files with 164 additions and 84 deletions

View File

@ -15,12 +15,11 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- 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 commands = require (wolfa_getLuaPath()..".commands.commands") local commands = require (wolfa_getLuaPath()..".commands.commands")
local players = require (wolfa_getLuaPath()..".players.players") local players = require (wolfa_getLuaPath()..".players.players")
local logs = require (wolfa_getLuaPath()..".util.logs")
local settings = require (wolfa_getLuaPath()..".util.settings") local settings = require (wolfa_getLuaPath()..".util.settings")
function commandPersonalMessage(clientId, command, recipient, ...) function commandPersonalMessage(clientId, command, recipient, ...)
@ -84,6 +83,8 @@ function commandPersonalMessage(clientId, command, recipient, ...)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..cmdClient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..cmdClient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";")
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..cmdClient.." \"^9reply: ^7r [^2message^7]\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..cmdClient.." \"^9reply: ^7r [^2message^7]\";")
end end
logs.writeChat(clientId, "priv", cmdClient, ...)
end end
commands.addclient("pm", commandPersonalMessage, "", "", true, (settings.get("fs_game") == "legacy")) commands.addclient("pm", commandPersonalMessage, "", "", true, (settings.get("fs_game") == "legacy"))
commands.addclient("m", commandPersonalMessage, "", "", true, (settings.get("fs_game") == "legacy")) commands.addclient("m", commandPersonalMessage, "", "", true, (settings.get("fs_game") == "legacy"))

View File

@ -15,10 +15,9 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- 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 commands = require (wolfa_getLuaPath()..".commands.commands") local commands = require (wolfa_getLuaPath()..".commands.commands")
local logs = require (wolfa_getLuaPath()..".util.logs")
local players = require (wolfa_getLuaPath()..".players.players") local players = require (wolfa_getLuaPath()..".players.players")
function commandR(clientId, command, ...) function commandR(clientId, command, ...)
@ -51,6 +50,8 @@ function commandR(clientId, command, ...)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..recipient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..recipient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";")
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..recipient.." \"^9reply: ^7r [^2message^7]\";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..recipient.." \"^9reply: ^7r [^2message^7]\";")
logs.writeChat(clientId, "priv", recipient, ...)
return true return true
end end
commands.addclient("r", commandR, "", "[^2message^7]", true) commands.addclient("r", commandR, "", "[^2message^7]", true)

View File

@ -19,26 +19,44 @@ local commands = require (wolfa_getLuaPath()..".commands.commands")
local players = require (wolfa_getLuaPath()..".players.players") local players = require (wolfa_getLuaPath()..".players.players")
local logs = require (wolfa_getLuaPath()..".util.logs")
local settings = require (wolfa_getLuaPath()..".util.settings") local settings = require (wolfa_getLuaPath()..".util.settings")
function commandSay(clientId, command) local types = {
["say"] = "chat",
["say_team"] = "team",
["say_teamnl"] = "spec",
["say_buddy"] = "fire",
["vsay"] = "chat",
["vsay_team"] = "team",
["vsay_buddy"] = "fire"
}
function commandSay(clientId, command, ...)
if players.isMuted(clientId, players.MUTE_CHAT) then if players.isMuted(clientId, players.MUTE_CHAT) then
et.trap_SendServerCommand(clientId, "cp \"^1You are muted\"") et.trap_SendServerCommand(clientId, "cp \"^1You are muted\"")
return true return true
end end
logs.writeChat(clientId, types[command], ...)
end end
commands.addclient("say", commandSay, "", "", false, (settings.get("g_standalone") == 0)) commands.addclient("say", commandSay, "", "", false, (settings.get("g_standalone") == 0))
commands.addclient("say_team", commandSay, "", "", false, (settings.get("g_standalone") == 0)) commands.addclient("say_team", commandSay, "", "", false, (settings.get("g_standalone") == 0))
commands.addclient("say_teamnl", commandSay, "", "", false, (settings.get("g_standalone") == 0)) commands.addclient("say_teamnl", commandSay, "", "", false, (settings.get("g_standalone") == 0))
commands.addclient("say_buddy", commandSay, "", "", false, (settings.get("g_standalone") == 0)) commands.addclient("say_buddy", commandSay, "", "", false, (settings.get("g_standalone") == 0))
function commandVoiceSay(clientId, cmdArguments) function commandVoiceSay(clientId, command, ...)
if players.isMuted(clientId, players.MUTE_VOICE) then if players.isMuted(clientId, players.MUTE_VOICE) then
et.trap_SendServerCommand(clientId, "cp \"^1You are voicemuted\"") et.trap_SendServerCommand(clientId, "cp \"^1You are voicemuted\"")
return true return true
end end
if settings.get("g_standalone") == 1 then
logs.writeChat(clientId, types[command], ...)
end
end end
commands.addclient("vsay", commandVoiceSay, "", "", false) commands.addclient("vsay", commandVoiceSay, "", "", false)
commands.addclient("vsay_team", commandVoiceSay, "", "", false) commands.addclient("vsay_team", commandVoiceSay, "", "", false)
commands.addclient("vsay_buddy", commandVoiceSay, "", "", false)

View File

@ -15,16 +15,12 @@
-- You should have received a copy of the GNU General Public License -- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
require (wolfa_getLuaPath()..".util.debug")
local auth = require (wolfa_getLuaPath()..".auth.auth") local auth = require (wolfa_getLuaPath()..".auth.auth")
local players = require (wolfa_getLuaPath()..".players.players")
local util = require (wolfa_getLuaPath()..".util.util") local util = require (wolfa_getLuaPath()..".util.util")
local events = require (wolfa_getLuaPath()..".util.events") local events = require (wolfa_getLuaPath()..".util.events")
local files = require (wolfa_getLuaPath()..".util.files") local files = require (wolfa_getLuaPath()..".util.files")
local settings = require (wolfa_getLuaPath()..".util.settings") local logs = require (wolfa_getLuaPath()..".util.logs")
local tables = require (wolfa_getLuaPath()..".util.tables") local tables = require (wolfa_getLuaPath()..".util.tables")
local commands = {} local commands = {}
@ -123,19 +119,19 @@ function commands.load()
return totalAmount return totalAmount
end end
function commands.log(clientId, command, cmdArguments) function commands.log(clientId, command, victim, ...)
local victimId local victimId
-- funny, NoQuarter actually checks EACH command for a victim (so even -- funny, NoQuarter actually checks EACH command for a victim (so even
-- !help [playername] will log a victimname). so why not do the same :D -- !help [playername] will log a victimname). so why not do the same :D
-- todo: do this more nicely, maybe change .register() function -- todo: do this more nicely, maybe change .register() function
if cmdArguments[1] then if victim then
local cmdClient local cmdClient
if tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then if tonumber(victim) == nil or tonumber(victim) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
cmdClient = et.ClientNumberFromString(cmdArguments[1]) cmdClient = et.ClientNumberFromString(victim)
else else
cmdClient = tonumber(cmdArguments[1]) cmdClient = tonumber(victim)
end end
if cmdClient ~= -1 and cmdClient ~= nil and et.gentity_get(cmdClient, "pers.netname") then if cmdClient ~= -1 and cmdClient ~= nil and et.gentity_get(cmdClient, "pers.netname") then
@ -143,35 +139,7 @@ function commands.log(clientId, command, cmdArguments)
end end
end end
local fileDescriptor = files.open(settings.get("g_logAdmin"), et.FS_APPEND) logs.writeAdmin(clientId, command, victimId, ...)
local logLine
local clientGUID = clientId and players.getGUID(clientId) or "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
local clientName = clientId and players.getName(clientId) or "console"
local clientFlags = ""
if settings.get("g_standalone") == 1 then
if victimId then
local victimName = players.getName(victimId)
logLine = string.format("[%s] %s: %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, clientName, command, victimName, table.concat(cmdArguments, " ", 2))
else
logLine = string.format("[%s] %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, clientName, command, table.concat(cmdArguments, " "))
end
else
local levelTime = et.trap_Milliseconds() / 1000
if victimId then
local victimName = players.getName(victimId)
logLine = string.format("%3i:%02f: %i: %s: %s: %s: %s: %s: %s: \"%s\"\n", math.floor(levelTime / 60), (levelTime % 60), clientId, clientGUID, clientName, clientFlags, command, victimId, victimName, table.concat(cmdArguments, " ", 2))
else
logLine = string.format("%3i:%02f: %i: %s: %s: %s: %s: \"%s\"\n", math.floor(levelTime / 60), (levelTime % 60), clientId, clientGUID, clientName, clientFlags, command, table.concat(cmdArguments, " "))
end
end
et.trap_FS_Write(logLine, string.len(logLine), fileDescriptor)
et.trap_FS_FCloseFile(fileDescriptor)
end end
function commands.onGameInit() function commands.onGameInit()
@ -179,51 +147,51 @@ function commands.onGameInit()
end end
events.handle("onGameInit", commands.onGameInit) events.handle("onGameInit", commands.onGameInit)
function commands.onServerCommand(cmdText) function commands.onServerCommand(command)
local wolfCmd = string.lower(cmdText) local wolfCmd = string.lower(command)
local cmdArguments = {} local args = {}
if servercmds[wolfCmd] and servercmds[wolfCmd]["function"] then if servercmds[wolfCmd] and servercmds[wolfCmd]["function"] then
for i = 1, et.trap_Argc() - 1 do for i = 1, et.trap_Argc() - 1 do
table.insert(cmdArguments, et.trap_Argv(i)) table.insert(args, et.trap_Argv(i))
end end
return servercmds[wolfCmd]["function"](wolfCmd, tables.unpack(cmdArguments)) and 1 or 0 return servercmds[wolfCmd]["function"](wolfCmd, tables.unpack(args)) and 1 or 0
end end
local shrubCmd = cmdText local shrubCmd = command
if string.find(cmdText, "!") == 1 then if string.find(command, "!") == 1 then
shrubCmd = string.lower(string.sub(cmdText, 2, string.len(cmdText))) shrubCmd = string.lower(string.sub(command, 2, string.len(command)))
end end
if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then
for i = 1, et.trap_Argc() - 1 do for i = 1, et.trap_Argc() - 1 do
table.insert(cmdArguments, et.trap_Argv(i)) table.insert(args, et.trap_Argv(i))
end end
if not admincmds[shrubCmd]["hidden"] then if not admincmds[shrubCmd]["hidden"] then
commands.log(-1337, shrubCmd, cmdArguments) commands.log(-1337, shrubCmd, tables.unpack(args))
end end
return admincmds[shrubCmd]["function"](-1337, shrubCmd, tables.unpack(cmdArguments)) and 1 or 0 return admincmds[shrubCmd]["function"](-1337, shrubCmd, tables.unpack(args)) and 1 or 0
end end
end end
events.handle("onServerCommand", commands.onServerCommand) events.handle("onServerCommand", commands.onServerCommand)
function commands.onClientCommand(clientId, cmdText) function commands.onClientCommand(clientId, command)
local wolfCmd = string.lower(cmdText) local wolfCmd = string.lower(command)
local cmdArguments = {} local args = {}
-- mod-specific or custom commands loading -- mod-specific or custom commands loading
-- syntax: command arg1 arg2 ... argN -- syntax: command arg1 arg2 ... argN
if clientcmds[wolfCmd] and clientcmds[wolfCmd]["function"] and clientcmds[wolfCmd]["flag"] then if clientcmds[wolfCmd] and clientcmds[wolfCmd]["function"] and clientcmds[wolfCmd]["flag"] then
if clientcmds[wolfCmd]["flag"] == "" or auth.isPlayerAllowed(clientId, clientcmds[wolfCmd]["flag"]) then if clientcmds[wolfCmd]["flag"] == "" or auth.isPlayerAllowed(clientId, clientcmds[wolfCmd]["flag"]) then
for i = 1, et.trap_Argc() - 1 do for i = 1, et.trap_Argc() - 1 do
table.insert(cmdArguments, et.trap_Argv(i)) table.insert(args, et.trap_Argv(i))
end end
local isFinished = clientcmds[wolfCmd]["function"](clientId, wolfCmd, tables.unpack(cmdArguments)) local isFinished = clientcmds[wolfCmd]["function"](clientId, wolfCmd, tables.unpack(args))
if isFinished ~= nil then if isFinished ~= nil then
return isFinished and 1 or 0 return isFinished and 1 or 0
@ -236,20 +204,20 @@ function commands.onClientCommand(clientId, cmdText)
local clientCmd = nil local clientCmd = nil
if (wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_buddy") and string.find(et.trap_Argv(1), "/") == 1 then if (wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_buddy") and string.find(et.trap_Argv(1), "/") == 1 then
cmdArguments = util.split(et.trap_Argv(1), " ") args = util.split(et.trap_Argv(1), " ")
-- say "/command arg1 arg2 argN" -- say "/command arg1 arg2 argN"
if #cmdArguments > 1 then if #args > 1 then
clientCmd = string.sub(cmdArguments[1], 2, string.len(cmdArguments[1])) clientCmd = string.sub(args[1], 2, string.len(args[1]))
table.remove(cmdArguments, 1) table.remove(args, 1)
-- say /command arg1 arg2 argN -- say /command arg1 arg2 argN
else else
clientCmd = string.sub(et.trap_Argv(1), 2, string.len(et.trap_Argv(1))) clientCmd = string.sub(et.trap_Argv(1), 2, string.len(et.trap_Argv(1)))
for i = 2, et.trap_Argc() - 1 do for i = 2, et.trap_Argc() - 1 do
table.insert(cmdArguments, et.trap_Argv(i)) table.insert(args, et.trap_Argv(i))
end end
if cmdArguments[1] == et.trap_Argv(1) then table.remove(cmdArguments, 1) end if args[1] == et.trap_Argv(1) then table.remove(args, 1) end
end end
end end
@ -259,7 +227,7 @@ function commands.onClientCommand(clientId, cmdText)
if clientcmds[clientCmd] and clientcmds[clientCmd]["function"] and clientcmds[clientCmd]["chat"] then if clientcmds[clientCmd] and clientcmds[clientCmd]["function"] and clientcmds[clientCmd]["chat"] then
if clientcmds[clientCmd]["flag"] == "" or auth.isPlayerAllowed(clientId, clientcmds[clientCmd]["flag"]) then if clientcmds[clientCmd]["flag"] == "" or auth.isPlayerAllowed(clientId, clientcmds[clientCmd]["flag"]) then
return clientcmds[clientCmd]["function"](clientId, clientCmd, tables.unpack(cmdArguments)) and 1 or 0 return clientcmds[clientCmd]["function"](clientId, clientCmd, tables.unpack(args)) and 1 or 0
end end
end end
end end
@ -269,28 +237,28 @@ function commands.onClientCommand(clientId, cmdText)
-- syntax: say or say_* -- syntax: say or say_*
if (wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_buddy") and string.find(et.trap_Argv(1), "!") == 1 then if (wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_buddy") and string.find(et.trap_Argv(1), "!") == 1 then
cmdArguments = util.split(et.trap_Argv(1), " ") args = util.split(et.trap_Argv(1), " ")
-- syntax: say "!command arg1 arg2 ... argN"
if #cmdArguments > 1 then
shrubCmd = string.sub(cmdArguments[1], 2, string.len(cmdArguments[1]))
table.remove(cmdArguments, 1) -- syntax: say "!command arg1 arg2 ... argN"
if #args > 1 then
shrubCmd = string.sub(args[1], 2, string.len(args[1]))
table.remove(args, 1)
-- syntax: say !command arg1 arg2 ... argN -- syntax: say !command arg1 arg2 ... argN
else else
shrubCmd = string.sub(et.trap_Argv(1), 2, string.len(et.trap_Argv(1))) shrubCmd = string.sub(et.trap_Argv(1), 2, string.len(et.trap_Argv(1)))
for i = 2, et.trap_Argc() - 1 do for i = 2, et.trap_Argc() - 1 do
table.insert(cmdArguments, et.trap_Argv(i)) table.insert(args, et.trap_Argv(i))
end end
if cmdArguments[1] == et.trap_Argv(1) then table.remove(cmdArguments, 1) end if args[1] == et.trap_Argv(1) then table.remove(args, 1) end
end end
-- syntax: !command arg1 arg2 ... argN -- syntax: !command arg1 arg2 ... argN
elseif string.find(wolfCmd, "!") == 1 then elseif string.find(wolfCmd, "!") == 1 then
shrubCmd = string.sub(wolfCmd, 2, string.len(wolfCmd)) shrubCmd = string.sub(wolfCmd, 2, string.len(wolfCmd))
for i = 1, et.trap_Argc() - 1 do for i = 1, et.trap_Argc() - 1 do
table.insert(cmdArguments, et.trap_Argv(i)) table.insert(args, et.trap_Argv(i))
end end
end end
@ -301,10 +269,10 @@ function commands.onClientCommand(clientId, cmdText)
if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then
if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and auth.isPlayerAllowed(clientId, auth.PERM_TEAMCMDS)) or (wolfCmd == "!"..shrubCmd and auth.isPlayerAllowed(clientId, auth.PERM_SILENTCMDS)) then if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and auth.isPlayerAllowed(clientId, auth.PERM_TEAMCMDS)) or (wolfCmd == "!"..shrubCmd and auth.isPlayerAllowed(clientId, auth.PERM_SILENTCMDS)) then
if admincmds[shrubCmd]["flag"] ~= "" and auth.isPlayerAllowed(clientId, admincmds[shrubCmd]["flag"]) then if admincmds[shrubCmd]["flag"] ~= "" and auth.isPlayerAllowed(clientId, admincmds[shrubCmd]["flag"]) then
local isFinished = admincmds[shrubCmd]["function"](clientId, shrubCmd, tables.unpack(cmdArguments)) local isFinished = admincmds[shrubCmd]["function"](clientId, shrubCmd, tables.unpack(args))
if not admincmds[shrubCmd]["hidden"] then if not admincmds[shrubCmd]["hidden"] then
commands.log(clientId, shrubCmd, cmdArguments) commands.log(clientId, shrubCmd, tables.unpack(args))
end end
if isFinished and "!"..shrubCmd == wolfCmd then -- silent command via console, removes "unknown command" message if isFinished and "!"..shrubCmd == wolfCmd then -- silent command via console, removes "unknown command" message

View File

@ -0,0 +1,90 @@
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
-- Copyright (C) 2015-2017 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 players = require (wolfa_getLuaPath()..".players.players")
local files = require (wolfa_getLuaPath()..".util.files")
local settings = require (wolfa_getLuaPath()..".util.settings")
local logs = {}
function logs.writeServer(...)
local fileDescriptor = files.open(settings.get("g_logServer"), et.FS_APPEND)
local logLine = string.format("[%s] %s\n", os.date("%Y-%m-%d %H:%M:%S"), table.concat({...}, " "))
et.trap_FS_Write(logLine, string.len(logLine), fileDescriptor)
et.trap_FS_FCloseFile(fileDescriptor)
end
function logs.writeChat(clientId, type, ...)
local fileDescriptor = files.open(settings.get("g_logChat"), et.FS_APPEND)
local logLine
local clientGUID = clientId and players.getGUID(clientId) or "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
local clientName = clientId and players.getName(clientId) or "console"
if type == "priv" then
local args = {...}
local recipientName = players.getName(args[1])
logLine = string.format("[%s] %s: %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, string.upper(type), clientName, recipientName, table.concat({...}, " ", 2))
else
logLine = string.format("[%s] %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, string.upper(type), clientName, table.concat({...}, " "))
end
et.trap_FS_Write(logLine, string.len(logLine), fileDescriptor)
et.trap_FS_FCloseFile(fileDescriptor)
end
function logs.writeAdmin(clientId, command, victimId, ...)
local fileDescriptor = files.open(settings.get("g_logAdmin"), et.FS_APPEND)
local logLine
local clientGUID = clientId and players.getGUID(clientId) or "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
local clientName = clientId and players.getName(clientId) or "console"
local clientFlags = ""
local args = table.concat({...}, " ")
if settings.get("g_standalone") == 1 then
if victimId then
local victimName = players.getName(victimId)
logLine = string.format("[%s] %s: %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, clientName, command, victimName, args)
else
logLine = string.format("[%s] %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, clientName, command, args)
end
else
local levelTime = et.trap_Milliseconds() / 1000
if victimId then
local victimName = players.getName(victimId)
logLine = string.format("%3i:%02f: %i: %s: %s: %s: %s: %s: %s: \"%s\"\n", math.floor(levelTime / 60), (levelTime % 60), clientId, clientGUID, clientName, clientFlags, command, victimId, victimName, args)
else
logLine = string.format("%3i:%02f: %i: %s: %s: %s: %s: \"%s\"\n", math.floor(levelTime / 60), (levelTime % 60), clientId, clientGUID, clientName, clientFlags, command, args)
end
end
et.trap_FS_Write(logLine, string.len(logLine), fileDescriptor)
et.trap_FS_FCloseFile(fileDescriptor)
end
return logs

View File

@ -21,6 +21,8 @@ local events = require (wolfa_getLuaPath()..".util.events")
local settings = {} local settings = {}
local data = { local data = {
["g_logServer"] = "server.log",
["g_logChat"] = "chat.log",
["g_logAdmin"] = "admin.log", ["g_logAdmin"] = "admin.log",
["g_fileGreetings"] = "greetings.cfg", ["g_fileGreetings"] = "greetings.cfg",
["g_fileRules"] = "rules.cfg", ["g_fileRules"] = "rules.cfg",