Addon Details

Watch - Add Favorite


Does this version work for you?
0
w00ts
w00t!2

roundthread library - Version 1

posted on 2007-11-02 11:20:23
by Chunky



Description

This lib is similary as gamethread lib but it has a new method which allow you to remove all the delayed commands. The only thing you have to do is to call the cancelAll method on the round_end event

Version Notes For 1

Updated on: 2007-11-02 11:20:23 EST by Chunky (View Zip Contents)
This lib is similary as gamethread lib but it has a new method which allow you to remove all the delayed commands. The only thing you have to do is to call the cancelAll method on the round_end event, I haven't found how to make this by default in the lib, any help? This second lib allow you to use the gamethread.py lib to delay commands during a map, example: [syntax="python"]import es import roundthread import gamethread def load(): es.msg("0 Hello world") roundthread.delayed(5, es.msg, "5 Hello world") roundthread.delayed(10, es.msg, "10 Hello world") roundthread.delayed(15, es.msg, "15 Hello world") roundthread.delayed(20, es.msg, "20 Hello world") roundthread.delayed(25, es.msg, "25 Hello world") roundthread.delayed(30, es.msg, "30 Hello world") gamethread.delayed(15, es.msg, "15 gamethread Hello world") gamethread.delayed(20, es.msg, "20 gamethread Hello world") def round_end(event_var): roundthread.cancelAll() def es_map_start(event_var): roundthread.cancelAll()[/syntax] This example will display during a round all the Hello World as normally, but if the round ends in the 10 firsts seconds for example you will only see the "15 gamethread Hello world" and "20 gamethread Hello world" during the next round. When you call this method all delayed commands (for all the scripts using roundthread library) will be cancelled, (thats why this will be usefull to don't have to call the cancelAll command in each script) My script allow you to cancel delayed commands at the end of a map too, just call this method in the es_map_start event. You can easily implement theses methods in the gamethread library if you wanna stop gamethreads delayes commands at the maps end. The 2 new methods are: In the TimeSortedQueue class: [syntax="python"]def removeAll(self): with self.lock: while bool(self.nodes): for item in self.nodes: self.nodes.remove(item)[/syntax] and in the public part: [syntax="python"]def cancelAll(): ''' Cancel all delayed commands ''' timeq.removeAll()[/syntax] To install it you have to create a text file named [b]roundthread.py[/b] and put it into the [b]cstrike\addons\eventscripts\_libs\python[/b] directory.

( Previous Versions )