Import error player.wapons

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
mister-man
Member
Posts: 70
Joined: Wed Aug 29, 2012 7:09 pm
Location: Germany

Import error player.wapons

Postby mister-man » Wed Sep 18, 2013 12:40 pm

Hay,

I tried to import player.weapon and it seems there is an error.

Code: Select all

from players.weapons import get_ammo


Code: Select all

[SP]  Caught an Exception:
Traceback (most recent call last):
  File '..\addons\source-python\packages\source-python\addons\manager.py', line
48, in __missing__
    instance = _LoadedAddon(addon_name)
  File '..\addons\source-python\packages\source-python\addons\manager.py', line
237, in __init__
    self._addon = __import__(addon_name + '.' + addon_name)
  File '..\addons\source-python\plugins\realisticAmmo\realisticAmmo.py', line 18
, in <module>
    from players.weapons import get_ammo
  File '..\addons\source-python\packages\source-python\players\weapons.py', line
 10, in <module>
    from entities.entity import BaseEntity
  File '..\addons\source-python\packages\source-python\entities\entity.py', line
 12, in <module>
    from entities.keyvalues import KeyValues
  File '..\addons\source-python\packages\source-python\entities\keyvalues.py', l
ine 12, in <module>
    from paths import DATA_PATH

ImportError: cannot import name DATA_PATH
----------

Community of Gamers --> http://c-o-g.de
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Wed Sep 18, 2013 2:44 pm

Update your installation. I fixed that 4 days ago. :)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Sep 18, 2013 2:55 pm

As Ayuto states, the name change was fixed already. Though, I am not sure why you are trying to import a method which is already included in PlayerEntity. You cannot import a method, anyway, only global objects in a module. If you wish to use get_ammo, just use it as it is designed:

Code: Select all

from players.entity import PlayerEntity

player = PlayerEntity(<index>)
ammo = player.get_ammo('m4a1')

# You can also use the full entity name
ammo = player.get_ammo('weapon_m4a1')
Satoon
User avatar
mister-man
Member
Posts: 70
Joined: Wed Aug 29, 2012 7:09 pm
Location: Germany

Postby mister-man » Wed Sep 18, 2013 3:50 pm

Okay thanks... my mistake ;)

My first try to do something with weapons!
----------



Community of Gamers --> http://c-o-g.de
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Sep 18, 2013 4:03 pm

Sorry, forgot to mention, but the data for the property values needs to be updated. I keep forgetting to do that, so I will do that right now.

Satoon

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 27 guests