Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.09 KB | None | 0 0
  1.  
  2. local logTable = { ["Admin"] = "", ["Nick"] = "", ["Kill"] = "", ["Chat"] = "", ["Connect"] = "", ["Login"] = "", ["Register"] = "", ["Weapon"] = "", ["Error"] = "", ["KillPush"] = "", ["DBSave"] = "", ["Mute"] = "", ["Report"] = "",
  3. ["VIPFile"] = "", ["Warns"] = "" }
  4. local logByDate = { ["Admin"] = true, ["Nick"] = false, ["Kill"] = true, ["Chat"] = true, ["Connect"] = true, ["Login"] = true, ["Register"] = true, ["Weapon"] = true, ["Report"] = false, ["Error"] = false, ["KillPush"] = false,
  5. ["DBSave"] = false, ["Mute"] = false, ["VIPFile"] = false, ["Warns"] = false }
  6. local logPath = { ["Admin"] = "Logs/Admin/", ["Nick"] = "Logs/nickchange.log", ["Kill"] = "Logs/Kills/", ["Chat"] = "Logs/Chat/", ["Connect"] = "Logs/Connect/", ["Login"] = "Logs/Login/", ["Register"] = "Logs/Register/",
  7. ["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",
  8. ["Warns"] = "Logs/Warns.log" }
  9.  
  10.  
  11. local function saveLogEntrys ( )
  12. local curtime = getRealTime()
  13. local date = curtime.monthday.."_"..(curtime.month+1).."_"..(curtime.year-100)
  14. local thelog = nil
  15. for category, string in pairs ( logTable ) do
  16. if string ~= "" then
  17. if logByDate[category] then
  18. if fileExists ( logPath[category]..date..".log" ) then
  19. thelog = fileOpen ( logPath[category]..date..".log" )
  20. else
  21. thelog = fileCreate ( logPath[category]..date..".log" )
  22. fileWrite ( thelog, "- "..category.." -\n" )
  23. end
  24. else
  25. if fileExists ( logPath[category] ) then
  26. thelog = fileOpen ( logPath[category] )
  27. else
  28. thelog = fileCreate ( logPath[category] )
  29. fileWrite ( thelog, "- "..category.." -\n" )
  30. end
  31. end
  32. fileSetPos ( thelog, fileGetSize ( thelog ) + 1 )
  33. fileWrite ( thelog, string )
  34. fileClose ( thelog )
  35. end
  36. logTable[category] = ""
  37. end
  38. end
  39. setTimer ( saveLogEntrys, 1*60*1000, 0 )
  40. addEventHandler ( "onResourceStop", resourceRoot, saveLogEntrys, true, "low-9999" )
  41.  
  42.  
  43. -- Admin-Logs --
  44. function enterAdminLogEntry ( theAdmin, command, info )
  45. local curtime = getRealTime()
  46. if command == "tmute" or command == "pmute" then
  47. 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"
  48. else
  49. 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"
  50. end
  51. end
  52.  
  53.  
  54. -- Nickchange-Logs --
  55. function enterNickLogEntry ( player, newnick )
  56. local curtime = getRealTime()
  57. logTable["Nick"] = logTable["Nick"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." hat sich zu "..newnick.." unbenannt.\n"
  58. end
  59.  
  60.  
  61. -- Kill-Logs --
  62. function createKillLogMessage ( killer, victim )
  63. local curtime = getRealTime()
  64. 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"
  65. end
  66.  
  67.  
  68. -- Chat-Logs --
  69. function storeChatInLog ( msg )
  70. local curtime = getRealTime()
  71. logTable["Chat"] = logTable["Chat"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
  72. end
  73.  
  74.  
  75. --connectLogs
  76. addEventHandler ( "onPlayerConnect", root, function ( playerNick, playerIP, _, playerSerial )
  77. local curtime = getRealTime()
  78. logTable["Connect"] = logTable["Connect"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..playerNick.." connected with the serial "..playerSerial.." and the ip "..playerIP..".\n"
  79. end )
  80.  
  81.  
  82. --loginLogs
  83. function playerLLogin ( player, playerSerial, playerIP )
  84. local curtime = getRealTime()
  85. 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"
  86. end
  87.  
  88.  
  89. --registerLogs
  90. function playerLRegister (player, playerSerial, playerIP)
  91. local curtime = getRealTime()
  92. 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"
  93. end
  94.  
  95.  
  96. -- Waffen-Logs --
  97. function enterWeaponLogEntry ( player, weapon )
  98. local curtime = getRealTime()
  99. logTable["Weapon"] = logTable["Weapon"].."["..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..( isElement(player) and getPlayerName ( player ) or player ).." - "..weapon.."\n"
  100. end
  101.  
  102.  
  103. -- Fehler-Logs --
  104. function logError ( msg )
  105. local curtime = getRealTime()
  106. logTable["Error"] = logTable["Error"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
  107. end
  108.  
  109.  
  110. -- Kill-Push-Logs --
  111. function logKillPush ( msg )
  112. local curtime = getRealTime()
  113. logTable["KillPush"] = logTable["KillPush"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
  114. end
  115.  
  116. -- Report-Logs --
  117. function logReport ( msg )
  118. local curtime = getRealTime()
  119. logTable["Report"] = logTable["Report"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
  120. end
  121.  
  122. -- VIP-File-Logs --
  123. function logVIPFile ( msg )
  124. local curtime = getRealTime()
  125. logTable["VIPFile"] = logTable["VIPFile"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..msg.."\n"
  126. end
  127.  
  128.  
  129. function logPlayerSavedDatas ( array )
  130. if array and array[1] then
  131. local curtime = getRealTime()
  132. for i=1, #array do
  133. array[i] = tostring ( array[i] )
  134. end
  135. local str = table.concat ( array, ", " )
  136. logTable["DBSave"] = logTable["DBSave"].."["..curtime.monthday.."."..curtime.month+1 .."."..curtime.year+1900 .." - "..curtime.hour..":"..curtime.minute..":"..curtime.second.."] "..str.."\n"
  137. end
  138. end
  139.  
  140.  
  141. function enterWarnLogEntry ( player, msg )
  142. local curtime = getRealTime()
  143. 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"
  144. end
  145.  
  146. addEventHandler ( "onDebugMessage", root, function ( message, level, file, line )
  147. if level < 3 then
  148. logError ( tostring ( file ).." Zeile "..tostring ( line )..": "..tostring ( message ) )
  149. end
  150. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement