Code: Select all
from core import echo_console
from filters.players import PlayerIter
class MyClass:
@staticmethod
def pre_bump_weapon(args):
echo_console("Hooked. args: {}".format(args))
my_class = MyClass()
for player in PlayerIter():
break
else:
raise RuntimeError("Join the server")
def load():
player.bump_weapon.add_pre_hook(my_class.pre_bump_weapon)
def unload():
player.bump_weapon.remove_pre_hook(my_class.pre_bump_weapon)
Code: Select all
from core import echo_console
from filters.players import PlayerIter
class MyClass:
def pre_bump_weapon(self, args):
echo_console("Hooked. Self: {}, args: {}".format(self, args))
my_class = MyClass()
for player in PlayerIter():
break
else:
raise RuntimeError("Join the server")
def load():
player.bump_weapon.add_pre_hook(my_class.pre_bump_weapon)
def unload():
player.bump_weapon.remove_pre_hook(my_class.pre_bump_weapon)
In my working case it was a bit different - the function was hooked properly and hook was called successfully, but upon removing the hook from the function, the game crashes the very next time the previously hooked function is called.
Is this me being dumb or does this deserve a GitHub issue?