repeat not stopping

Please post any questions about developing your plugin here. Please use the search function before posting!
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

repeat not stopping

Postby 8guawong » Fri Dec 05, 2014 4:08 pm

Syntax: Select all

from engines.server import engine_server
from listeners import LevelInit
from random import choice
from path import Path
from listeners.tick import TickRepeat
from listeners.tick import TickRepeatStatus
import core

map_list = []

def load():
base_path = Path(__file__).parent
with open(base_path + '/maps.txt', 'r') as open_allowed_file:
for line in open_allowed_file:
map_list.append(line.rstrip())

@LevelInit
def my_level_init_function(mapname):
map_check = TickRepeat(check_map, mapname)
if map_check.status is TickRepeatStatus.RUNNING:
map_check.stop()
map_check.start(120, 1)
else:
map_check.start(120, 1)

def check_map(mapname):
print(mapname)
if core.global_vars.map_name == mapname:
engine_server.server_command('map %s\n' % choice(map_list))


want to change the map if the map is still the same after x amount of time
but if start de_dust2 then i change to de_dust before 120 second is up
it still printed mapname after i changed map like the repeat did not stop @_@

-------- edit -------
oh i think i figured it out

Syntax: Select all

@LevelInit
def my_level_init_function(mapname):
map_check = TickRepeat(check_map, mapname)

resetting the map_check after map change :rolleyes:

is there a map_end event we can use???

---- edit ----
from listeners import LevelShutdown :cool:

final code should work

Syntax: Select all

from engines.server import engine_server
from listeners import LevelInit
from listeners import LevelShutdown
from random import choice
from path import Path
from listeners.tick import TickRepeat
from listeners.tick import TickRepeatStatus
import core

map_list = []
map_check = 0

def load():
base_path = Path(__file__).parent
with open(base_path + '/maps.txt', 'r') as open_allowed_file:
for line in open_allowed_file:
map_list.append(line.rstrip())

def unload():
if map_check.status is TickRepeatStatus.RUNNING:
map_check.stop()

@LevelInit
def my_level_init_function(mapname):
global map_check
map_check = TickRepeat(check_map, mapname)
map_check.start(120, 1)

def check_map(mapname):
if core.global_vars.map_name == mapname:
engine_server.server_command('map %s\n' % choice(map_list))

@LevelShutdown
def my_level_shutdown_function():
if map_check.status is TickRepeatStatus.RUNNING:
map_check.stop()

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 40 guests