From 8db901f3ac28e2f03bad3442a7ab37236ef3d008 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 25 Jul 2021 22:16:54 -0500 Subject: [PATCH] Send enter prop keybind on new keybind add --- scripts/server/keybind.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/server/keybind.js b/scripts/server/keybind.js index 452d7f44..c7f584de 100644 --- a/scripts/server/keybind.js +++ b/scripts/server/keybind.js @@ -73,6 +73,14 @@ function addPlayerKeyBind(client, keyId, tempCommand, tempParams) { let keyBindData = new serverClasses.keyBindData(false, keyId, `${tempCommand} ${tempParams}`); getPlayerData(client).accountData.keyBinds.push(keyBindData); sendAddAccountKeyBindToClient(client, keyId, KEYSTATE_UP); + + if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { + let keyId = getPlayerKeyBindForCommand(client, "enter"); + logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`); + sendPlayerEnterPropertyKey(client, keyId.key); + } else { + sendPlayerEnterPropertyKey(client, false); + } } // =========================================================================== @@ -85,6 +93,14 @@ function removePlayerKeyBind(client, keyId) { } } sendRemoveAccountKeyBindToClient(client, keyId); + + if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { + let keyId = getPlayerKeyBindForCommand(client, "enter"); + logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`); + sendPlayerEnterPropertyKey(client, keyId.key); + } else { + sendPlayerEnterPropertyKey(client, false); + } } // =========================================================================== @@ -122,6 +138,12 @@ function doesPlayerHaveKeyBindForKey(client, key) { // =========================================================================== +function doesPlayerHaveKeyBindsDisabled(client) { + return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("disableKeyBinds")); +} + +// =========================================================================== + function getPlayerKeyBindForKey(client, key) { for(let i in getPlayerData(client).accountData.keyBinds) { if(getPlayerData(client).accountData.keyBinds[i].key == key) { @@ -143,7 +165,7 @@ function playerUsedKeyBind(client, key) { } logToConsole(LOG_DEBUG, `[VRR.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`); - if(doesPlayerHaveKeyBindForKey(client, key)) { + if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) { let keyBindData = getPlayerKeyBindForKey(client, key); if(keyBindData.enabled) { let splitCommandString = keyBindData.commandString.split(" "); @@ -161,6 +183,7 @@ function playerUsedKeyBind(client, key) { // =========================================================================== function sendAccountKeyBindsToClient(client) { + sendClearKeyBindsToClient(client); for(let i in getPlayerData(client).accountData.keyBinds) { sendAddAccountKeyBindToClient(client, getPlayerData(client).accountData.keyBinds[i].key, getPlayerData(client).accountData.keyBinds[i].keyState); }