I try my first steps in SP and have an error with the messagesytem.
Syntax: Select all
# =============================================================================
# >> IMPORTS
# =============================================================================
from players.helpers import index_from_playerinfo
from players.helpers import playerinfo_from_userid
# =============================================================================
# >> Global
# =============================================================================
chatColors = { '#white' : '\x01' ,
'#darkred' : '\x02' ,
'#green' : '\x04' ,
'#palegreen' : '\x05' ,
'#lightgreen' : '\x06' ,
'#red' : '\x07' }
# =============================================================================
# >> CLASSES
# =============================================================================
class saylib(object):
def __init__(self):
pass
def __setColor(self, msg):
text = msg
for i, j in colors.iteritems():
text = text.replace(i, str(j))
return str(text)
def tell(self, userid, msg):
playerinfo = playerinfo_from_userid(userid)
i = index_from_playerinfo(playerinfo)
m = messages.SayText(index=i, chat=1, message=__setColor(msg))
m.send(i)
Error:
Code: Select all
sp load AoD
[SP] Loading addon 'AoD'...
[SP] Caught an Exception:
Traceback (most recent call last):
File '..\addons\source-python\_libs\addons\manager.py', line 43, in __missing_
_
instance = _LoadedAddon(addon_name)
File '..\addons\source-python\_libs\addons\manager.py', line 232, in __init__
self._addon = __import__(addon_name + '.' + addon_name)
File '..\addons\source-python\AoD\AoD.py', line 13, in <module>
from AoD._libs.saylib import saylib
ImportError: cannot import name saylib
[SP] Addon 'AoD' was unable to be loaded.
Can someone explain me, whats wrong? The code from function "tell" comes from the wike!
Thanks