Page 1 of 1

Check for custom button to be pressed ?

Posted: Fri Jan 19, 2018 9:51 am
by Pudge90
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:

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.

Re: Check for custom button to be pressed ?

Posted: Fri Jan 19, 2018 10:22 am
by L'In20Cible
Unfortunately, this is not possible. Source.Python is a server-side plugin so it relies on the information that is networked and the clients doesn't send anything to the server unless there is a command bound to a key that needs to be send to the server. Binding a key to say_team works because the client send that command to the server so that the server can send the messages to all other players.

Re: Check for custom button to be pressed ?

Posted: Fri Jan 19, 2018 12:29 pm
by Pudge90
Okay, that makes sense in a way. Then I'll go with the workaround. Thank you for the quick reply