From bac750b24e673358ec55d3bf71c118a749fe5d0c Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 25 Jan 2014 11:25:22 +0100 Subject: Added "player destroying" and "player destroyed" hooks Hooks: HOOK_PLAYER_DESTROYING HOOK_PLAYER_DESTROYED Idea from: https://github.com/mc-server/MCServer/issues/473 --- src/Bindings/PluginLua.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/Bindings/PluginLua.cpp') diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 4c4664815..2b34e92c9 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -623,6 +623,46 @@ bool cPluginLua::OnPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_Blo +bool cPluginLua::OnPlayerDestroying(cPlayer & a_Player) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_DESTROYING]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + +bool cPluginLua::OnPlayerDestroyed(cPlayer & a_Player) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_DESTROYED]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + bool cPluginLua::OnPlayerEating(cPlayer & a_Player) { cCSLock Lock(m_CriticalSection); -- cgit v1.2.3 From dbbd47b96d3b3dd5ca0680eda8191808f30e3927 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 1 Feb 2014 13:27:44 +0100 Subject: Removed "player destroying" hook --- src/Bindings/PluginLua.cpp | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/Bindings/PluginLua.cpp') diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 2b34e92c9..7fc1db391 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -623,26 +623,6 @@ bool cPluginLua::OnPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_Blo -bool cPluginLua::OnPlayerDestroying(cPlayer & a_Player) -{ - cCSLock Lock(m_CriticalSection); - bool res = false; - cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_DESTROYING]; - for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) - { - m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res); - if (res) - { - return true; - } - } - return false; -} - - - - - bool cPluginLua::OnPlayerDestroyed(cPlayer & a_Player) { cCSLock Lock(m_CriticalSection); -- cgit v1.2.3