PreHook: player_hurt
Posted: Sat Mar 07, 2015 3:40 pm
I needed to get event pre player_hurt.
From the examples on the site I was able to make it up:
When you deal damage I get to the console: 2 0 0
If I replace args [0] to args [1] I get an error:
What am I doing wrong?
SP (build on March 2). Platform: Windows
From the examples on the site I was able to make it up:
Syntax: Select all
# =============================================================================
# >> IMPORTS
# =============================================================================
import memory
from memory import find_binary
from memory import make_object
from memory import Convention
from memory import DataType
from memory.hooks import PreHook
from basetypes import TakeDamageInfo
from core import PLATFORM
# =============================================================================
# >> CONSTANTS
# =============================================================================
if PLATFORM == 'windows':
ON_TAKE_DAMAGE_IDENTIFIER = b'\x55\x8B\xEC\x81\xEC\x44\x01\x2A\x2A\x56' \
b'\x89\x4D\xFC'
else:
ON_TAKE_DAMAGE_IDENTIFIER = '_ZN20CBaseCombatCharacter12OnTakeDamageERK15CTakeDamageInfo'
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
server = find_binary('cstrike/bin/server')
OnTakeDamage = server[ON_TAKE_DAMAGE_IDENTIFIER].make_function(Convention.THISCALL, (DataType.POINTER, DataType.POINTER), DataType.VOID)
# =============================================================================
# >> CALLBACK
# =============================================================================
@PreHook(OnTakeDamage)
def pre_on_take_damage(args):
info = make_object(TakeDamageInfo, args[0])
print(info.inflictor)
print(info.attacker)
print(info.weapon)
When you deal damage I get to the console: 2 0 0
If I replace args [0] to args [1] I get an error:
What am I doing wrong?
SP (build on March 2). Platform: Windows