Fixed keybind not working
This commit is contained in:
@@ -25,9 +25,16 @@ function initKeyBindScript() {
|
|||||||
function bindAccountKey(key, keyState) {
|
function bindAccountKey(key, keyState) {
|
||||||
logToConsole(LOG_DEBUG, `[Asshat.KeyBind]: Binded key ${sdl.getKeyName(key)} (${key})`);
|
logToConsole(LOG_DEBUG, `[Asshat.KeyBind]: Binded key ${sdl.getKeyName(key)} (${key})`);
|
||||||
bindKey(toInteger(key), keyState, function(event) {
|
bindKey(toInteger(key), keyState, function(event) {
|
||||||
if(hasKeyBindDelayElapsed() && canLocalPlayerUseKeyBinds()) {
|
if(hasKeyBindDelayElapsed()) {
|
||||||
lastKeyBindUse = sdl.ticks;
|
if(canLocalPlayerUseKeyBinds()) {
|
||||||
tellServerPlayerUsedKeyBind(key);
|
logToConsole(LOG_DEBUG, `[Asshat.KeyBind]: Using keybind for key ${sdl.getKeyName(key)} (${key})`);
|
||||||
|
lastKeyBindUse = sdl.ticks;
|
||||||
|
tellServerPlayerUsedKeyBind(key);
|
||||||
|
} else {
|
||||||
|
logToConsole(LOG_ERROR, `[Asshat.KeyBind]: Failed to use keybind for key ${sdl.getKeyName(key)} (${key}) - Not allowed to use keybinds!`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logToConsole(LOG_ERROR, `[Asshat.KeyBind]: Failed to use keybind for key ${sdl.getKeyName(key)} (${key}) - Not enough time has passed since last keybind use!`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -52,23 +59,8 @@ function hasKeyBindDelayElapsed() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function hasKeyBindHoldElapsed(keyState) {
|
|
||||||
let holdDuration = AG_KEYSTATE_HOLDSHORT
|
|
||||||
if(keyState == AG_KEYSTATE_HOLDLONG) {
|
|
||||||
holdDuration = keyBindLongHoldDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sdl.ticks-keyBindHoldStart >= holdDuration) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================================
|
|
||||||
|
|
||||||
function canLocalPlayerUseKeyBinds() {
|
function canLocalPlayerUseKeyBinds() {
|
||||||
return (!usingSkinSelector && isSpawned && !itemActionDelayEnabled);
|
return true; //(!usingSkinSelector && isSpawned && !itemActionDelayEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user