Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions imports/addKeybind/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ function lib.addKeybind(data)
keybinds[data.name] = setmetatable(data, keybind_mt)

RegisterCommand('+' .. data.name, function()
if data.disabled or IsPauseMenuActive() then return end
if data.disabled or (IsPauseMenuActive() and not data.allowInPauseMenu) then return end
data.isPressed = true
if data.onPressed then data:onPressed() end
end)

RegisterCommand('-' .. data.name, function()
if data.disabled or IsPauseMenuActive() then return end
if data.disabled or (IsPauseMenuActive() and not data.allowInPauseMenu) then return end
data.isPressed = false
if data.onReleased then data:onReleased() end
end)
Expand Down
7 changes: 5 additions & 2 deletions package/client/addKeybind/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface KeybindProps {
description: string;
defaultMapper?: string;
defaultKey?: string;
allowInPauseMenu?: boolean;
disabled?: boolean;
disable?(this: CKeybind, toggle: boolean): void;
onPressed?(this: CKeybind): void;
Expand All @@ -30,6 +31,7 @@ class Keybind implements CKeybind {
onReleased?: (this: CKeybind) => void;
secondaryKey?: string;
secondaryMapper?: string;
allowInPauseMenu?: boolean;
[key: string]: any;

disabled: boolean = false;
Expand All @@ -43,6 +45,7 @@ class Keybind implements CKeybind {
this.defaultKey = data.defaultKey ?? '';
this.secondaryKey = data.secondaryKey;
this.secondaryMapper = data.secondaryMapper;
this.allowInPauseMenu = data.allowInPauseMenu;

if (typeof data.disabled === 'boolean') this.disabled = data.disabled;
this.onPressed = data.onPressed;
Expand Down Expand Up @@ -77,7 +80,7 @@ export function addKeybind(data: KeybindProps): CKeybind {
RegisterCommand(
'+' + kb.name,
() => {
if (kb.disabled || IsPauseMenuActive()) return;
if (kb.disabled || (!kb.allowInPauseMenu && IsPauseMenuActive())) return;
kb.isPressed = true;
kb.onPressed?.call(kb);
},
Expand All @@ -87,7 +90,7 @@ export function addKeybind(data: KeybindProps): CKeybind {
RegisterCommand(
'-' + kb.name,
() => {
if (kb.disabled || IsPauseMenuActive()) return;
if (kb.disabled || (!kb.allowInPauseMenu && IsPauseMenuActive())) return;
kb.isPressed = false;
kb.onReleased?.call(kb);
},
Expand Down