Added paramater to CreateEvent to determine whether or not creation should be forced even if nothing is hooking/listening to the event.
Added paramater to CreateEvent to determine whether or not creation should be forced even if nothing is hooking/listening to the event.
1.1 --- a/core/EventManager.cpp Mon Apr 30 22:03:28 2007 +0000
1.2 +++ b/core/EventManager.cpp Mon Apr 30 22:53:27 2007 +0000
1.3 @@ -277,10 +277,10 @@
1.4 return EventHookErr_Okay;
1.5 }
1.6
1.7 -EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name)
1.8 +EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name, bool force)
1.9 {
1.10 EventInfo *pInfo;
1.11 - IGameEvent *pEvent = gameevents->CreateEvent(name, true);
1.12 + IGameEvent *pEvent = gameevents->CreateEvent(name, force);
1.13
1.14 if (pEvent)
1.15 {
2.1 --- a/core/EventManager.h Mon Apr 30 22:03:28 2007 +0000
2.2 +++ b/core/EventManager.h Mon Apr 30 22:53:27 2007 +0000
2.3 @@ -93,7 +93,7 @@
2.4 public:
2.5 EventHookError HookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post);
2.6 EventHookError UnhookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post);
2.7 - EventInfo *CreateEvent(IPluginContext *pContext, const char *name);
2.8 + EventInfo *CreateEvent(IPluginContext *pContext, const char *name, bool force=false);
2.9 void FireEvent(EventInfo *pInfo, bool bDontBroadcast=false);
2.10 void CancelCreatedEvent(EventInfo *pInfo);
2.11 private: // IGameEventManager2 hooks
3.1 --- a/core/smn_events.cpp Mon Apr 30 22:03:28 2007 +0000
3.2 +++ b/core/smn_events.cpp Mon Apr 30 22:53:27 2007 +0000
3.3 @@ -71,7 +71,7 @@
3.4
3.5 pContext->LocalToString(params[1], &name);
3.6
3.7 - pInfo = g_EventManager.CreateEvent(pContext, name);
3.8 + pInfo = g_EventManager.CreateEvent(pContext, name, params[2] ? true : false);
3.9
3.10 if (pInfo)
3.11 {
4.1 --- a/plugins/include/events.inc Mon Apr 30 22:03:28 2007 +0000
4.2 +++ b/plugins/include/events.inc Mon Apr 30 22:53:27 2007 +0000
4.3 @@ -81,9 +81,12 @@
4.4 * Creates a game event to be fired later.
4.5 *
4.6 * @param name Name of event.
4.7 - * @return Handle to event or INVALID_HANDLE if event doesn't exist.
4.8 + * @param force If set to true, this forces the event to be created even if it's not being hooked.
4.9 + * Note that this will not force it if the event doesn't exist at all.
4.10 + * @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't
4.11 + being hooked (unless force is true).
4.12 */
4.13 -native Handle:CreateEvent(const String:name[]);
4.14 +native Handle:CreateEvent(const String:name[], bool:force=false);
4.15
4.16 /**
4.17 * Fires a game event.