[CSS]Exception when reading ammo key value
Posted: Sun Feb 18, 2018 9:01 am
I can set the ammo key value without any issues, and this works (gives the amount of reserve ammo the value is set to when I pick up the USP), but an exception gets raised when trying to read it.
Also, "ammo" is not in weapon_usp.keyvalues. & Reading the kv after spawn doesn't work either.
Code:
Exception:
SP info
What is going on? & How else can I read the value of reserve ammo that comes with a weapon spawned in the world?
Also, "ammo" is not in weapon_usp.keyvalues. & Reading the kv after spawn doesn't work either.
Code:
Syntax: Select all
from weapons.entity import Weapon
weapon_usp = Weapon.create("weapon_usp")
weapon_usp.set_key_value_int("ammo", 125) # Works
weapon_usp.get_key_value_int("ammo") # Exception raised
weapon_usp.spawn()
Exception:
Code: Select all
[SP] Loading plugin 'kvtest'...
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
plugin._load()
File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "../addons/source-python/plugins/kvtest/kvtest.py", line 6, in <module>
weapon_usp.get_key_value_int("ammo") # Exception raised
NameError: "ammo" is not a valid KeyValue for entity class "CWeaponCSBase".
[SP] Plugin 'kvtest' was unable to be loaded.
SP info
Code: Select all
Date : 2018-02-18 09:00:42.103015
OS : Linux-4.4.0-101-generic-x86_64-with-debian-stretch-sid
Game : css
SP version : 621
What is going on? & How else can I read the value of reserve ammo that comes with a weapon spawned in the world?