how to catch the halftime

Please post any questions about developing your plugin here. Please use the search function before posting!
varunkishore
Junior Member
Posts: 11
Joined: Wed Mar 28, 2018 6:47 am

how to catch the halftime

Postby varunkishore » Sat May 05, 2018 9:07 am

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
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: how to catch the halftime

Postby L'In20Cible » Sat May 05, 2018 10:07 am

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)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: how to catch the halftime

Postby satoon101 » Sat May 05, 2018 11:43 am

Image
varunkishore
Junior Member
Posts: 11
Joined: Wed Mar 28, 2018 6:47 am

Re: how to catch the halftime

Postby varunkishore » Tue May 08, 2018 12:35 pm

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")
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: how to catch the halftime

Postby decompile » Tue May 08, 2018 3:19 pm

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.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: how to catch the halftime

Postby satoon101 » Tue May 08, 2018 8:40 pm

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.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 16 guests