summaryrefslogtreecommitdiffstats
path: root/Plugins/ChatLog.lua
blob: 9f86a708635773f38a0836ad1a71f8d82ae2006f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local ChatLogPlugin = {}
ChatLogPlugin.__index = ChatLogPlugin

function ChatLogPlugin:new()
   local t = {}
   setmetatable(t, ChatLogPlugin)
   local w = Lua__cPlugin:new()
   tolua.setpeer(w, t)
   w:tolua__set_instance(w)
   return w
end

function ChatLogPlugin:OnDisable()
	Log( self:GetName() .. " v." .. self:GetVersion() .. " is shutting down..." )
end

function ChatLogPlugin:Initialize()
	self:SetName( "ChatLog" )
	self:SetVersion( 1 )

	PluginManager = cRoot:Get():GetPluginManager()
	PluginManager:AddHook( self, cPluginManager.E_PLUGIN_CHAT )

	self.Logger = cMCLogger:new_local("ChatLog"..GetTime()..".txt")
	self.Logger:LogSimple("--- ChatLog started ---", 1);

	Log( "Initialized " .. self:GetName() .. " v." .. self:GetVersion() )
	return true
end

function ChatLogPlugin:OnChat( Message, Player )
	Server = cRoot:Get():GetServer()

	-- Lets get loggin'
	self.Logger:LogSimple(Player:GetName() .. ": " .. Message, 1);

	return false
end

Plugin = ChatLogPlugin:new()
cRoot:Get():GetPluginManager():AddPlugin( Plugin )