Events in SourceMod

Today we’re introducing another wiki article: Events (SourceMod Scripting).

Events are one of the nicest additions to HL2, providing a message passing system similar to network messages, but more user friendly and much easier to debug. You’ll notice one major piece missing from the API: enumeration. Event properties are not enumerable.

Unfortunately, this was only a feature in Valve’s original API, IGameEventManager. When Valve added IGameEventManager2 as a more optimized API, they never bothered to expose the KeyValues functionality implicit in IGameEvent (implemented as CGameEvent). Since the original API is deprecated, SourceMod uses the newer version.

Of course, SourceMod’s event API is completely unrelated to AMX Mod X’s register_event, which was based on user messages. The Half-Life 2 game event manager only touches netcode when it transmits events (for which there is a special svc code). (AMX Mod X’s function should have been named register_message from the start.)

Leave a Reply

You must be logged in to post a comment.