mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
refactor(addKeybind): consistency with defaultKey (#128)
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
---@field name string
|
---@field name string
|
||||||
---@field description string
|
---@field description string
|
||||||
---@field defaultKey? string
|
---@field defaultKey? string
|
||||||
---@field keybind string
|
---@field currentKey string
|
||||||
---@field disabled? boolean
|
---@field disabled? boolean
|
||||||
---@field disable? fun(self: CKeybind, toggle: boolean)
|
---@field disable? fun(self: CKeybind, toggle: boolean)
|
||||||
---@field onPressed? fun(self: CKeybind)
|
---@field onPressed? fun(self: CKeybind)
|
||||||
@@ -20,7 +20,7 @@ local IsPauseMenuActive = IsPauseMenuActive
|
|||||||
---@return CKeybind
|
---@return CKeybind
|
||||||
function lib.addKeybind(data)
|
function lib.addKeybind(data)
|
||||||
data.defaultKey = data.defaultKey or ''
|
data.defaultKey = data.defaultKey or ''
|
||||||
data.keybind = GetControlInstructionalButton(0, joaat('+' .. data.name) | 0x80000000, true):sub(3)
|
data.currentKey = GetControlInstructionalButton(0, joaat('+' .. data.name) | 0x80000000, true):sub(3)
|
||||||
data.disabled = data.disabled or false
|
data.disabled = data.disabled or false
|
||||||
data.disable = disableKeybind
|
data.disable = disableKeybind
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ function lib.addKeybind(data)
|
|||||||
data:onReleased()
|
data:onReleased()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterKeyMapping('+' .. data.name, data.description, 'keyboard', data.keybind)
|
RegisterKeyMapping('+' .. data.name, data.description, 'keyboard', data.defaultKey)
|
||||||
|
|
||||||
SetTimeout(500, function()
|
SetTimeout(500, function()
|
||||||
TriggerEvent('chat:removeSuggestion', ('/+%s'):format(data.name))
|
TriggerEvent('chat:removeSuggestion', ('/+%s'):format(data.name))
|
||||||
|
|||||||
Reference in New Issue
Block a user