Page 1 of 1

how to catch the halftime

Posted: Sat May 05, 2018 9:07 am
by varunkishore
hi any one tell ??
how to catch the halftime
i tried this method to get the

Code: Select all

round played = gamerules.get_property_short('cs_gamerules_data.m_totalRoundsPlayed'
it returns -1 that's it
the i tried totalrounds

Code: Select all

maxrounds = ConVar('mp_maxrounds').get_int()
it return the correct value
but i can't get the how many rounds i played!!i need to get how many roundplayed by player

Re: how to catch the halftime

Posted: Sat May 05, 2018 10:07 am
by L'In20Cible
You could always keep a count yourself I guess. Something like this maybe (untested):

Syntax: Select all

from cvars import ConVar
from events import Event
from listeners import OnLevelInit

mp_maxrounds = ConVar('mp_maxrounds')
rounds_played = int()

@OnLevelInit
def on_level_init(map_name):
global rounds_played
rounds_played = int()

@Event('round_start')
def round_start(game_event):
global rounds_played
rounds_played = rounds_played + 1

def is_halftime():
return rounds_played >= (mp_maxrounds.get_int() / 2)

Re: how to catch the halftime

Posted: Sat May 05, 2018 11:43 am
by satoon101

Re: how to catch the halftime

Posted: Tue May 08, 2018 12:35 pm
by varunkishore
i use this code to get the halftime but i can't get the correct the halftime ! because it calculated the warm up, draw matches ....
i wrote the plugin if the match goes halftime ..i use to print the second half but can't print??
what mistake i did ?

Code: Select all

from cvars import ConVar
from events import Event
from listeners import OnLevelInit

mp_maxrounds = ConVar('mp_maxrounds')
rounds_played = int()

@OnLevelInit
def on_level_init(map_name):
    global rounds_played
    rounds_played = int()

@Event('round_start')
def round_start(game_event):
    global rounds_played
    rounds_played = rounds_played + 1
 
@TypedSayCommand('.m')
def cmd_on_test2(command_info):
    if rounds_played >= (mp_maxrounds.get_int() / 2):
        print("second round play")

Re: how to catch the halftime

Posted: Tue May 08, 2018 3:19 pm
by decompile
How about adding this:

Syntax: Select all

@Event('cs_intermission')
def cs_intermission(game_event):
global rounds_played
rounds_played = 0


You can use the Syntax Highlighting for Python code instead of block code.

Re: how to catch the halftime

Posted: Tue May 08, 2018 8:40 pm
by satoon101
Definitely check out what decompile said. That should really be all you need.

As for handling warmup in the other code, you should be able to use the round_end event to check whether the match is starting. I don't know all the reasons for round_end in CS:GO. I think we used to have a listing of them on our original wiki (which would have been around 5 years ago). If I have time this weekend, I'll see if I can get a listing and add that to the wiki for both CS:S and CS:GO.