CSGO: Change team score

Please post any questions about developing your plugin here. Please use the search function before posting!
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

CSGO: Change team score

Postby nullable » Mon Dec 15, 2014 7:38 pm

Is it possible to change team score in csgo game?
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Dec 15, 2014 8:22 pm

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
Image
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Mon Dec 15, 2014 8:48 pm

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

Postby L'In20Cible » Mon Dec 15, 2014 8:54 pm

Use entity.set_prop_int('m_scoreTotal', score) for now. Those properties will be available from the entities_changes branch.
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Dec 15, 2014 8:56 pm

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

Postby satoon101 » Tue Dec 16, 2014 4:26 am

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

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 138 guests