Page 1 of 1

Hooking OnPlayerRunCmd

Posted: Thu Dec 24, 2015 10:09 am
by roflmuffin
Hi there,

I know you can use the OnTick listener and use playerinfo.get_last_user_command() to get the same sort of information as OnPlayerRunCmd, but these values are of course read only.

I think it may involve some signature scanning, but I am totally new to Source.Python's memory module and trying to implement a solution. Would anyone be able to guide me towards a possible solution for this?

Thanks,
Roflmuffin

Posted: Thu Dec 24, 2015 11:03 am
by Ayuto
We have PlayerRunCommand already included, so it's extremely easy to hook it.

Syntax: Select all

from entities.hooks import EntityPreHook
from entities.hooks import EntityCondition

@EntityPreHook(EntityCondition.is_player, 'run_command')
def on_pre_player_run_command(args):
print(args)

Posted: Thu Dec 24, 2015 11:17 am
by roflmuffin
Well don't I feel silly... Do you know when this was added? A quick glance at GitHub says August.

Posted: Thu Dec 24, 2015 2:50 pm
by satoon101
Looks like the offsets were originally added to our data on August 14:
https://github.com/Source-Python-Dev-Team/Source.Python/commit/77859ac6f696dce71e22f18157b0b5ac2ca88cc8

Posted: Thu Dec 24, 2015 6:21 pm
by L'In20Cible
You could also try to get/set Player.buttons (points at m_nButtons) attribute.