May 1 release setting Player attributes

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

May 1 release setting Player attributes

Postby BackRaw » Sun May 01, 2016 7:40 pm

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?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: May 1 release setting Player attributes

Postby satoon101 » Sun May 01, 2016 7:47 pm

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.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: May 1 release setting Player attributes

Postby BackRaw » Sun May 01, 2016 8:02 pm

self.armor = "0" doesn't work either, it doesn't set anything. On a fun map I still get 100 armor.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: May 1 release setting Player attributes

Postby satoon101 » Sun May 01, 2016 8:12 pm

Wait until build 322 is available. This commit should fix that issue:
https://github.com/Source-Python-Dev-Te ... a84b94450f
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: May 1 release setting Player attributes

Postby BackRaw » Sun May 01, 2016 8:17 pm

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

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 64 guests