Disable func_button Created 1 month ago2021-01-08 16:56:20 UTC by KrA40n1 KrA40n1

Created 1 month ago2021-01-08 16:56:20 UTC by KrA40n1 KrA40n1

Posted 1 month ago2021-01-08 16:56:20 UTC Post #345180

I want to disable func_button when I press an other button. I want it to stay disabled while the other button is active. There are two cases of this
  • when the button is "toggle" - until it is pressed again.
  • when the button is not "toggle" - until it resets.
I have done that in a very complicated way and I am looking if there is a simpler way I can lock the buttons that I want?

Thank you.
Posted 1 month ago2021-01-09 13:08:37 UTC Post #345185
To enable or disable an entity, you'll need to use a multisource to act as its master. Enabling an entity is easier to do than disabling it, but both are quite doable (once you know how to work around a few quirks and bugs!).

So we've got func_button A, which must be enabled or disabled by func_button B. We'll add a multisource MS, and set A's 'master' property to MS. Let's now look at 4 possible scenario's:

B is a toggle button...
  • ...that must enable A: add a trigger_relay TR and make it toggle multisource MS, then make func_button B target trigger_relay TR. (if you let B target MS directly, you'll hit a bug where MS won't be triggered one out of every 4 button presses)
  • ...that must disable A: same as above, but also add a trigger_auto that triggers trigger_relay TR as soon as the level starts. This inverts the relationship between B and MS. (give the trigger_auto a small delay, otherwise it might fire before TR has been spawned)
B is an auto-reset button...
  • ...that must enable A: the most common and easy setup: just make func_button B target multisource MS. (buttons don't trigger their target when they auto-reset, unless their target is a multisource - so this scenario was designed to be easy to do)
  • ...that must disable A: add a trigger_relay TR that toggles multisource MS, and add a trigger_auto that triggers trigger_relay TR when the level starts. But instead of making func_button B target trigger_relay TR directly (which you would do if B were a toggle button), make it target a multi_manager MM. Then make multi_manager MM target trigger_relay TR twice: first with a delay of 0, then with a delay that corresponds to func_button B's auto-reset time (or slightly lower, just to be safe). (the problem here is that auto-resetting buttons do not trigger their target when the reset, so we'll have to use a multi_manager to simulate that behavior)
If you want to use multiple buttons to enable/disable func_button A, then repeat the above steps for each of those buttons. And if you want to enable/disable multiple things at the same time, then just make all of those things use multisource MS as their master.
Posted 1 month ago2021-01-10 17:45:13 UTC Post #345195
Thank you. Everything worked great.
Posted 1 month ago2021-01-10 21:09:36 UTC Post #345198
One detail I forgot to mention: if you don't enable the 'Remove On fire' flag on a trigger_auto, then it will fire again when you reload a savegame that was made in that map. That will invert the button-multisource relationship again, which is not what you want. So be sure to enable that flag on each trigger_auto.
Posted 1 month ago2021-01-10 23:45:04 UTC Post #345200
This is for Counter-Strike not for single player so it triggers only when the level is loaded. Thanks a lot again.
You must be logged in to post a response.