how to get the current game state/match state

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 get the current game state/match state

Postby varunkishore » Wed May 02, 2018 11:09 am

hi ...now i'm creating one command like '' game_state"
it shows current state of the game like if a player is in warm_up means it show player is in warm_up,if player is playing in game means it shows player playing the game ,if player is playing second half means it shows second half likethat ...
is their any way to get the current state of the match ??
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: how to get the current game state/match state

Postby VinciT » Wed May 02, 2018 7:28 pm

You should be able to get all of that information from the GameRulesProxy entity.

This code should work, but for some reason I'm not getting the expected values.

Maybe someone else knows what the issue is?

In any case, here are all the properties for the entity as well:
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: how to get the current game state/match state

Postby satoon101 » Wed May 02, 2018 10:49 pm

I have not tested any of this, but I did see m_gamePhase and thought it might be helpful. A quick google search led me to this:
https://github.com/splewis/get5/blob/ma ... sp#L19-L25

I did print out that value locally with no players (including bots) on the server, and it returned 0:

Syntax: Select all

from filters.entities import EntityIter
def get_gamerules_entity():
for entity in EntityIter('gamerules', exact_match=False):
return entity
return None
entity = get_gamerules_entity()
print(entity.get_property_uchar('cs_gamerules_data.m_gamePhase'))


So, I imagine 0 is for match not even started, and 1 is likely for Warmup. But again, I have not tested that, so those are just assumptions.
Image
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: how to get the current game state/match state

Postby VinciT » Wed May 02, 2018 11:58 pm

Just tried m_gamePhase with me + bots for a full match (I set the mp_roundtime/mp_roundtime_defuse to 0.1 and turned off mp_freezetime to speed things up) and I kept getting 0.
Here's the SourceMod implementation/wrapper for GameRulesProxy: https://github.com/alliedmodders/source ... atives.cpp - maybe this can help?

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 19 guests