From 15b0fba122d8c2ba7024b74aa07b78a877cc9d8c Mon Sep 17 00:00:00 2001 From: Vincent Herbet Date: Tue, 2 Jul 2013 11:22:43 +0200 Subject: [PATCH] Add new register_event flags to filter humans and bots (bug 5768, r=me) --- amxmodx/CEvent.cpp | 16 ++++++++++++++-- amxmodx/CEvent.h | 4 +++- plugins/include/amxmodx.inc | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/amxmodx/CEvent.cpp b/amxmodx/CEvent.cpp index f34909c2..fe9c4fa8 100755 --- a/amxmodx/CEvent.cpp +++ b/amxmodx/CEvent.cpp @@ -46,7 +46,7 @@ EventsMngr::ClEvent::ClEvent(CPluginMngr::CPlugin* plugin, int func, int flags) m_FlagDead = true; m_FlagWorld = (flags & 1) ? true : false; // flag a - m_FlagPlayer = (flags & 2) ? true : false; // flag b + m_FlagClient = (flags & 2) ? true : false; // flag b m_FlagOnce = (flags & 4) ? true : false; // flag c if (flags & 24) @@ -55,6 +55,18 @@ EventsMngr::ClEvent::ClEvent(CPluginMngr::CPlugin* plugin, int func, int flags) m_FlagDead = (flags & 8) ? true : false; // flag d } + if( m_FlagClient ) + { + m_FlagPlayer = true; + m_FlagBot = true; + + if( flags & 96 ) + { + m_FlagPlayer = (flags & 32) ? true : false; // flag f + m_FlagBot = (flags & 64) ? true : false; // flag g + } + } + m_Stamp = 0.0f; m_Done = false; @@ -237,7 +249,7 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in if (pPlayer) { - if (!(*iter).m_FlagPlayer || (pPlayer->IsAlive() ? !(*iter).m_FlagAlive : !(*iter).m_FlagDead)) + if (!(*iter).m_FlagClient || (pPlayer->IsBot() ? !(*iter).m_FlagBot : !(*iter).m_FlagPlayer) || (pPlayer->IsAlive() ? !(*iter).m_FlagAlive : !(*iter).m_FlagDead)) { (*iter).m_Done = true; continue; diff --git a/amxmodx/CEvent.h b/amxmodx/CEvent.h index 89472bf0..422920d6 100755 --- a/amxmodx/CEvent.h +++ b/amxmodx/CEvent.h @@ -74,11 +74,13 @@ public: CPluginMngr::CPlugin *m_Plugin; // the plugin this ClEvent class is assigned to // flags - bool m_FlagPlayer; + bool m_FlagClient; bool m_FlagWorld; bool m_FlagOnce; bool m_FlagDead; bool m_FlagAlive; + bool m_FlagPlayer; + bool m_FlagBot; float m_Stamp; // for 'once' flag diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 64d189ec..fb7cdfa9 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -114,10 +114,12 @@ native console_cmd(id,const cmd[],any:...); /* Registers event on which a given function will be called * Flags: * "a" - global event. -* "b" - specified. +* "b" - specified to client (human player and bot). * "c" - send only once when repeated to other players. * "d" - call if is send to dead player. * "e" - to alive. +* "f" - to human player only ("b" flag must be set). +* "g" - to bot only ("b" flag must be set). * NOTE: Due to a long-standing bug that would break compatibility with old plugins, * the client id should be checked for alive/dead state if you use d or e. * Examples for conditions: