From f96cb13ff43b9b7760fb66bcf1453bb862dfefe3 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 24 Nov 2022 17:31:03 +1100 Subject: [PATCH] refactor(client/addKeybind): save control hash --- imports/addKeybind/client.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/imports/addKeybind/client.lua b/imports/addKeybind/client.lua index b9449c7..484eee0 100644 --- a/imports/addKeybind/client.lua +++ b/imports/addKeybind/client.lua @@ -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