Keybind resource for FiveM
Creating custom keybinds for fivem made easy.
This resource allows you to create dynamic keybinds that users can customize for their own tastes.
This is able because of the relatively new RegisterKeyMapping
feature in fivem which allows us to bind commands to certain keys.
These keys will show up under the keybind settings in the native GTAV settings menu.
Usage
Using the resource
This resource uses exports to handle the registering of keybinds.
All examples below will be in LUA
but they can be used in JavaScript
as well.
Creating a simple keybind:
exports.keybinds:RegisterKeybind(name, description, key, func)
-
Name: The name of the keybind, later needed to toggle it on/off
-
description: The description of the keybind. This will show up in the settings.
-
key: A key to be used as default. You can get the key ids from this website: KEYBOARD - Cfx.re Docs
-
func: This is the function that will be played on the press of the keybind
Creating a keybind that needs to be held down:
exports.keybinds:RegisterHoldKeybind(name, description, key, func, delay)
-
Name: The name of the keybind, later needed to toggle it on/off
-
description: The description of the keybind. This will show up in the settings.
-
key: A key to be used as default. You can get the key ids from this website: KEYBOARD - Cfx.re Docs
-
func: This is the function that will be played when the keybind is held down
-
delay: This sets the frequency of the function playing while the keybind is held down (miliseconds)
Note: The function always plays first, so when you press the keybind once, the function still plays
Creating a two way keybind:
exports.keybinds:RegisterTwoWayKeybind(name, description, key, func1, func2)
-
Name: The name of the keybind, later needed to toggle it on/off
-
description: The description of the keybind. This will show up in the settings.
-
key: A key to be used as default. You can get the key ids from this website: KEYBOARD - Cfx.re Docs
-
func1: This is the function that will be played when the keybind is pressed
-
func2: This is the function that will be played when the keybind is released
Toggling the keybinds:
exports.keybinds:ToggleKeybind(name, state)
-
Name: The name of the keybind that you want to toggle
-
State:
true
means the keybind doesn’t do anything,false
means the keybind is active
HUN description
Keybind resource a Fivem-hez
Billentyűparancsok készítése leegyszerűsítve
Ezzel a resource-al képes vagy olyan billentyűparancsokat létrehozni amelyet a felhasználók könnyedén tudnak változtatni saját izlésük szerint
Ez a viszonylag új RegisterKeyMapping
function miatt jöhetett létre, amely képes parancsokhoz billentyűparancsot rendelni.
Az összes billentyűparancs amit ezzel készítesz a GTAV-s beállításokon belül megtalálható és állítható lesz.
Felhasználás
Ez a resource exportokat használ a billentyűparancsok létrehozására
A lenti pélák mind LUA
nyelven vannak feltüntetve, viszont JavaScript
-ben is müködnek.
Egyszerű billentyűparancs készítése:
exports.keybinds:RegisterKeybind(name, description, key, func)
-
Name: A billentyűparancs neve. Késöbb a kikapcsolásához fog kelleni.
-
description: A billentyűparancs leírása. Ez fog megjelenni a beállításokban is.
-
key: Az alapértelmezett billenytű. A következő weboldalon megtalálod az összes lehetőséget: KEYBOARD - Cfx.re Docs
-
func: A kód ami le fog játszódni amikor lenyomják a billentyűparancs-ot. (Egy function)
Lenyomva tartható billentyűparancs készítése:
exports.keybinds:RegisterHoldKeybind(name, description, key, func, delay)
-
Name: A billentyűparancs neve. Késöbb a kikapcsolásához fog kelleni.
-
description: A billentyűparancs leírása. Ez fog megjelenni a beállításokban is.
-
key: Az alapértelmezett billenytű. A következő weboldalon megtalálod az összes lehetőséget: KEYBOARD - Cfx.re Docs
-
func: A kód ami le fog játszódni amikor lenyomják a billentyűparancs-ot. (Egy function)
-
delay: Mennyi idő teljen el kettő lejátszott kódsor között (milisec)
Note: A function mindig először játszódik le, és utána várokozik, így elég ha a felhasználó egyszer lenyomja, akkor is lejátszódik.
Kétirányú billentyűparancs készítése:
exports.keybinds:RegisterTwoWayKeybind(name, description, key, func1, func2)
-
Name: A billentyűparancs neve. Késöbb a kikapcsolásához fog kelleni.
-
description: A billentyűparancs leírása. Ez fog megjelenni a beállításokban is.
-
key: Az alapértelmezett billenytű. A következő weboldalon megtalálod az összes lehetőséget: KEYBOARD - Cfx.re Docs
-
func1: Kód amely lejátszódik amikor lenyomja a felhasználó a billentyűt
-
func2: Kód amely lejátszódik amikor felengedi a felhasználó a billentyűt
Billentyűparancsok kapcsolása:
exports.keybinds:ToggleKeybind(name, state)
-
Name: A billentyűparancs neve amelyet kapcsolni szeretnél
-
State:
true
azt jelenti hogy a billentyűparancs nem csinál semmit,false
azt jelenti hogy a billentyűparancs aktív
Download
Github: GitHub - 0324bence/FiveM-Keybinds: A resource that allows you to create custom keybinds
Direct download(zip): keybinds.zip (3.1 KB)