You have to replace
<OnTakeDamage> with the actual function of OnTakeDamage. In RoOF's example, he didn't provide exactly how he got the function, so both L'In20Cible and I used place holders. Anytime you see
<Something> in code, you will need to replace that with what it is referencing. For the current example, you can do it a couple different ways now:
Syntax: Select all
from engines.server import engine_server
from entities import TakeDamageInfo
from entities.helpers import index_from_pointer
from filters.players import PlayerIter
from memory import make_object
from memory.hooks import PreHook
from players.bots import bot_manager
from players.entity import PlayerEntity
from weapons.entity import WeaponEntity
for _player in PlayerIter(return_types='player'):
on_take_damage = _player.on_take_damage
break
else:
_player = PlayerEntity(
index_from_edict(bot_manager.create_bot('test_bot')))
on_take_damage = _player.on_take_damage
engine_server.server_command('kickid {0};'.format(_player.userid))
@PreHook(on_take_damage)
def pre_on_take_damage(args):
...
Also, we haven't come to a full decision of where the new EntityPreHook and EntityPostHook classes will be housed, but for the moment they are in memory.hooks:
Syntax: Select all
from entities import TakeDamageInfo
from entities.helpers import index_from_pointer
from memory import make_object
from memory.hooks import EntityPreHook
from players.entity import PlayerEntity
from weapons.entity import WeaponEntity
@EntityPreHook(['cs_bot', 'player'], 'on_take_damage')
def pre_on_take_damage(args):
...