Start working on combo keybind support
This commit is contained in:
@@ -19,19 +19,16 @@ function initKeyBindScript() {
|
|||||||
function addKeyBindCommand(command, params, client) {
|
function addKeyBindCommand(command, params, client) {
|
||||||
let splitParams = params.split(" ");
|
let splitParams = params.split(" ");
|
||||||
|
|
||||||
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
|
let keys = getKeysInComboName(getParam(params, " ", 1));
|
||||||
let tempCommand = getParam(params, " ", 2);
|
let tempCommand = getParam(params, " ", 2);
|
||||||
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
|
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
|
||||||
|
|
||||||
if(!keyId) {
|
if(keys.indexOf(false) != -1) {
|
||||||
messagePlayerError(client, "The key ID or name you input is invalid!");
|
messagePlayerError(client, "One of the key names you input is invalid!");
|
||||||
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
|
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces. Must be lowercase.");
|
||||||
|
messagePlayerTip(client, "No actual symbols, use a name for those if needed like ampersand, hashtag, tilde, etc");
|
||||||
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
|
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
|
||||||
return false;
|
messagePlayerInfo(client, `For combos, use a plus sign between the keys. No spaces! Example: {ALTCOLOUR}rightctrl+num3{MAINCOLOUR}`);
|
||||||
}
|
|
||||||
|
|
||||||
if(!keyId) {
|
|
||||||
messagePlayerError(client, "That key name/id is invalid!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,14 +38,12 @@ function addKeyBindCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
|
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
|
||||||
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
|
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(keys.join(" + "))} {MAINCOLOUR}keys to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function removeKeyBindCommand(command, params, client) {
|
function removeKeyBindCommand(command, params, client) {
|
||||||
let splitParams = params.split(" ");
|
|
||||||
|
|
||||||
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
|
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
|
||||||
|
|
||||||
if(!keyId) {
|
if(!keyId) {
|
||||||
@@ -75,6 +70,8 @@ function addPlayerKeyBind(client, keys, command, params, tempKey = false) {
|
|||||||
keyBindData.databaseId = -1;
|
keyBindData.databaseId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyBindData.needsSaved = true;
|
||||||
|
|
||||||
getPlayerData(client).keyBinds.push(keyBindData);
|
getPlayerData(client).keyBinds.push(keyBindData);
|
||||||
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
|
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
|
||||||
|
|
||||||
@@ -218,3 +215,28 @@ function showKeyBindListCommand(command, params, client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
function getKeyNamesInComboName(comboName) {
|
||||||
|
if(comboName.indexOf("+") != -1) {
|
||||||
|
return comboName.split("+");
|
||||||
|
} else {
|
||||||
|
return [comboName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function getKeysInComboName(comboName) {
|
||||||
|
let keyNames = getKeyNamesInComboName(comboName);
|
||||||
|
let keys = [];
|
||||||
|
for(let i in keyNames) {
|
||||||
|
if(getKeyIdFromParams(keyNames[i])) {
|
||||||
|
keys.push(getKeyIdFromParams(keyNames[i]));
|
||||||
|
} else {
|
||||||
|
keys.push(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user