Page 1 of 1

set_color error

Posted: Tue May 06, 2014 4:34 pm
by Tuck
Exception

Code: Select all

[SP]  Caught an Exception:
Traceback (most recent call last):
  File '../addons/source-python/packages/source-python/events/listener.py', line 84, in fire_game_event
    callback(game_event)
  File '../addons/source-python/plugins/tuck/tuck.py', line 40, in player_spawn
    player.set_color((255, 0, 0, 255))
  File '../addons/source-python/packages/source-python/entities/entity.py', line 314, in set_color
    self.rendermode = self.rendermode | 1
  File '../addons/source-python/packages/source-python/entities/entity.py', line 237, in __setattr__
    self.datamaps[attr]._set_value(value)
  File '../addons/source-python/packages/source-python/entities/datamaps.py', line 365, in _set_value
    getattr(self.current_pointer, self.set_attr)(value, self.offset)

Boost.Python.ArgumentError: Python argument types in
    Pointer.set_char(Pointer, int, int)
did not match C++ signature:
    set_char(CPointer {lvalue}, char, int offset=0)


Code:
- I've tried with and without alpha same thing.

Syntax: Select all

from events import Event

from players.helpers import index_from_userid
from players.entity import PlayerEntity

@Event
def player_spawn(GameEvent):
userid = GameEvent.get_int('userid')
index = index_from_userid(userid)
player = PlayerEntity(index)
if not player.isdead and player.name == 'Tuck':
player.set_color((255, 0, 0))

Posted: Tue May 06, 2014 6:06 pm
by devilsnake88
Hi,
Look at the end of this script:
http://www.sourcepython.com/showthread.php?105-Spawnprotection&highlight=spawn

Didn't test but you can try.

Posted: Tue May 06, 2014 6:11 pm
by satoon101
The code in that thread is really old, so none of it will work. We will look into that issue, though, the BaseEntity class is going to get another major overhaul here very soon, so we would be wasting time trying to figure this out until then. Note that "usage" of the BaseEntity/PlayerEntity class will not be changing, just how it works internally will.