OnPlayerRunCommand not fired in TF2

Please post any questions about developing your plugin here. Please use the search function before posting!
ghetto_life
Junior Member
Posts: 15
Joined: Fri Aug 26, 2022 11:06 pm

OnPlayerRunCommand not fired in TF2

Postby ghetto_life » Fri Sep 09, 2022 5:25 pm

Hello!
I try use OnPlayerRunCommand for TF2, but it not fired.

Syntax: Select all

from listeners import OnPlayerRunCommand


def load():
print("Script run")


@OnPlayerRunCommand
def on_player_run_command(player, user_cmd):
print("Hook")


In the game I shot and jumped. No "Hook" message appeared in the console.
Installed SP version for TF2. OS: Windows
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: OnPlayerRunCommand not fired in TF2

Postby cssbestrpg » Sat Sep 10, 2022 10:29 am

Hi, it sounds to me the game data is outdated
ghetto_life
Junior Member
Posts: 15
Joined: Fri Aug 26, 2022 11:06 pm

Re: OnPlayerRunCommand not fired in TF2

Postby ghetto_life » Sat Sep 10, 2022 11:56 am

I tried completely reinstalling the SP and running just the script above. The result is the same.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: OnPlayerRunCommand not fired in TF2

Postby Ayuto » Sat Sep 10, 2022 2:49 pm

Game data is automatically updated by SP itself if you haven't disabled it (it's taking the latest data from data.sourcepython.com). However, it could be that our data ist not up to date. I will check that later today.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: OnPlayerRunCommand not fired in TF2

Postby Ayuto » Sat Sep 10, 2022 4:17 pm

Data seems to be up-to-date. Could you please set sp_logging_level to 4 in your core_settings.ini, restart your server, load your plugin and join your server. In your console log you should see the following entry if you join the server:

Code: Select all

[Source.Python] Initializing core hook (run_command)...
[Source.Python] Core hook (run_command) has been initialized.
ghetto_life
Junior Member
Posts: 15
Joined: Fri Aug 26, 2022 11:06 pm

Re: OnPlayerRunCommand not fired in TF2

Postby ghetto_life » Sat Sep 10, 2022 4:29 pm

Ayuto wrote:Data seems to be up-to-date. Could you please set sp_logging_level to 4 in your core_settings.ini, restart your server, load your plugin and join your server. In your console log you should see the following entry if you join the server:

Code: Select all

[Source.Python] Initializing core hook (run_command)...
[Source.Python] Core hook (run_command) has been initialized.


Yes, there is this message. But "Hook" is still not printed.

Log:

Code: Select all

