1
0

Plugins can modify message in the OnChat() hook handler.

FS #376

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1622 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2013-06-22 19:08:34 +00:00
parent 9dd0486faf
commit 943dcaea14
10 changed files with 27 additions and 13 deletions

View File

@@ -228,7 +228,7 @@ bool cPlugin_NewLua::OnBlockToPickups(cWorld * a_World, cEntity * a_Digger, int
bool cPlugin_NewLua::OnChat(cPlayer * a_Player, const AString & a_Message)
bool cPlugin_NewLua::OnChat(cPlayer * a_Player, AString & a_Message)
{
cCSLock Lock(m_CriticalSection);
const char * FnName = GetHookFnName(cPluginManager::HOOK_CHAT);
@@ -241,13 +241,17 @@ bool cPlugin_NewLua::OnChat(cPlayer * a_Player, const AString & a_Message)
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
tolua_pushstring (m_LuaState, a_Message.c_str());
if (!CallFunction(2, 1, FnName))
if (!CallFunction(2, 2, FnName))
{
return false;
}
bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0);
lua_pop(m_LuaState, 1);
bool bRetVal = (tolua_toboolean(m_LuaState, -2, 0) > 0);
if (lua_isstring(m_LuaState, -1))
{
a_Message = tolua_tostring(m_LuaState, -1, "");
}
lua_pop(m_LuaState, 2);
return bRetVal;
}