Check for custom button to be pressed ?

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Pudge90
Junior Member
Posts: 20
Joined: Sun Jan 14, 2018 6:18 pm
Location: Germany

Check for custom button to be pressed ?

Postby Pudge90 » 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:

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.
User avatar
L'In20Cible
Project Leader
Posts: 1059
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Check for custom button to be pressed ?

Postby L'In20Cible » Fri Jan 19, 2018 10:22 am

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.
User avatar
Pudge90
Junior Member
Posts: 20
Joined: Sun Jan 14, 2018 6:18 pm
Location: Germany

Re: Check for custom button to be pressed ?

Postby Pudge90 » Fri Jan 19, 2018 12:29 pm

Okay, that makes sense in a way. Then I'll go with the workaround. Thank you for the quick reply

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 2 guests