Restarting round when timer reaches 00:01

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Omniwolf
Junior Member
Posts: 10
Joined: Tue Aug 09, 2016 9:45 pm

Restarting round when timer reaches 00:01

Postby Omniwolf » Wed Aug 24, 2016 5:52 pm

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)
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Restarting round when timer reaches 00:01

Postby iPlayer » Wed Aug 24, 2016 6:04 pm

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 :)
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 15 guests