mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(client/addKeybind): save control hash
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
---@class CKeybind : KeybindProps
|
||||
---@field currentKey string
|
||||
---@field disabled boolean
|
||||
---@field hash number
|
||||
---@field getCurrentKey fun(): string
|
||||
|
||||
local keybinds = {}
|
||||
@@ -20,7 +22,6 @@ end
|
||||
|
||||
local IsPauseMenuActive = IsPauseMenuActive
|
||||
local GetControlInstructionalButton = GetControlInstructionalButton
|
||||
local joaat = joaat
|
||||
|
||||
local keybind_mt = {
|
||||
disabled = false,
|
||||
@@ -39,7 +40,7 @@ function keybind_mt:__index(index)
|
||||
end
|
||||
|
||||
function keybind_mt:getCurrentKey()
|
||||
return GetControlInstructionalButton(0, joaat('+' .. self.name) | 0x80000000, true):sub(3)
|
||||
return GetControlInstructionalButton(0, self.hash, true):sub(3)
|
||||
end
|
||||
|
||||
---@param data KeybindProps
|
||||
@@ -64,11 +65,12 @@ function lib.addKeybind(data)
|
||||
TriggerEvent('chat:removeSuggestion', ('/-%s'):format(data.name))
|
||||
end)
|
||||
|
||||
data.hash = joaat('+' .. data.name) | 0x80000000
|
||||
data.disabled = data.disabled
|
||||
data.disable = disableKeybind
|
||||
keybinds[data.name] = setmetatable(data, keybind_mt)
|
||||
---@cast data -KeybindProps
|
||||
return data
|
||||
|
||||
return data --[[@as CKeybind]]
|
||||
end
|
||||
|
||||
return lib.addKeybind
|
||||
|
||||
Reference in New Issue
Block a user