add_ammo,add_clip attributes don't work

Please post any questions about developing your plugin here. Please use the search function before posting!
DJiSer
Junior Member
Posts: 20
Joined: Sat May 10, 2014 2:44 pm

add_ammo,add_clip attributes don't work

Postby DJiSer » Tue Jan 20, 2015 9:59 pm

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\events\listener.py", line 90, in fire_game_event
    callback(game_event)
  File "..\addons\source-python\plugins\test4\test4.py", line 100, in player_say
    player.add_primary_ammo(10)
  File "..\addons\source-python\packages\source-python\players\weapons\__init__.py", line 209, in add_primary_ammo
    self._add_weapon_ammo(value, is_filters='primary')
  File "..\addons\source-python\packages\source-python\players\weapons\__init__.py", line 238, in _add_weapon_ammo
    weapon_manager.ammoprop + '%03d' % weapon.ammoprop)
  File "..\addons\source-python\packages\source-python\entities\entity.py", line 83, in __getattr__
    raise AttributeError('Attribute "{0}" not found'.format(attr))

AttributeError: Attribute "ammoprop" not found


Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\events\listener.py", line 90, in fire_game_event
    callback(game_event)
  File "..\addons\source-python\plugins\test4\test4.py", line 104, in player_say
    player.add_primary_clip(10)
  File "..\addons\source-python\packages\source-python\players\weapons\__init__.py", line 258, in add_primary_clip
    self._add_weapon_clip(value, is_filters='primary')
  File "..\addons\source-python\packages\source-python\players\weapons\__init__.py", line 286, in _add_weapon_clip
    weapon.clip += value
  File "..\addons\source-python\packages\source-python\entities\entity.py", line 83, in __getattr__
    raise AttributeError('Attribute "{0}" not found'.format(attr))
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Wed Jan 21, 2015 1:22 am

I think that it would help everyone if you provided the code that generated that log. :)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jan 21, 2015 2:07 am

If this is for CS:GO, I know why it is occurring. If not, please add more info like Doldol mentioned. I will update CS:GO's data here in a few to include a few more properties (one being for the ammoprop).
Image
DJiSer
Junior Member
Posts: 20
Joined: Sat May 10, 2014 2:44 pm

Postby DJiSer » Wed Jan 21, 2015 6:00 am

Syntax: Select all

@Event
def player_say(game_event):
userid = game_event.get_int('userid')
if game_event.get_string('text') == 'test':
index = index_from_userid(userid)
player = PlayerEntity(index)
prim = player.get_primary()
if prim:
player.add_primary_ammo(10)
if game_event.get_string('text') == 'test2':
index = index_from_userid(userid)
player = PlayerEntity(index)
prim = player.get_primary()
if prim:
player.add_primary_clip(10)

I try _set_weapon_ammo;_set_weapon_clip - same result.

CS:GO Windows, Jan17 Build.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jan 21, 2015 6:04 am

Yes, I think this update from a few hours ago should fix your issue:
https://github.com/Source-Python-Dev-Team/Source.Python/commit/8fff5e38abc885acbe98efd96eeb364804eb3274

The data previously did not include those properties for CS:GO (at least since we moved to the new format).
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 139 guests