Page 1 of 1

CSGO: Change team score

Posted: Mon Dec 15, 2014 7:38 pm
by nullable
Is it possible to change team score in csgo game?

Posted: Mon Dec 15, 2014 8:22 pm
by satoon101
Yes, am pretty sure it is possible. I do not have time to test, so the following might not work. There are actually 3 different properties for the score:

  • m_scoreTotal - <BaseEntity>.score_total
  • m_scoreFirstHalf - <BaseEntity>.score_first_half
  • m_scoreSecondHalf - <BaseEntity>.score_second_half

Syntax: Select all

from filters.entity import EntityIter

def set_team_score(team, score):
for entity in EntityIter('cs_team_manager', return_types='entity'):
if entity.team != team:
continue
entity.score_total = score

Posted: Mon Dec 15, 2014 8:48 pm
by nullable
As I understand entity it doesn't have score_total. I have print dir object:

Syntax: Select all

def set_team_score(team, score):
for entity in EntityIter('cs_team_manager', return_types='entity'):
if entity.team != team:
continue
print(dir(entity))
entity.score_total = score


Syntax: Select all

['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_edict', '_entities', '_get_function', '_get_offset', '_get_property', '_get_virtual', '_index', '_set_offset', '_set_property', 'basehandle', 'classname', 'color', 'damage', 'datamaps', 'edict', 'entities', 'functions', 'get_color', 'index', 'instances', 'inthandle', 'named_datamaps', 'offsets', 'pointer', 'properties', 'set_color', 'virtuals']
AttributeError: Attribute 'score_total' not found

Posted: Mon Dec 15, 2014 8:54 pm
by L'In20Cible
Use entity.set_prop_int('m_scoreTotal', score) for now. Those properties will be available from the entities_changes branch.

Posted: Mon Dec 15, 2014 8:56 pm
by satoon101
Which version are you using? __dir__ has been added to the entities_changes branch to also print out the dynamically supported attributes, but using dir() in the current release does not show those. It also seems that the data is not properly defined for those dynamic properties, so it makes sense it encounters an attribute error. Try using those properties by name instead, along with entity.set_prop_int and see if that works.

Posted: Tue Dec 16, 2014 4:26 am
by satoon101
I just remembered that we passed in entity types to BaseEntity in the old version. So, the code should look more like:

Syntax: Select all

def set_team_score(team, score):
for index in EntityIter('cs_team_manager'):
entity = BaseEntity(index, 'team')
if entity.team != team:
continue
entity.score_total = score


However, I think we are really close to finishing the entities_changes updates, so you will have to update the code at that time.