Page 1 of 1

Restarting round when timer reaches 00:01

Posted: Wed Aug 24, 2016 5:52 pm
by Omniwolf
Im working on a plugin that when the round timer hits 00:01, the round auto restarts, this is what I got so far.

Code: Select all

@Event('tf_map_time_remaining')
def tf_map_time_remaining(event):
    if event     # This line I don't know what to write.
        engine_server.server_command('mp_restartgame 1\n')


Now, even though I got experience in Python, I don't have much in sourcepython, so can anyone help? What Im trying to get it to do is when it hits the time 00:01 it will restart the round after 10 seconds or so. (This code has probably got errors all over it, and its only 4 lines :P)

Re: Restarting round when timer reaches 00:01

Posted: Wed Aug 24, 2016 6:04 pm
by iPlayer
I'm not familiar with this event, but I suppose

Syntax: Select all

@Event('tf_map_time_remaining')
def tf_map_time_remaining(event):
if event['seconds'] <= 1:
engine_server.server_command('mp_restartgame 1')

Also, this is how you can restart the round without resetting scores: viewtopic.php?p=6414#p6414 (though, it might be a bit outdated because, afaik, SP now has a dedicated class for console commands).
Also, please use

Code: Select all

[syntax=py][/syntax]
instead of

Code: Select all

[code][/code]
to insert Python code :)