diff --git a/scripts/server/keybind.js b/scripts/server/keybind.js index 9787aa19..011da3a8 100644 --- a/scripts/server/keybind.js +++ b/scripts/server/keybind.js @@ -43,6 +43,11 @@ function initKeyBindScript() { // =========================================================================== function addKeyBindCommand(command, params, client) { + if (areParamsEmpty(tempCommand)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); + return false; + } + let splitParams = params.split(" "); let keyId = getKeyIdFromParams(getParam(params, " ", 1)); @@ -50,45 +55,35 @@ function addKeyBindCommand(command, params, client) { let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : ""; if (!keyId) { - messagePlayerError(client, "The key ID or name you input is invalid!"); - messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces."); - messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`); - return false; - } - - if (!keyId) { - messagePlayerError(client, "That key name/id is invalid!"); - return false; - } - - if (areParamsEmpty(tempCommand)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); + messagePlayerError(client, getLocaleString(client, "InvalidKeyBindName")); + messagePlayerTip(client, getLocaleString(client, "KeyBindNameTip")); + messagePlayerInfo(client, getLocaleString(client, "UniversalInlineExampleList", `{ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl{MAINCOLOR}`)); return false; } addPlayerKeyBind(client, keyId, tempCommand, tempParams); - messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`); + messagePlayerSuccess(client, getLocaleString(client, "KeyBindRemoved", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))}{MAINCOLOUR}`, `{ALTCOLOUR}/${tempCommand} ${tempParams}`)); } // =========================================================================== function removeKeyBindCommand(command, params, client) { - let keyId = getKeyIdFromParams(getParam(params, " ", 1)); - - if (!keyId) { - messagePlayerError(client, "The key ID or name you input is invalid!"); - messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces."); - messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`); + if (areParamsEmpty(tempCommand)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } + let keyId = getKeyIdFromParams(getParam(params, " ", 1)); + if (!keyId) { - messagePlayerError(client, "That key name/id is invalid!"); + messagePlayerError(client, getLocaleString(client, "InvalidKeyBindName")); + messagePlayerTip(client, getLocaleString(client, "KeyBindNameTip")); + messagePlayerInfo(client, getLocaleString(client, "UniversalInlineExampleList", `{ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl{MAINCOLOR}`)); return false; } removePlayerKeyBind(client, keyId); - messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`); + messagePlayerSuccess(client, getLocaleString(client, "KeyBindRemoved", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))}{MAINCOLOUR}`)); } // =========================================================================== @@ -102,6 +97,15 @@ function resetKeyBindsCommand(command, params, client) { // =========================================================================== +function copyKeyBindsToServerCommand(command, params, client) { + getPlayerData(client).promptType = AGRP_PROMPT_COPYKEYBINDSTOSERVER; + showPlayerPrompt(client, getLocaleString(client, "CopyAllKeyBindsToServerConfirm"), getLocaleString(client, "GUIWarningTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No")); + //removePlayerKeyBind(client, keyId); + //messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`); +} + +// =========================================================================== + function addPlayerKeyBind(client, keys, command, params, tempKey = false) { let keyBindData = new KeyBindData(false, keys, `${command} ${params}`); if (tempKey == true) {