Hooking respawn
Posted: Tue May 20, 2014 9:29 am
Want to make sure I am hooking the right function.
I have two other questions also. Does this take place every time a player spawns, or only at round start? I see that there is one parameter for RoundRespawn, but I'm not sure what it is and a quick google didn't pull anything up for me. For CS:Source, Allied Modders says there are no arguments.
I have two other questions also. Does this take place every time a player spawns, or only at round start? I see that there is one parameter for RoundRespawn, but I'm not sure what it is and a quick google didn't pull anything up for me. For CS:Source, Allied Modders says there are no arguments.
Syntax: Select all
import memory
from memory import Convention, Argument, Return
from memory.hooks import PreHook
from basetypes import TakeDamageInfo
from core import PLATFORM
# Signature and symbol for CCSPlayer::RoundRespawn
if PLATFORM == 'windows':
ON_PLAYER_SPAWN_IDENTIFIER = b'\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x8B\x0D\x2A\x2A\x2A\x2A\x57'
else:
ON_PLAYER_SPAWN_IDENTIFIER = '_ZN9CCSPlayer12RoundRespawnEv'
# Get the server file
server = memory.find_binary('cstrike/bin/server')
# Search for the function pointer and convert it into a Function object
OnPlayerSpawn = server[ON_PLAYER_SPAWN_IDENTIFIER].make_function(
Convention.THISCALL,
(Argument.POINTER, Argument.POINTER),
Return.VOID
# =============================================================================
# Functions
# =============================================================================
@PreHook(OnPlayerSpawn)
def pre_player_spawn(args):
'''
Called at round start OR whenever a player spawns?
'''
# Convert the second pointer to a Player? object
player = memory.make_object(NotSureWhichObject, args[1])
# Modify health?
player.health += 20