From 3e7e3b5a2d2232e5b6995c1adf1dda900cf5602c Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 4 Jan 2022 20:04:45 -0600 Subject: [PATCH] Add command from params util --- scripts/server/utilities.js | 38 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 224399aa..55f430c7 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -688,6 +688,20 @@ function getAccentFromParams(params) { // =========================================================================== +function getCommandFromParams(params) { + for(let i in serverCommands) { + for(let j in serverCommands[i]) { + if(toLowerCase(serverCommands[i][j].command).indexOf(toLowerCase(params)) != -1) { + return serverCommands[i][j]; + } + } + } + + return false; +} + +// =========================================================================== + function getLocaleNameFromParams(params) { let locales = getLocales(); if(isNaN(params)) { @@ -1381,13 +1395,13 @@ function isConsole(client) { // =========================================================================== function updateConnectionLogOnQuit(client, quitReasonId) { - quickDatabaseQuery(`UPDATE conn_main SET conn_when_disconnect=NOW(), conn_how_disconnect=${quitReasonId} WHERE conn_id = ${toInteger(getEntityData(client, "vrr.connection"))}`); + quickDatabaseQuery(`UPDATE conn_main SET conn_when_disconnect=NOW(), conn_how_disconnect=${quitReasonId} WHERE conn_id = ${getPlayerData(client).connectionId}`); } // =========================================================================== function updateConnectionLogOnAuth(client, authId) { - quickDatabaseQuery(`UPDATE conn_main SET conn_auth=${authId} WHERE conn_id = ${toInteger(getEntityData(client, "vrr.connection"))}`); + quickDatabaseQuery(`UPDATE conn_main SET conn_auth=${authId} WHERE conn_id = ${getPlayerData(client).connectionId}`); } // =========================================================================== @@ -1398,7 +1412,7 @@ function updateConnectionLogOnClientInfoReceive(client, clientVersion, screenWid let safeClientVersion = escapeDatabaseString(dbConnection, clientVersion); let safeScreenWidth = escapeDatabaseString(dbConnection, toString(screenWidth)); let safeScreenHeight = escapeDatabaseString(dbConnection, toString(screenHeight)); - quickDatabaseQuery(`UPDATE conn_main SET conn_client_version='${safeClientVersion}', conn_screen_width='${safeScreenWidth}', conn_screen_height='${safeScreenHeight}' WHERE conn_id = ${toInteger(getEntityData(client, "vrr.connection"))}`); + quickDatabaseQuery(`UPDATE conn_main SET conn_client_version='${safeClientVersion}', conn_screen_width='${safeScreenWidth}', conn_screen_height='${safeScreenHeight}' WHERE conn_id = ${getPlayerData(client).connectionId}`); } } @@ -1430,24 +1444,6 @@ function fixCharacterName(name) { // =========================================================================== -function getAllVehiclesOwnedByPlayer(client) { - return getServerData().vehicles.filter((v) => v.ownerType == VRR_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId); -} - -// =========================================================================== - -function getAllBusinessesOwnedByPlayer(client) { - return getServerData().businesses.filter((b) => b.ownerType == VRR_BIZOWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId); -} - -// =========================================================================== - -function getAllHousesOwnedByPlayer(client) { - return getServerData().houses.filter((h) => h.ownerType == VRR_HOUSEOWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId); -} - -// =========================================================================== - function addPositiveNegativeSymbol(value) { return (value >= 0) ? `+${value}` : `${value}`; }