From 391e926478495f26d77d8d83bcfab7ff46625059 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 8 Mar 2022 01:09:08 -0600 Subject: [PATCH] Remove game script control (will use another resource) --- scripts/server/anticheat.js | 213 ------------------------------------ scripts/server/business.js | 24 ++-- scripts/server/command.js | 6 - scripts/server/core.js | 6 +- scripts/server/house.js | 20 ++-- scripts/shared/const.js | 8 +- 6 files changed, 30 insertions(+), 247 deletions(-) diff --git a/scripts/server/anticheat.js b/scripts/server/anticheat.js index e82b5079..38ff2b63 100644 --- a/scripts/server/anticheat.js +++ b/scripts/server/anticheat.js @@ -9,57 +9,8 @@ function initAntiCheatScript() { logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ..."); - getServerData().antiCheat.whiteListedGameScripts = loadAntiCheatGameScriptWhiteListFromDatabase(); - getServerData().antiCheat.blackListedGameScripts = loadAntiCheatGameScriptBlackListFromDatabase(); logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Anticheat script initialized!"); } -// =========================================================================== - -function loadAntiCheatGameScriptWhiteListFromDatabase() { - logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Loading whitelisted game scripts ...`); - let dbConnection = connectToDatabase(); - let tempWhiteListedGameScripts = []; - - if(dbConnection) { - let dbQueryString = `SELECT * FROM ac_script_wl WHERE ac_script_wl_enabled = 1 AND ac_script_wl_server = ${getServerId()}`; - let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { - let dbAssoc = fetchQueryAssoc(dbQuery); - let tempWhiteListedGameScriptData = new WhiteListedGameScriptData(dbAssoc); - tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData); - logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`); - } - } - disconnectFromDatabase(dbConnection); - } - logToConsole(LOG_DEBUG, `[VRR.AntiCheat] ${tempWhiteListedGameScripts.length} whitelisted game scripts loaded!`); - return tempWhiteListedGameScripts; -} - -// =========================================================================== - -function loadAntiCheatGameScriptBlackListFromDatabase() { - logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Loading blacklisted game scripts ...`); - let dbConnection = connectToDatabase(); - let tempBlackListedGameScripts = []; - - if(dbConnection) { - let dbQueryString = `SELECT * FROM ac_script_bl WHERE ac_script_bl_enabled = 1 AND ac_script_bl_server = ${getServerId()}`; - let dbQuery = queryDatabase(dbConnection, dbQueryString); - if(dbQuery) { - if(dbQuery.numRows > 0) { - let dbAssoc = fetchQueryAssoc(dbQuery); - let tempBlackListedGameScriptData = new BlackListedGameScriptData(dbAssoc); - tempBlackListedGameScripts.push(tempBlackListedGameScriptData); - logToConsole(LOG_DEBUG, `[VRR.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`); - } - } - disconnectFromDatabase(dbConnection); - } - logToConsole(LOG_DEBUG, `[VRR.AntiCheat] ${tempBlackListedGameScripts.length} blacklisted game scripts loaded!`); - return tempBlackListedGameScripts; -} // =========================================================================== @@ -76,170 +27,6 @@ function clearPlayerStateToEnterExitProperty(client) { // =========================================================================== -/** - * This is a command handler function. - * - * @param {string} command - The command name used by the player - * @param {string} params - The parameters/args string used with the command by the player - * @param {Client} client - The client/player that used the command - * @return {bool} Whether or not the command was successful - * - */ - function addAntiCheatBlackListedScriptCommand(command, params, client) { - if(areParamsEmpty(params)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); - return false; - } - - let scriptName = params; - let tempBlackListedGameScriptData = new BlackListedGameScriptData(false); - tempBlackListedGameScriptData.scriptName = scriptName; - tempBlackListedGameScriptData.serverId = getServerId(); - tempBlackListedGameScriptData.enabled = true; - tempBlackListedGameScriptData.needsSaved = true; - getServerConfig().antiCheat.blackListedGameScripts.push(tempBlackListedGameScriptData); - - if(getServerConfig().antiCheat.gameScriptBlackListEnabled) { - sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_DENY); - } - - messagePlayerSuccess(client, `You added {ALTCOLOUR}${scriptName} {MAINCOLOUR} to the anticheat game script blacklist`); - return true; -} - -// =========================================================================== - -/** - * This is a command handler function. - * - * @param {string} command - The command name used by the player - * @param {string} params - The parameters/args string used with the command by the player - * @param {Client} client - The client/player that used the command - * @return {bool} Whether or not the command was successful - * - */ - function addAntiCheatWhiteListedScriptCommand(command, params, client) { - if(areParamsEmpty(params)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); - return false; - } - - let scriptName = params; - let tempWhiteListedGameScriptData = new WhiteListedGameScriptData(false); - tempWhiteListedGameScriptData.scriptName = scriptName; - tempWhiteListedGameScriptData.serverId = getServerId(); - tempWhiteListedGameScriptData.enabled = true; - tempWhiteListedGameScriptData.needsSaved = true; - getServerConfig().antiCheat.whiteListedGameScripts.push(tempWhiteListedGameScriptData); - - if(getServerConfig().antiCheat.gameScriptWhiteListEnabled) { - sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_ALLOW); - } - - messagePlayerSuccess(client, `You added {ALTCOLOUR}${scriptName} {MAINCOLOUR} to the anticheat game script whitelist`); - return true; -} - -// =========================================================================== - -/** - * This is a command handler function. - * - * @param {string} command - The command name used by the player - * @param {string} params - The parameters/args string used with the command by the player - * @param {Client} client - The client/player that used the command - * @return {bool} Whether or not the command was successful - * - */ - function removeAntiCheatWhiteListedScriptCommand(command, params, client) { - if(areParamsEmpty(params)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); - return false; - } - - let whiteListScriptId = getAntiCheatWhiteListedScriptFromParams(params); - - getServerConfig().antiCheat.whiteListedGameScripts.splice(whiteListScriptId, 1); - - if(getServerConfig().antiCheat.gameScriptWhiteListEnabled) { - sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_NONE); - } - - messagePlayerSuccess(client, `You removed {ALTCOLOUR}${scriptName} {MAINCOLOUR} from the anticheat game script whitelist`); - return true; -} - -// =========================================================================== - -/** - * This is a command handler function. - * - * @param {string} command - The command name used by the player - * @param {string} params - The parameters/args string used with the command by the player - * @param {Client} client - The client/player that used the command - * @return {bool} Whether or not the command was successful - * - */ - function removeAntiCheatBlackListedScriptCommand(command, params, client) { - if(areParamsEmpty(params)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); - return false; - } - - let blackListScriptId = getAntiCheatBlackListedScriptFromParams(params); - - getServerConfig().antiCheat.blackListedGameScripts.splice(blackListScriptId, 1); - - if(getServerConfig().antiCheat.gameScriptBlackListEnabled) { - sendPlayerGameScriptState(null, scriptName, VRR_GAMESCRIPT_NONE); - } - - messagePlayerSuccess(client, `You removed {ALTCOLOUR}${scriptName} {MAINCOLOUR} from the anticheat game script blacklist`); - return true; -} - -// =========================================================================== - -/** - * This is a command handler function. - * - * @param {string} command - The command name used by the player - * @param {string} params - The parameters/args string used with the command by the player - * @param {Client} client - The client/player that used the command - * @return {bool} Whether or not the command was successful - * - */ - function toggleAntiCheatScriptWhiteListCommand(command, params, client) { - getServerConfig().antiCheat.gameScriptWhiteListEnabled = !getServerConfig().antiCheat.gameScriptWhiteListEnabled; - getServerConfig().needsSaved = true; - - messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned anticheat game script whitelist ${getBoolRedGreenInlineColour(getServerConfig().antiCheat.gameScriptWhiteListEnabled)}${toUpperCase(getOnOffFromBool(getServerConfig().antiCheat.gameScriptWhiteListEnabled))}`); - updateServerRules(); - return true; -} - -// =========================================================================== - -/** - * This is a command handler function. - * - * @param {string} command - The command name used by the player - * @param {string} params - The parameters/args string used with the command by the player - * @param {Client} client - The client/player that used the command - * @return {bool} Whether or not the command was successful - * - */ -function toggleAntiCheatScriptBlackListCommand(command, params, client) { - getServerConfig().antiCheat.gameScriptBlackListEnabled = !getServerConfig().antiCheat.gameScriptBlackListEnabled; - getServerConfig().needsSaved = true; - - messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned anticheat game script blacklist ${getBoolRedGreenInlineColour(getServerConfig().antiCheat.gameScriptBlackListEnabled)}${toUpperCase(getOnOffFromBool(getServerConfig().antiCheat.gameScriptBlackListEnabled))}`); - updateServerRules(); - return true; -} - -// =========================================================================== - function isPlayerExemptFromAntiCheat(client) { if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) { return true; diff --git a/scripts/server/business.js b/scripts/server/business.js index 54be2b14..9335ea09 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -58,7 +58,7 @@ function loadBusinessesFromDatabase() { while(dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessData = new BusinessData(dbAssoc); tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId); - tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); + //tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); tempBusinesses.push(tempBusinessData); logToConsole(LOG_INFO, `[VRR.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`); } @@ -105,6 +105,7 @@ function loadBusinessLocationsFromDatabase(businessId) { // =========================================================================== +/* function loadBusinessGameScriptsFromDatabase(businessId) { logToConsole(LOG_VERBOSE, `[VRR.Business]: Loading business game scripts for business ${businessId} from database ...`); @@ -133,6 +134,7 @@ function loadBusinessGameScriptsFromDatabase(businessId) { logToConsole(LOG_VERBOSE, `[VRR.Business]: ${tempBusinessGameScripts.length} game scripts for business ${businessId} loaded from database successfully!`); return tempBusinessGameScripts; } +*/ // =========================================================================== @@ -2058,19 +2060,19 @@ function doesBusinessHaveAnyItemsToBuy(businessId) { // =========================================================================== -function sendPlayerBusinessGameScripts(client, businessId) { - for(let i in getBusinessData(businessId).gameScripts) { - sendPlayerGameScriptState(client, getBusinessData(businessId).gameScripts[i].state); - } -} +//function sendPlayerBusinessGameScripts(client, businessId) { +// for(let i in getBusinessData(businessId).gameScripts) { +// sendPlayerGameScriptState(client, getBusinessData(businessId).gameScripts[i].state); +// } +//} // =========================================================================== -function clearPlayerBusinessGameScripts(client, businessId) { - for(let i in getBusinessData(businessId).gameScripts) { - sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY); - } -} +//function clearPlayerBusinessGameScripts(client, businessId) { +// for(let i in getBusinessData(businessId).gameScripts) { +// sendPlayerGameScriptState(client, VRR_GAMESCRIPT_DENY); +// } +//} // =========================================================================== diff --git a/scripts/server/command.js b/scripts/server/command.js index a7d1aaa6..c577d396 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -68,12 +68,6 @@ function loadCommands() { commandData("stopanim", stopPlayerAnimationCommand, "", getStaffFlagValue("None"), true, true, "Stops your current animation"), ], antiCheat: [ - commandData("addacscriptwl", addAntiCheatWhiteListedScriptCommand, "