[CSGO] can't grep weapon ammo

Please post any questions about developing your plugin here. Please use the search function before posting!
kalle
Junior Member
Posts: 26
Joined: Sun Jun 26, 2016 9:48 am
Contact:

[CSGO] can't grep weapon ammo

Postby kalle » Fri Aug 05, 2016 12:05 am

Dear community,

I can't grep the weapons ammo. I can get the weapon clip, but I need to get all available ammo. The following errror occurs:

Syntax: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/plugins/conquest/conquest.py', line 58, in tick_listener
class_weapons.ontick()
File '../addons/source-python/plugins/conquest/weapons.py', line 235, in ontick
print(weapon.get_ammo())
File '../addons/source-python/packages/source-python/weapons/entity.py', line 68, in get_ammo
weapon_manager.ammoprop + '%03d' % self.ammoprop)
File '../addons/source-python/packages/source-python/entities/entity.py', line 293, in get_property_int
return self._get_property(name, 'int')
File '../addons/source-python/packages/source-python/entities/entity.py', line 347, in _get_property
name, server_class.properties[name].prop_type, prop_type))

TypeError: Property 'm_iAmmo.007' is of type ushort not int


Source:

Syntax: Select all

print(player.get_primary_ammo())


After that I figured out that you have some kind of Weapons class at all :) so I tried to use that directly. Same error:

Syntax: Select all

if player.get_primary():
weapon = Weapon(player.get_primary())
if weapon:
print(weapon.get_ammo())


Changing the __init__.py in the "weapons" folder of sourcepython is not solving the problem at all. At least I get another error. Is CSGO the problem or did I found some bug in sourcepython? I'm using one of the latest precompiled binaries directly from your "Builds" section (Current Source.Python version: 410).
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CSGO] can't grep weapon ammo

Postby L'In20Cible » Fri Aug 05, 2016 12:07 am

kalle
Junior Member
Posts: 26
Joined: Sun Jun 26, 2016 9:48 am
Contact:

Re: [CSGO] can't grep weapon ammo

Postby kalle » Fri Aug 05, 2016 10:52 am

Thanks, feeling dump now. Had recently a look for that on github :/

can now get/set the weapon ammo.

Syntax: Select all

weapon = Weapon(player.get_primary())
if weapon:
current = int(weapon.get_property_short('m_iPrimaryReserveAmmoCount'))

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 151 guests