2
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here

NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

Author Topic: Creating new events  (Read 5838 times)

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 984
    • GitHub
Creating new events
« on: February 20, 2012, 08:24:32 PM »
Hi. I added some information to my games.log file and I would like to parse those info in order to create new events:

1st type of log lines:

  0:00 Callvote: 0 nextmap ut4_swim
  0:00 Callvote: 0 map ut4_casa
  0:00 Callvote: 0 cyclemap
  0:00 Callvote: 0 kick Dude
  0:00 Callvote: 0 reload
  0:00 Callvote: 0 restart

basically is: Callvote: <player cid> <vote type> <additional info>

2nd type of log lines:

  0:00 Vote: 1 yes
  0:00 Vote: 0 no

and again: Vote: <player cid> <yes/no>

I would like to create 3 new events:

EVT_CALLVOTE
EVT_VOTE_YES
EVT_VOTE_NO

in this way I can track votes via b3bot and allow different type of users (guest,user,regualar,...) to have different voting privileges

I'm currently using the iourt41.py parser v 1.11.4

Any help will be appreciated
Thanks

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Creating new events
« Reply #1 on: February 20, 2012, 09:56:31 PM »
here is an example of a parser which inherits from the official B3 parser for Urban Terror and adds 2 events :

EVT_CLIENT_CALLVOTE and EVT_CLIENT_VOTE

if evt is the event object created for the line "0:00 Callvote: 0 map ut4_casa", then
evt.client is the client object for the player connected on slot 0
evt.data['type'] == 'map'
evt.data['info'] == 'ut4_casa'

if evt is the event object created for the line "0:00 Vote: 1 yes", then
evt.client is the client object for the player connected on slot 1
evt.data == 'yes'


To use this parser, copy the file iourt41callvote.py in the parsers folder in your B3 installation folder.
modify your b3.xml to use the parser named "iourt41callvote"

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 984
    • GitHub
Re: Creating new events
« Reply #2 on: February 20, 2012, 10:22:00 PM »
Wow...wonderful...thanks for the help ^^

Offline Leito

  • Beta Testers
  • Full Member
  • *
  • Posts: 107
Re: Creating new events
« Reply #3 on: March 15, 2012, 05:20:13 AM »
How did you manage to send lines to games.log Mr. Click? Or are you just parsing qconsole.log?

Thanks for that Courgette. I'm changing my parser a bit to more mimmic yours (yours is cleaner).

Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 984
    • GitHub
Re: Creating new events
« Reply #4 on: April 22, 2012, 01:21:48 AM »
Well, I edited the binary source code to log /callvote and /vote events ^^

Offline Beber888

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 179
Re: Creating new events
« Reply #5 on: June 28, 2012, 09:26:36 AM »
I'm looking for a list of events and additional data from B3. I use UrT.
In the event.py plugin some event are written but in q3rcon.py or iourt41.py there is more....
Python, Php, UrT SourceCode

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Creating new events
« Reply #6 on: July 02, 2012, 09:36:59 PM »
the events you will find in the b3/events.py file are events that can be used by all plugins whatever the game B3 is connected to.

But some games have additional specific events which are added at runtime. You can find them in the 'statup' method of game parsers (and inherited from parsers)

For instance, in the iourt41.py file we find 3 UrT specific events :
Code: [Select]
self.Events.createEvent('EVT_GAME_FLAG_RETURNED', 'Flag returned')
        self.Events.createEvent('EVT_CLIENT_GEAR_CHANGE', 'Client gear change')
        self.Events.createEvent('EVT_SURVIVOR_WIN', 'Survivor Winner')

in q3rcon.py there are no new B3 event created. The code 'self._stopEvent' in q3rcon.py is for python thread events which are a mechanism to synchronize multiple threads.

Offline Fragmeister

  • Full Member
  • ***
  • Posts: 78
    • Serveur FRAG on Urban terror
Re: Creating new events
« Reply #7 on: April 07, 2013, 11:03:23 PM »
But some games have additional specific events which are added at runtime. You can find them in the 'statup' method of game parsers (and inherited from parsers)

For instance, in the iourt41.py file we find 3 UrT specific events :
Code: [Select]
self.Events.createEvent('EVT_GAME_FLAG_RETURNED', 'Flag returned')
        self.Events.createEvent('EVT_CLIENT_GEAR_CHANGE', 'Client gear change')
        self.Events.createEvent('EVT_SURVIVOR_WIN', 'Survivor Winner')

