Code that works in tf2 fails in tf2c mod.
Posted: Fri Oct 02, 2020 10:39 am
I know sourcemod has a unofficial gamedata release to make it work with tf2classic but I prefer source.python
I'm trying to hook things such as entity creation and player run_command but they don't work at all. Nothing is output in console no matter what.
Example of code that works in tf2 but not tf2c (mod)
Strangely though on_tick and on_player_say work fine. Right now I can work with that but its very limiting.
Does someone more experienced know what is happening and why it doesn't work?
I'm trying to hook things such as entity creation and player run_command but they don't work at all. Nothing is output in console no matter what.
Example of code that works in tf2 but not tf2c (mod)
Code: Select all
from listeners import OnPlayerRunCommand
def IsPlayerBot(Obj):
if Obj.is_bot == True:
return True
elif Obj.playerinfo.is_fake_client():
return True
else:
return False
# This will never run #
@OnPlayerRunCommand
def on_player_run_command(player, user_cmd):
print("hook")
if (IsPlayerBot(player)):
user_cmd.forward_move = 0
user_cmd.side_move = 0
pass
Strangely though on_tick and on_player_say work fine. Right now I can work with that but its very limiting.
Does someone more experienced know what is happening and why it doesn't work?