Page 1 of 1

May 1 release setting Player attributes

Posted: Sun May 01, 2016 7:40 pm
by BackRaw
Hi,

I get this exception:

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File '../addons/source-python/packages/source-python/events/listener.py', line 92, in fire_game_event
    callback(game_event)
  File '../addons/source-python/plugins/flashfun/flashfun.py', line 79, in on_player_spawn
    get_player(game_event).prepare()
  File '../addons/source-python/plugins/flashfun/players.py', line 59, in prepare
    self.armor = 0
  File '../addons/source-python/packages/source-python/entities/entity.py', line 119, in __setattr__
    setattr(server_class(self.pointer, wrap=True), attr, value)
  File '../addons/source-python/packages/source-python/entities/classes.py', line 568, in fset
    getattr(ptr, 'set_' + type_name)(value, offset)
 
Boost.Python.ArgumentError: Python argument types in
    Pointer.set_char(CCSPlayer, int, int)
did not match C++ signature:
    set_char(CPointer {lvalue}, char, int offset=0)


Whenever I do this:

Syntax: Select all

@Event('player_spawn')
def on_player_spawn(game_event):
"""Called when a player spawns on the server."""
# Prepare the spawning player for battle
get_player(game_event).prepare()
Which calls prepare() from:

Syntax: Select all

class Player(SPPlayer):

"""Class used to extend SP's players.entity.Player class with useful
functionality for this script."""

def equip(self, weapon='weapon_flashbang'):
"""Safely equip the player with a flashbang grenade."""
# Is the player alive and on a team?
if not self.dead and self.team > 1:

# If yes, equip them with a flashbang grenade
self.give_named_item(weapon, *_give_named_item_args)

def prepare(self):
"""Safely prepare the player for battle."""
# Stop preparing when the player is either dead or not on any opposing team
if self.dead or self.team < 2:
return

# Set standard values for the player's health and armor attributes
self.health = player_health.get_int()
self.armor = 0

spawn_protection.start(self.userid)

# Get a random vector to spawn on
vector = spawn_points.get_random()

# Set it as the player's location if we found one
if vector is not None:
self.origin = vector

# Safely equip the player after a second
Delay(1, self.equip)

def remove_weapon(self, classname, re_equip=False):
# Look for the weapon's index in the player's weapon index list
index = self.get_weapon_index(classname)

# Remove the weapon if possible
if index is not None:
Delay(0, Weapon(index).remove)

if re_equip:
Delay(.1, self.equip)
The line containing self.armor = 0 is the one causing the issue. Didn't have that with the April 17 (I believe) release.

Prior to updating I removed each folder in cstrike/addons, just leaving plugins. source-python.dll/so/vdf have also been removed. Could it be a data error?

Re: May 1 release setting Player attributes

Posted: Sun May 01, 2016 7:47 pm
by satoon101
It's because we now get the proper type of value for SendPropType.INT SendProps. For now, just put the value in a string, but we will work on fixing this so that isn't required in the future.

Re: May 1 release setting Player attributes

Posted: Sun May 01, 2016 8:02 pm
by BackRaw
self.armor = "0" doesn't work either, it doesn't set anything. On a fun map I still get 100 armor.

Re: May 1 release setting Player attributes

Posted: Sun May 01, 2016 8:12 pm
by satoon101
Wait until build 322 is available. This commit should fix that issue:
https://github.com/Source-Python-Dev-Te ... a84b94450f

Re: May 1 release setting Player attributes

Posted: Sun May 01, 2016 8:17 pm
by BackRaw
satoon101 wrote:Wait until build 322 is available. This commit should fix that issue:
https://github.com/Source-Python-Dev-Te ... a84b94450f

Alright thanks. I'll be patient :D