Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local logTable = { ["Admin"] = "", ["Nick"] = "", ["Kill"] = "", ["Chat"] = "", ["Connect"] = "", ["Login"] = "", ["Register"] = "", ["Weapon"] = "", ["Error"] = "", ["KillPush"] = "", ["DBSave"] = "", ["Mute"] = "", ["Report"] = "",
- ["VIPFile"] = "", ["Warns"] = "" }
- local logByDate = { ["Admin"] = true, ["Nick"] = false, ["Kill"] = true, ["Chat"] = true, ["Connect"] = true, ["Login"] = true, ["Register"] = true, ["Weapon"] = true, ["Report"] = false, ["Error"] = false, ["KillPush"] = false,
- ["DBSave"] = false, ["Mute"] = false, ["VIPFile"] = false, ["Warns"] = false }
- local logPath = { ["Admin"] = "Logs/Admin/", ["Nick"] = "Logs/nickchange.log", ["Kill"] = "Logs/Kills/", ["Chat"] = "Logs/Chat/", ["Connect"] = "Logs/Connect/", ["Login"] = "Logs/Login/", ["Register"] = "Logs/Register/",
- ["Weapon"] = "Logs/Waffen/", ["Error"] = "Logs/fehler.log", ["KillPush"] = "Logs/killpush.log", ["DBSave"] = "Logs/dbsave.log", ["Mute"] = "Logs/mutes.log", ["Report"] = "Logs/Report.log", ["VIPFile"] = "Logs/VIPFile.log",
- ["Warns"] = "Logs/Warns.log" }
- local function saveLogEntrys ( )
- local curtime = getRealTime()
- local date = curtime.monthday.."_"..(curtime.month+1).."_"..(curtime.year-100)
- local thelog = nil
- for category, string in pairs ( logTable ) do
- if string ~= "" then
- if logByDate[category] then
- if fileExists ( logPath[category]..date..".log" ) then
- thelog = fileOpen ( logPath[category]..date..".log" )
- else
- thelog = fileCreate ( logPath[category]..date..".log" )
- fileWrite ( thelog, "- "..category.." -\n" )
- end
- else
- if fileExists ( logPath[category] ) then
- thelog = fileOpen ( logPath[category] )
- else
- thelog = fileCreate ( logPath[category] )
- fileWrite ( thelog, "- "..category.." -\n" )
- end
- end
- fileSetPos ( thelog, fileGetSize ( thelog ) + 1 )
- fileWrite ( thelog, string )
- fileClose ( thelog )
- end
- logTable[category] = ""
- end
- end
- setTimer ( saveLogEntrys, 1*60*1000, 0 )
- addEventHandler ( "onResourceStop", resourceRoot, saveLogEntrys, true, "low-9999" )
- -- Admin-Logs --
- function enterAdminLogEntry ( theAdmin, command, info )
- local curtime = getRealTime()
- if command == "tmute" or command == "pmute" then
- logTable["Mute"] = logTable["Mute"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(theAdmin) and getPlayerName ( theAdmin ) or theAdmin ).." hat den Befehl "..command.." benutzt. [Weitere Infos] "..info.."\n"
- else
- logTable["Admin"] = logTable["Admin"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(theAdmin) and getPlayerName ( theAdmin ) or theAdmin ).." hat den Befehl "..command.." benutzt. [Weitere Infos] "..info.."\n"
- end
- end
- -- Nickchange-Logs --
- function enterNickLogEntry ( player, newnick )
- local curtime = getRealTime()
- logTable["Nick"] = logTable["Nick"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." hat sich zu "..newnick.." unbenannt.\n"
- end
- -- Kill-Logs --
- function createKillLogMessage ( killer, victim )
- local curtime = getRealTime()
- logTable["Kill"] = logTable["Kill"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement ( killer ) and getPlayerName ( killer ) or killer ).." hat "..( isElement ( victim ) and getPlayerName ( victim ) or victim ).." getötet.\n"
- end
- -- Chat-Logs --
- function storeChatInLog ( msg )
- local curtime = getRealTime()
- logTable["Chat"] = logTable["Chat"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
- end
- --connectLogs
- addEventHandler ( "onPlayerConnect", root, function ( playerNick, playerIP, _, playerSerial )
- local curtime = getRealTime()
- logTable["Connect"] = logTable["Connect"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..playerNick.." connected with the serial "..playerSerial.." and the ip "..playerIP..".\n"
- end )
- --loginLogs
- function playerLLogin ( player, playerSerial, playerIP )
- local curtime = getRealTime()
- logTable["Login"] = logTable["Login"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." logged in with the serial "..playerSerial.." and the IP "..playerIP.."\n"
- end
- --registerLogs
- function playerLRegister (player, playerSerial, playerIP)
- local curtime = getRealTime()
- logTable["Register"] = logTable["Register"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." registered with the serial "..playerSerial.." and the IP "..playerIP.."\n"
- end
- -- Waffen-Logs --
- function enterWeaponLogEntry ( player, weapon )
- local curtime = getRealTime()
- logTable["Weapon"] = logTable["Weapon"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." - "..weapon.."\n"
- end
- -- Fehler-Logs --
- function logError ( msg )
- local curtime = getRealTime()
- logTable["Error"] = logTable["Error"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
- end
- -- Kill-Push-Logs --
- function logKillPush ( msg )
- local curtime = getRealTime()
- logTable["KillPush"] = logTable["KillPush"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
- end
- -- Report-Logs --
- function logReport ( msg )
- local curtime = getRealTime()
- logTable["Report"] = logTable["Report"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
- end
- -- VIP-File-Logs --
- function logVIPFile ( msg )
- local curtime = getRealTime()
- logTable["VIPFile"] = logTable["VIPFile"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
- end
- function logPlayerSavedDatas ( array )
- if array and array[1] then
- local curtime = getRealTime()
- for i=1, #array do
- array[i] = tostring ( array[i] )
- end
- local str = table.concat ( array, ", " )
- logTable["DBSave"] = logTable["DBSave"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..str.."\n"
- end
- end
- function enterWarnLogEntry ( player, msg )
- local curtime = getRealTime()
- logTable["Warns"] = logTable["Warns"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." - "..msg.."\n"
- end
- addEventHandler ( "onDebugMessage", root, function ( message, level, file, line )
- if level < 3 then
- logError ( tostring ( file ).." Zeile "..tostring ( line )..": "..tostring ( message ) )
- end
- end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement