I'm trying to create my own plugin. It is for showing the time left before bomb explosion.
At the end, I would like to show who picked and who dropped the bomb (but I don't know the commands)
For the moment, I write it with "SaysText2", but if it's possible to write it in the center screen, I prefere.
This is my code :
Syntax: Select all
# ../addons/source-python/plugins/Bomb/Bomb.py
"""Show delay before explosion."""
from listeners.tick import TickRepeat
from messages import SayText2
from events import Event
# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Create the cfg file
with ConfigManager(info.basename, 'Bomb') as config:
# Create the dissolver delay cvar
bomb_delay = _config.cvar(
'delay', 30, ConVarFlags.NONE,'Delay before bomb explosion')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('Bomb_planted')
def start_count_down():
delay = bomb_delay.get_int()
timer.start(1, delay)
def count_down():
while timer >= 0:
if timer == 20:
SayText2(message='Seconds remaining: {0}'.format(timer.remaining)).send()
elif timer == 10:
SayText2(message='Seconds remaining: {0}'.format(timer.remaining)).send()
elif timer <= 5:
SayText2(message='Seconds remaining: {0}'.format(timer.remaining)).send()
timer = TickRepeat(count_down)
But when I load it, I have this error :
If I dothis :
Syntax: Select all
def start_count_down():
# delay = bomb_delay.get_int()
timer.start(1, 30)
I have this error :
Can you help me please?
Thanks