Results 1 to 5 of 5
Thread: Game Events
-
12-18-08, 05:37 PM #1
Game Events
How are we getting them? Do we have a list of all the events any where, or a place i could go look?
-
12-18-08, 06:15 PM #2
Re: Game Events
hl2sdk.addGameEventListener (or something like it, check out the map voting manager in daemons.py, it uses it)
The list of game events isn't officially published anywhere i've found, but the metamod team put together a list of the ones their aware of. Unfortunately, it's poorly documented.
http://wiki.alliedmods.net/Game_Events_%28Source%29
I'm not sure if you've worked with events before, so if you haven't, here's the basics:
All events have string names, and you register/unregister for them at any time. When an even comes in, it's passed with a set of parameters in the form of a map/hashtable. Keys are always strings, but values can be strings/numbers/etc. You need to know what type the value is, and then you use the appropriate "getter" to access it. So for instance for round win events, there is a key/value pair called "team_id", which stores an int. So you would get that value by doing event.getInt("team_id");
Other than that, the real trick to working with game events is (1) finding the event you're looking for, and (2) understanding the parameters that are passed with it, as there is little documentation on them.
-
12-19-08, 06:22 PM #3
Re: Game Events
A word of warning: some events don't seem to fire exactly when you'd expect them too.
-
12-22-08, 01:40 PM #4
Re: Game Events
few more questions:
im not quite sure i understand how we are monitoring the events.
for example matti passes all defined events to the addon.
how does lonestar see and manage events?
Let me make sure what i believe i understand so far is correct:
Originally Posted by daemons.py
But then my understanding cannot be right as there is an event broadcasting function:
Originally Posted by client.py
To who is the even being broadcasted to? The listeners? Then who listens for the broadcast? Perhaps i am over complicating this but id rather have a full understanding...
-
12-22-08, 05:09 PM #5
Re: Game Events
To clarify there are two origins of events, and each has it's own way to listen to those events
To listen to SDK-originating events, you call hl2sdk.addGameEventListener("eventname", someFunction), and when the SDK broadcasts the "eventname" event, LoneStar will make sure someFunction is called.
The MapVotingDaemon class of daemons.py has an example of using the above:
Code:sdk.addGameEventListener("round_end", self._handleRoundEnd)
In addition to those events, LoneStar broadcasts LoneStar-specific events that do not originate from the game engine. The event module is what handles those events. So events.addListener is how you register to listen to the events, and events.broadcast is how LoneStar fires off an event to those listeners.
The quotes you have above are of this event system.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks