Syntax: Select all
weapon = WeaponEntity(create_entity(weapon_name))
weapon.teleport(location, None, None)
spawn_entity(weapon.index)
No matter what weapon I spawn with the code above, the weapon will sound like a deagle and have no recoil at all.
I found a thread on SourceMod forums describing the same issue. The very same thread had the fix as well.
In order to make the spawned weapon behave like the weapon it is supposed to be, you need to set the m_iItemDefinition property.
I tried doing that, and I got this error:
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File '..\addons\source-python\packages\source-python\commands\manager.py', line 151, in
__call__
return_value = callback(*args)
File '..\addons\source-python\packages\source-python\commands\auth.py', line 63, in __ca
ll__
return self.callback(*args)
File '..\addons\source-python\plugins\power_weapon\power_weapon.py', line 68, in create_
power_weapon
weapon.set_property_int('m_iItemDefinitionIndex', 3)
File '..\addons\source-python\packages\source-python\entities\entity.py', line 412, in s
et_property_int
self._set_property(name, 'int', value)
File '..\addons\source-python\packages\source-python\entities\entity.py', line 480, in _
set_property
name, self.classname))
ValueError: Property 'm_iItemDefinitionIndex' not found for entity type 'weapon_ak47'
Any ideas on how to fix this?