Files
Elite-Gaming-FiveM/resources/mth-K9/RageUI/components/Keys.lua
T
2025-01-23 18:00:31 -08:00

54 lines
1.2 KiB
Lua

---
--- @author Dylan MALANDAIN
--- @version 2.0.0
--- @since 2020
---
--- RageUI Is Advanced UI Libs in LUA for make beautiful interface like RockStar GAME.
---
---
--- Commercial Info.
--- Any use for commercial purposes is strictly prohibited and will be punished.
---
--- @see RageUI
---
---@class Keys
Keys = {};
---Register
---@param Controls string
---@param ControlName string
---@param Description string
---@param Action function
---@return Keys
---@public
Keys = {
keysAllow = true
}
function Keys.Register(Controls, ControlName, Description, Action)
local _Keys = {
CONTROLS = Controls
}
RegisterKeyMapping(string.format('rageui-%s', ControlName), Description, "keyboard", Controls)
RegisterCommand(string.format('rageui-%s', ControlName), function(source, args)
if (Action ~= nil) then
if Keys.keysAllow then
Action();
else
ShowNotification("~r~Action impossible ...~s~")
end
end
end, false)
return setmetatable(_Keys, Keys)
end
---Exists
---@param Controls string
---@return boolean
function Keys:Exists(Controls)
return self.CONTROLS == Controls and true or false
end