Source-Python-Dev-Team / Source.Python

This plugin aims to use boost::python and create an easily accessible wrapper around the Source Engine API for scripter use.
http://forums.sourcepython.com
GNU General Public License v3.0
163 stars 31 forks source link

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

Closed Xiazee closed 4 years ago

Xiazee commented 4 years ago

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
--------------------------------------------------------
CookStar commented 4 years ago

Related Topics. BaseHandle to Index conversion failure - Source.Python forums