Detecting a button press (not a key press)
I know there are other threads out there, but I'm getting a bit overwhelmed with them. I'm not sure which to use.
Basically, what's the proper way to detect a button press? Like an ingame button (specifically a kz button). Currently I am using an EmitSound forward and when the button makes the normal button sound, it triggers my start function. Is this the best way? Somehow, hooking a sound forward doesn't seem like the best way. I'd think it should be in a client_prethink perhaps. If you suggest another method other than using sound, I'd appreciate maybe a little snippet. Thanks guys. --MALON |
Re: Detecting a button press (not a key press)
pev(id,pev_button) ?:? IN_*
Edit: Oh god no...with this only 'use' key i think... |
Re: Detecting a button press (not a key press)
Use Ham Sandwich.
Code:
RegisterHam ( Ham:function, const EntityClass[], const Callback[], Post=0 ) |
Re: Detecting a button press (not a key press)
you might be able to register the entity's think (if you know the classname) with register_think(const Classname[], const function[]); (engine)
|
Re: Detecting a button press (not a key press)
I'm checking into the hamsandwich method now. I've never used it, so we'll see how i do.
And yes, I do know the entity's classname (it's always one of 5 classnames because it's a convention) so register_think is seeming really awesome. I don't know if button's think, but they must because they trigger something else in the map that's map related and not plugin related. Boy, I hope i know what the funk i'm talking about and not just speaking out of my arse. Thanks so far guys! --MALON |
Re: Detecting a button press (not a key press)
here's an example from another thread: (it's old, I don't think you need "#include hamsandwich" anymore)
http://forums.alliedmods.net/showthr...hlight=ham_use Code:
#include <amxmodx> |
Re: Detecting a button press (not a key press)
So this is what I tried:
PHP Code:
EDIT -------------------------- D'OH...I didn't try just plain old func_button. I'm stupid. I didn't read classname and I thought entity name. So once I call the function (in this case event_hostage_used), I have to check what entities are within a sphere of the player? Or can I send the entity that called the function TO the function and then extract the entity name from there? Thanks again! --MALON |
Re: Detecting a button press (not a key press)
RegisterHam( Ham_Use, "func_button", "hamUseButton_Pre", 0 );
and then inside check whether pev_target is equal to "counter_start", "clockstartbutton", "firsttimerelay", "multi_start" "counter_off", "clockstop", "clockstopbutton", "multi_stop" |
Re: Detecting a button press (not a key press)
Quote:
PHP Code:
|
Re: Detecting a button press (not a key press)
Code:
#if defined _kz_buttons_includedPHP Code:
Then, you can make a plugin like this : PHP Code:
PHP Code:
|
| All times are GMT -4. The time now is 03:14. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.