mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
refactor(addKeybind): move RegisterCommand to top
This commit is contained in:
@@ -22,10 +22,7 @@ local IsPauseMenuActive = IsPauseMenuActive
|
|||||||
---@param data KeybindProps
|
---@param data KeybindProps
|
||||||
---@return CKeybind
|
---@return CKeybind
|
||||||
function lib.addKeybind(data)
|
function lib.addKeybind(data)
|
||||||
data.defaultKey = data.defaultKey or ''
|
if not data.defaultKey then data.defaultKey = '' end
|
||||||
data.currentKey = GetControlInstructionalButton(0, joaat('+' .. data.name) | 0x80000000, true):sub(3)
|
|
||||||
data.disabled = data.disabled or false
|
|
||||||
data.disable = disableKeybind
|
|
||||||
|
|
||||||
RegisterCommand('+' .. data.name, function()
|
RegisterCommand('+' .. data.name, function()
|
||||||
if not data.onPressed or data.disabled or IsPauseMenuActive() then return end
|
if not data.onPressed or data.disabled or IsPauseMenuActive() then return end
|
||||||
@@ -44,6 +41,9 @@ function lib.addKeybind(data)
|
|||||||
TriggerEvent('chat:removeSuggestion', ('/-%s'):format(data.name))
|
TriggerEvent('chat:removeSuggestion', ('/-%s'):format(data.name))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
data.currentKey = GetControlInstructionalButton(0, joaat('+' .. data.name) | 0x80000000, true):sub(3)
|
||||||
|
data.disabled = data.disabled or false
|
||||||
|
data.disable = disableKeybind
|
||||||
keybinds[data.name] = data
|
keybinds[data.name] = data
|
||||||
---@cast data -KeybindProps
|
---@cast data -KeybindProps
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user