Skip to content

TakeDamageInfo.attacker raises ValueError: Conversion from "BaseHandle" (...) to "Index" failed. #350

@Xiazee

Description

@Xiazee

This issue seems to be similar to #127

The following code:

from entities import TakeDamageInfo
from entities.hooks import EntityCondition, EntityPreHook
from memory import make_object

@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def on_take_damage(args):
    info = make_object(TakeDamageInfo, args[1])
    info.attacker

Causes this exception when you shoot someone:

[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\plugins\testhook\testhook.py", line 9, in on_take_damage
    info.attacker

ValueError: Conversion from "BaseHandle" (<_entities.BaseEntityHandle object at 0x229BBBB0>) to "Index" failed.

The other properties documented here do not raise any exceptions:
http://wiki.sourcepython.com/developing/modules/entities.html#entities.TakeDamageInfo

sp info

IMPORTANT: Please copy the full output.
--------------------------------------------------------
Checksum      : 1c85222c92fd172ecb743999bddb2e97
Date          : 2020-09-22 11:09:42.049044
OS            : Windows-10-10.0.19041
Game          : csgo
SP version    : 700
Github commit : 53f3bb562a2975c828d4c5145e21979859f57731
Server plugins:
   00: Source.Python, (C) 2012-2020, Source.Python Team.
SP plugins:
   00: testhook
--------------------------------------------------------

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