diff --git a/scripts/client/keybind.js b/scripts/client/keybind.js index 9c3693b3..716d0138 100644 --- a/scripts/client/keybind.js +++ b/scripts/client/keybind.js @@ -13,58 +13,32 @@ let keyBindDelayTime = 500; let keyBindShortHoldDuration = 500; let keyBindLongHoldDuration = 1500; -// ------------------------------------------------------------------------- +// =========================================================================== + +function initKeyBindScript() { + logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Initializing key bind script ..."); + logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Key bind script initialized!"); +} + +// =========================================================================== function bindAccountKey(key, keyState) { bindKey(toInteger(key), keyState, function(event) { if(hasKeyBindDelayElapsed()) { lastKeyBindUse = sdl.ticks; - triggerNetworkEvent("ag.useKeyBind", key); + tellServerPlayerUsedKeyBind(key); } }); - - /* - if(keyState == AG_KEYSTATE_UP) { - bindKey(toInteger(key), KEYSTATE_UP, function(event) { - if(hasKeyBindDelayElapsed()) { - lastKeyBindUse = sdl.ticks; - triggerNetworkEvent("ag.useKeyBind", key); - } - }); - } else if(keyState == AG_KEYSTATE_DOWN) { - bindKey(toInteger(key), KEYSTATE_DOWN, function(event) { - if(hasKeyBindDelayElapsed()) { - lastKeyBindUse = sdl.ticks; - triggerNetworkEvent("ag.useKeyBind", key); - } - }); - } else if(keyState == AG_KEYSTATE_HOLDSHORT || keyState == AG_KEYSTATE_HOLDLONG) { - bindKey(toInteger(key), KEYSTATE_DOWN, function(event) { - if(hasKeyBindDelayElapsed()) { - lastKeyBindUse = sdl.ticks; - keyBindHoldStart = sdl.ticks; - } - }); - bindKey(toInteger(key), KEYSTATE_UP, function(event) { - if(hasKeyBindHoldElapsed(keyState)) { - keyBindHoldStart = 0; - triggerNetworkEvent("ag.useKeyBind", key); - } - }); - } - */ } -addNetworkHandler("ag.addKeyBind", bindAccountKey); -// ------------------------------------------------------------------------- +// =========================================================================== function unBindAccountKey(key) { unbindKey(key); return true; } -addNetworkHandler("ag.delKeyBind", unBindAccountKey); -// ------------------------------------------------------------------------- +// =========================================================================== function hasKeyBindDelayElapsed() { if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) { @@ -74,7 +48,7 @@ function hasKeyBindDelayElapsed() { return false; } -// ------------------------------------------------------------------------- +// =========================================================================== function hasKeyBindHoldElapsed(keyState) { let holdDuration = AG_KEYSTATE_HOLDSHORT @@ -89,4 +63,4 @@ function hasKeyBindHoldElapsed(keyState) { return false; } -// ------------------------------------------------------------------------- \ No newline at end of file +// =========================================================================== \ No newline at end of file