Add new register_event flags to filter humans and bots (bug 5768, r=me)

Former-commit-id: 15b0fba122
This commit is contained in:
Vincent Herbet 2013-07-02 11:22:43 +02:00
parent 15572e2d61
commit 1026edec6c
3 changed files with 20 additions and 4 deletions

View File

@ -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;

View File

@ -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

View File

@ -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: