Skip to content

CSS player.take_damage #513

@srpg

Description

@srpg

I noticed player.take_damage causes errors in windows and it makes linux server crash, i am running the latest version of SP.

here is the error on windows:

[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\test\test.py", line 10, in player_hurt
    victim.take_damage(damage=123, attacker_index=index_from_userid(attacker))
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "..\addons\source-python\packages\source-python\entities\_base.py", line 816, in take_damage
    self.on_take_damage(take_damage_info)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "..\addons\source-python\packages\source-python\memory\helpers.py", line 337, in __call__
    return super().__call__(self._this, *args)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^

RuntimeError: Access violation while reading address '0'.

Here is test code:

from events import Event
from players.entity import Player
from players.helpers import index_from_userid

@Event('player_hurt')
def player_hurt(args):
    victim = Player.from_userid(args['userid'])
    attacker = args.get_int('attacker')
    if attacker > 0:
        victim.take_damage(damage=123, attacker_index=index_from_userid(attacker))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions