Results 1 to 5 of 5

Thread: Game Events

  1. Administrator Bunni's Avatar
    Join Date
    08-29-07
    Posts
    14,279
    Post Thanks / Like
    Blog Entries
    7
    Stat Links

    Game Events Game Events Game Events Game Events Game Events
    Gamer IDs

    Steam ID: bunni Bunni's Originid: Dr_Bunni
    #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?

  2. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Game Events
    #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.

  3. Registered TeamPlayer
    Join Date
    06-02-07
    Posts
    173
    Post Thanks / Like
    #3

    Re: Game Events

    A word of warning: some events don't seem to fire exactly when you'd expect them too.

  4. Administrator Bunni's Avatar
    Join Date
    08-29-07
    Posts
    14,279
    Post Thanks / Like
    Blog Entries
    7
    Stat Links

    Game Events Game Events Game Events Game Events Game Events
    Gamer IDs

    Steam ID: bunni Bunni's Originid: Dr_Bunni
    #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:
    Quote Originally Posted by daemons.py
    events.addListener(events.EVENT_MAP_STARTED, mapVotingDaemon._mapStarted)
    events.addListener(events.EVENT_MAP_ENDED, mapVotingDaemon._mapEnded)
    events.addListener(events.EVENT_PLAYER_DISCONNECTE D, mapVotingDaemon._playerDisconnected)
    This registers the event and when occurs passes relevent information to the assigned function, right?
    But then my understanding cannot be right as there is an event broadcasting function:
    Quote Originally Posted by client.py
    def _purgePlayer(self, p):
    try:
    self.players.remove(p)
    except ValueError:
    logger.error("Player %d (%s) doesn't exist in player list during purge" % (p.pid, p.address))
    try:
    del self.edictMap[ p.edict ]
    except KeyError:
    logger.error("Player %d (%s) doesn't exist in edict map during purge" % (p.pid, p.address))
    self._removeSteamIdCheck(p)
    if logger.logTarget is p:
    logger.logTarget = None
    events.broadcast(events.EVENT_PLAYER_DISCONNECTED, p)
    p.dispose()
    Whats the difference between addlistener and broadcast? Why one here and not the other?

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


  5. Registered TeamPlayer
    Join Date
    10-29-07
    Posts
    4,953
    Post Thanks / Like
    Stat Links

    Game Events
    #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)
    With the above line its going to be listening for game-generated round_end events.


    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)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Title