[Source.Python] Loading...
[Source.Python] Setting up exception hooks...
[Source.Python] Setting up data update...
[Source.Python] Checking for data updates...
[Source.Python] No new data is available.
[Source.Python] Setting up translations...
[Source.Python] Setting up data...
[Source.Python] Searching for a cached signature...
[Source.Python] Could not find a cached signature.
[Source.Python] Searching in the binary...
[Source.Python] Found a signature in the binary!
[Source.Python] Setting up global pointers...
[Source.Python] Retrieving global pointer for GlobalEntityList...
[Source.Python] Searching for a cached signature...
[Source.Python] Could not find a cached signature.
[Source.Python] Searching in the binary...
[Source.Python] Found a signature in the binary!
[Source.Python] Setting up global "server" variables...
[Source.Python] Setting up global "factory_dictionary" variables...
[Source.Python] Setting up the "sp" command...
[Source.Python] OnLevelEnd.__init__<<function _level_end at 0x22429C90>>
[Source.Python] OnLevelEnd.__init__ - Registering
[Source.Python] Setting up auth...
[Source.Python] Setting up user settings...
[Source.Python] OnClientDisconnect.__init__<<function on_player_disconnect at 0x2246D198>>
[Source.Python] OnClientDisconnect.__init__ - Registering
[Source.Python] Repeat.__init__: <<function _radio_refresh at 0x2246DBB8>> <()> <{}>
[Source.Python] Repeat.__init__: <<function _esc_refresh at 0x2246DC00>> <()> <{}>
[Source.Python] OnClientDisconnect.__init__<<function on_player_disconnect at 0x2246DCD8>>
[Source.Python] OnClientDisconnect.__init__ - Registering
[Source.Python] Setting up entities listener...
[Source.Python] Setting up versioning...
[Source.Python] Loaded successfully.
maxplayers set to 24
No '-replayserverdir' parameter found - using default replay folder.
Replay: Creating thread pool...succeeded.
Replay: Starting thread pool with 4 threads...succeeded.
Cleaning files from temp dir, "E:\servers\tf2\tf\replay\server\tmp\" ...no files removed.
ProtoDefs post data loaded.
ProtoDefs post data loaded.
Unknown command "r_decal_cullsize"
[SP] Loading plugin 'test'...
[Source.Python] OnNetworkedEntityCreated.__init__<<function on_networked_entity_created at 0x224773D8>>
[Source.Python] OnNetworkedEntityCreated.__init__ - Registering
[Source.Python] OnPlayerRunCommand.__init__<<function on_player_run_command at 0x22477810>>
[Source.Python] OnPlayerRunCommand.__init__ - Registering
Script run
[SP] Successfully loaded plugin 'test'.
--------------------------------------------------------
sv_pure set to 1.
--------------------------------------------------------
maxplayers set to 24
WARNING: Port 27015 was unavailable - bound to port 27016 instead
WARNING: Port 27005 was unavailable - bound to port 27006 instead
WARNING: Port 27020 was unavailable - bound to port 27021 instead
Network: IP 192.168.133.1, mode MP, dedicated Yes, ports 27016 SV / 27006 CL
Initializing Steam libraries for secure Internet server
No account token specified; logging into anonymous game server account.  (Use sv_setsteamaccount to login to a persistent account.)
pure_server_whitelist.txt not present; pure server using only base file rules
trusted_keys.txt not present; pure server using only base trusted key list
Executing dedicated server config file server.cfg
Using map cycle file 'cfg/mapcycle_default.txt'.  ('cfg\mapcycle.txt' was not found.)
material models/weapons/c_items/c_ubersaw_xms has a normal map and $basealphaenvmapmask.  Must use $normalmapalphaenvmapmask to get specular.

material models/weapons/c_items/c_frontierjustice_xmas has a normal map and $basealphaenvmapmask.  Must use $normalmapalphaenvmapmask to get specular.

material models/player/items/all_class/all_class_ring_setting has a normal map and $basealphaenvmapmask.  Must use $normalmapalphaenvmapmask to get specular.

material models/player/items/crafting/coin_invasion has a normal map and $basealphaenvmapmask.  Must use $normalmapalphaenvmapmask to get specular.

Set motd from file 'cfg/motd_default.txt'.  ('cfg/motd.txt' was not found.)
Set motd_text from file 'cfg/motd_text_default.txt'.  ('cfg/motd_text.txt' was not found.)
SV_ActivateServer: setting tickrate to 66.7
Connection to game coordinator established.
Current item schema is up-to-date with version 6A365496.
'server.cfg' not present; not executing.
'ctf_2fort.cfg' not present; not executing.
Server is hibernating
Connection to Steam servers successful.
Assigned anonymous gameserver Steam ID [A:1:3011340295:21284].
VAC secure mode is activated.
Client "Player" connected.
Server waking up from hibernation
[Source.Python] Initializing core hook (run_command)...
[Source.Python] Core hook (run_command) has been initialized.
[Source.Python] Initializing core hook (run_command)...
[Source.Python] Core hook (run_command) has been initialized.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: OnPlayerRunCommand not fired in TF2

Postby Ayuto » Sat Sep 10, 2022 5:08 pm

Okay, I figured there was an issue with data.sourcepython.com which didn't update properly and provided old data. If you restart your server, it should work fine now.
ghetto_life
Junior Member
Posts: 15
Joined: Fri Aug 26, 2022 11:06 pm

Re: OnPlayerRunCommand not fired in TF2

Postby ghetto_life » Sat Sep 10, 2022 6:41 pm

Now it works. Thank you! :smile:

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 20 guests