Hey,
i recently started using the console key bindings that got implemented on 6th January this year.
Using the new console key bindings – FiveM Cookbook It seems like the feature is out of canary and every client already has this.
This is how I use the function: (everything on the client)
RegisterKeyMapping("mycommand", "Feature 1", "keyboard", "PLUS");
RegisterCommand("mycommand", function () {
// do my stuff
});
Now my question is: Is there any way to get the key that the command is currently mapped to? What I am trying to get is the hash value of the key. Something like ~INPUT_???~
These bindings will be editable by the user in the ‘key bindings’ option (only 1 binding per command yet, no secondary binding), and depending on user demand we’ll add a helper for computing the right hashes to use with ~INPUT_~-style display as well for help hints and similar.
The feature got already mentioned in the cookbook, but I wonder if it is already implemented or will come soon.
Sorry this isn’t an answer, more of a question to you.
Have you been able to get keys to work that already have actions, I’m trying to bind a key to F5 and it won’t work, but if I bind it to say ’ it will. Any ideas?
I just tried to rebind “PLUS” to “F” with the code provided above. “F” is also bound to enter/leave a vehicle and for me it does both actions. When I now press F next to a vehicle, it runs “mycommand” and my character enters the vehicle.
In addition to that, I executed bind KEYBOARD F "say hello"
in F8 console. Even though F is already bound to enter/leave vehicle, it still works.
If that isn’t working for you, I guess it gets somehow blocked by any resource that you have installed? For me everything is working on a “stock” server with default resources.
Fun fact: If I enter bind KEYBOARD F "say hello"
5 times in the console, the same command gets executed 5 times.
Thanks for the information, turned out it was a bug that stops the bind from working when switching views. There’s a thread in the bug reports section for it.
bump. This would be very useful.
This feature is already implemented/got fixed. This topic might help you: RegisterKeyMapping - Get the right hash to read the current binding
GetControlInstructionalButton(padIndex: number, control: number, p2: Player);
http://tools.povers.fr/hashgenerator/
2 Likes