Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/27/14 in all areas

  1. Purple

    Getting chat logs

    Here i made something up real quick should work haven't tested it though. --[[ Chat logger v.1 by Purple (DRi*VJ*) 8/27/2014 Info: All logs are logged in a seperate file including PM, regular chat and team chat. They will be in your silent directory. If you would like to organize them put them into a folder called anything and change pm_logs = "pm_logs.txt" say_logs = "say_logs.txt" say_team_logs = "say_team_logs.txt" To your directory destination e.g. pm_logs = "logs/pm_logs.txt" Note: The file names must be the same in order for this to work. --]] pm_logs = "pm_logs.txt" say_logs = "say_logs.txt" say_team_logs = "say_team_logs.txt" date_fmt = "%Y-%m-%d, %H:%M:%S" version = "0.1" temp_name = {} c_Name = {} temp_sguid = {} temp_ip = {} pm = {} say = {} say_team = {} function et_InitGame(levelTime, randomSeed, restart) et.RegisterModname("pm_logs.lua "..version.." "..et.FindSelf()) maxclients = tonumber(et.trap_Cvar_Get("sv_maxclients")) for i = 0, maxclients - 1 do pm[i] = "" say[i] = "" say_team[i] = "" end end function et_ClientBegin( clientNum ) temp_name[clientNum] = et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "name" ) temp_sguid[clientNum] = et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "sil_guid" ) temp_ip[clientNum] = et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "ip" ) c_Name[clientNum] = et.Q_CleanStr( temp_name[clientNum] ) end function et_ClientCommand(clientNum, command) if command == "m" then if et.trap_Argc() > 1 then for i = 2, et.trap_Argc() - 1, 1 do pm[clientNum] = pm[clientNum] .. et.trap_Argv(i) .. " " end local sender = string.lower(et.trap_Argv(1)) info = os.date("%x %I:%M:%S%p") .. " | IP: [" .. temp_ip[clientNum] .. "] | From: "..playerName(clientNum).." | To: " .. sender .. " | Pm: [ " .. pm[clientNum] .. "] " .."\n" fd,len = et.trap_FS_FOpenFile(pm_logs, et.FS_APPEND) count = et.trap_FS_Write(info, string.len(info), fd) et.trap_FS_FCloseFile(fd) fd = nil for i = 0, maxclients - 1 do pm[i] = "" end end return 0 end if command == "say" then if et.trap_Argc() > 1 then for i = 1, et.trap_Argc() - 1, 1 do say[clientNum] = say[clientNum] .. et.trap_Argv(i) .. " " end info = os.date("%x %I:%M:%S%p") .. " | IP: [" .. temp_ip[clientNum] .. "] | Player: "..playerName(clientNum).." | say: [ " .. say[clientNum] .. "] " .."\n" fd,len = et.trap_FS_FOpenFile(say_logs, et.FS_APPEND) count = et.trap_FS_Write(info, string.len(info), fd) et.trap_FS_FCloseFile(fd) fd = nil for i = 0, maxclients - 1 do say[i] = "" end end return 0 end if command == "say_team" then if et.trap_Argc() > 1 then for i = 1, et.trap_Argc() - 1, 1 do say_team[clientNum] = say_team[clientNum] .. et.trap_Argv(i) .. " " end info = os.date("%x %I:%M:%S%p") .. " | IP: [" .. temp_ip[clientNum] .. "] | Player: "..playerName(clientNum).." | say_team: [ " .. say_team[clientNum] .. "] " .."\n" fd,len = et.trap_FS_FOpenFile(say_team_logs, et.FS_APPEND) count = et.trap_FS_Write(info, string.len(info), fd) et.trap_FS_FCloseFile(fd) fd = nil for i = 0, maxclients - 1 do say_team[i] = "" end end return 0 end return 0 end function playerName(id) local name = et.Info_ValueForKey(et.trap_GetUserinfo(id), "name") if name == "" then return "*unknown*" end return name end
    1 point
×
×
  • Create New...