Keybinding
Is there any way to bind a player's key to trigger an entity in a map? Not necessarily trigger I suppose -- sending outputs at all would be one thing -- but that if the player presses, for example, F a particular logic_relay would be triggered.
Is this something that can be done with Hammer wizardry? Or would that take more elaborate coding?
To look at standard keys (fire, use, jump, crouch) you can use a game_ui or logic_playerproxy. To use other ones, you can place a point_servercommand in your level (which lets you use the console), then have a logic_auto (or a trigger, perhaps?) OnMapSpawn > servercommand > Command > bind f ent_fire f_button_pressed trigger. Then whenever f is pressed, the f_button_pressed relay triggers. If you used a trigger or something to bind the key, you can take away that power later by disabling the relay or firing > servercommand > Command > unbind f.
bind f "<COMMAND>", since the console maybe could see a space (for example between ent_fire and the targetname) as end of the whole command.
Entering bind f "ent_fire temp_relay trigger" straight into the console works fine. Pressing f then triggers temp_relay
However, when I add an output to an entity (this failed for both logic_auto and logic_relay) that goes OnTrigger > servercommand > Command > bind f "ent_fire temp_relay trigger" the console says "f" = "+mouse_menu"
I tried other letters, "q" = "+mouse_menu_taunt", "t" = "say", evidently these keys are already bound and trying to change them via in-map entities doesn't work
I tried to bind an unbound letter, it says "z" is not bound
I would try to use the keys available to use in a game_ui. Perhaps you could have a key-combo instead of just one key. (using logic_branch etc)
Using the default bindings via game_ui and logic_playerproxy (especially multiple keys) just feels like an unpleasant solution. "Yes player, I'm going to need you to crouch-jump every time you need to activate the thing". The best that could come of that is probably having them hit both moveleft and moveright at once do it, but that still feels weird.
I've tried using escape characters, like <bind f \"...\"> but apparently vbsp doesn't like that and it crashes the compiler
My last resort would probably be kindly asking the player to open up the console and type in the thing themselves, but obviously that has its own drawbacks. I'm assuming more than half the playerbase has never used the console and it would ruin the whole immersive gameplay experience
Fracture wrote:
i keep trying to bind certain keys and half the keys keep coming out saying key is unbound. IF IT'S NOT IN USE, I SHOULD BE ABLE TO BIND IT!!! >:(
It's because the quotes are causing a problem. The parameter to the servercommand is (iirc) wrapped in quotes when it's sent, so what's interpreted is just "bind z" or whatever.
Pack a CFG script with your map if you really HAVE to use keybinds and put them in there. But as Tenacious said it's not a good idea. I just discovered that Back-Stock rebound the "r" key and screwed up some of my scripts.
narsqrd wrote:
My last resort would probably be kindly asking the player to open up the console and type in the thing themselves, but obviously that has its own drawbacks. I'm assuming more than half the playerbase has never used the console and it would ruin the whole immersive gameplay experience