Check for custom button to be pressed ?
Posted: Fri Jan 19, 2018 9:51 am
Is there any clever way to check for a custom button to be pressed ? I want to excecute a function/run code when a player presses a certain key. For example if a player presses the "p"-Key then do blablabla.
I thought about the @OnButtonStateChanged but as far as I am able to understand that only supports the specific buttons listed at http://wiki.sourcepython.com/developing ... yerButtons
Right now I have a workaround with binding a command in the console to the custom key that sends a playermessage:
which then triggers the @Event('player_say') and lets me excecute code in source.python.
But it's kinda uggly since every player has to bind the key by himself so a direct source.python-solution would be awesome.
I thought about the @OnButtonStateChanged but as far as I am able to understand that only supports the specific buttons listed at http://wiki.sourcepython.com/developing ... yerButtons
Right now I have a workaround with binding a command in the console to the custom key that sends a playermessage:
Code: Select all
bind p "say_team !examplefunction"
which then triggers the @Event('player_say') and lets me excecute code in source.python.
But it's kinda uggly since every player has to bind the key by himself so a direct source.python-solution would be awesome.