EntityPreHook is actually the same like a PreHook. The passed argument is a StackData object (I usually call it "args"), which provides you high- and low-level access to the stack of the hooked function.
After looking at the data files you know that the StackData object will provide you access to 4 arguments. You could also just use "print(args)". However, the first argument is the pointer of the player, the second argument is the pointer of the weapon. So, you could do something like this:
Syntax: Select all
import memory
from entities.hooks import EntityPreHook
from players.entity import PlayerEntity
from weapons.entity import WeaponEntity
@EntityPreHook('player', 'drop_weapon')
def pre_drop_weapon(args):
player = memory.make_object(PlayerEntity, args[0])
weapon = memory.make_object(WeaponEntity, args[1])
print('{0} wants to drop his weapon.'.format(player.name))
While checking the number of arguments in the data files, I also noticed that we defined INT as the return type. That is actually wrong and should be VOID. If you are using the latest release you also need to update your hooking line. We no longer use the entity class names like "player" or "cs_bot", but "CCSPlayer" and "CCSBot". However, in order to block dropping a weapon, you could also block the client command "dop".