in q3rcon.py there are no new B3 event created. The code 'self._stopEvent' in q3rcon.py is for python thread events which are a mechanism to synchronize multiple threads.
I've a Urt Bomb server (play by rounds) and i would like to create a command (!balend) who balance teams at the end of the current round, because i don't !bal in the middle of the round otherwise some player won't be able to play until the next round. So i've to use the event EVT_SURVIVOR_WIN, but I don't know how to use it...
Does i have to write
Code: python [Select]
self.Events.createEvent('EVT_SURVIVOR_WIN', 'Survivor Winner')

and then
Code: python [Select]
self.registerEvent(b3.events.EVT_SURVIVOR_WIN)

and finally
Code: python [Select]
    def onEvent(self, event):
        if event.type == b3.events.EVT_SURVIVOR_WIN:
            if self.balendasked == 1:
                self.cmd_pabalance()
                self.balendasked = 0

Is this correct like this?
Thank you in advance
« Last Edit: April 07, 2013, 11:06:31 PM by Fragmeister »
Website of my urt server : www.frag-urt.com/

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Creating new events
« Reply #8 on: April 07, 2013, 11:09:19 PM »
in a plugin you only need

Code: python [Select]
self.registerEvent(b3.events.EVT_SURVIVOR_WIN)  

and
Code: python [Select]
def onEvent(self, event):  
       if event.type == b3.events.EVT_SURVIVOR_WIN: 
           if self.balendasked == 1: 
               self.cmd_pabalance() 
               self.balendasked = 0 

« Last Edit: April 08, 2013, 09:52:07 AM by Courgette »

Offline Fragmeister

  • Full Member
  • ***
  • Posts: 78
    • Serveur FRAG on Urban terror
Re: Creating new events
« Reply #9 on: April 08, 2013, 12:46:28 PM »
Ok thanks it work !!
But i have register the event before :
Code: python [Select]
    self.registerEvent(b3.events.EVT_SURVIVOR_WIN)  

in :  
Code: python [Select]
def registerEvents(self):


But i've a problem : the balance is executed only if Blue/Red win by killing all other enemies, but in Bomb mode blue team can win by defusing the bomb (i've solve this problem by using EVT_CLIENT_ACTION) and red team can win by exploding the bomb and the event "bomb exploded" does not exist.
In the log of b3 i can see :
Code: log [Select]
130402 18:30:34	CONSOLE	'17:24 Pop!'
130402 18:30:34 VERBOSE 'line did not match format: Pop!'

How to create it ?
« Last Edit: April 08, 2013, 05:15:11 PM by Fragmeister »
Website of my urt server : www.frag-urt.com/

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Creating new events
« Reply #10 on: April 08, 2013, 02:24:32 PM »
Thank you for reporting this.
I documentated this missing event in the bug tracker.

Also I wonder, do you have an event for when the defending team wins by killing all attacking team members ?

Offline Fragmeister

  • Full Member
  • ***
  • Posts: 78
    • Serveur FRAG on Urban terror
Re: Creating new events
« Reply #11 on: April 08, 2013, 07:03:31 PM »
Yes i have it's the EVT_SURVIVOR_WIN, this event is activated when a team kills all opponents and the round is over.
Can't i create the event myself ?
Because idk how many time i'll wait for this event will integrate b3  :-\
« Last Edit: April 08, 2013, 07:42:03 PM by Fragmeister »
Website of my urt server : www.frag-urt.com/

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Creating new events
« Reply #12 on: April 08, 2013, 08:10:16 PM »
You can test it in B3 v1.10dev.daily22 that you can find at http://files.cucurb.net/b3/daily

please report back if it worked for you or if you had any issue with it. It would be nice if you were also able to confirm the correct behavior with UrT 4.2.

In your plugin, listen for the new event EVT_BOMB_EXPLODED. If you are interested in the implementation details, see commit cb64ee50.

Offline Fragmeister

  • Full Member
  • ***
  • Posts: 78
    • Serveur FRAG on Urban terror
Re: Creating new events
« Reply #13 on: April 08, 2013, 09:29:17 PM »
I think that i can't test this because my b3 is hosted...
So i've to wait for next release to use it  :-\
And i'm using Urt 4.1
Website of my urt server : www.frag-urt.com/

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Creating new events
« Reply #14 on: April 09, 2013, 12:53:22 AM »
Install this temporary plugin which patch B3 so it has the new EVT_BOMB_EXPLODED event.

Make sure to load this plugin before all others.

 


Rate this page +1 at Google Search