From bdee71440fe7f5eb7fc3579b61ee53ceb66596d1 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 7 Mar 2022 07:37:41 -0600 Subject: [PATCH 01/16] Business/house blips & pickups for IV --- scripts/client/main.js | 4 ++++ scripts/client/server.js | 13 +++++++++++++ scripts/client/sync.js | 25 ++++++++++++++++++++++--- scripts/server/business.js | 26 +++++++++++++++++++++----- scripts/server/client.js | 28 ++++++++++++++++++++++++++++ scripts/server/event.js | 6 ++++++ scripts/server/house.js | 16 ++++++++++++++++ 7 files changed, 110 insertions(+), 8 deletions(-) diff --git a/scripts/client/main.js b/scripts/client/main.js index 7292f970..fb292248 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -69,4 +69,8 @@ let forceWantedLevel = 0; // Pre-cache all allowed skins let allowedSkins = getAllowedSkins(getGame()); +let businessBlips = {}; +let houseBlips = {}; +let jobBlips = {}; + // =========================================================================== \ No newline at end of file diff --git a/scripts/client/server.js b/scripts/client/server.js index b5bb5da8..c2c8fd0a 100644 --- a/scripts/client/server.js +++ b/scripts/client/server.js @@ -101,6 +101,11 @@ function addAllNetworkHandlers() { addNetworkEventHandler("vrr.logLevel", setLogLevel); addNetworkEventHandler("vrr.infiniteRun", setLocalPlayerInfiniteRun); + + addNetworkEventHandler("vrr.business", receiveBusinessFromServer); + addNetworkEventHandler("vrr.house", receiveHouseFromServer); + + addNetworkEventHandler("vrr.holdObject", localPlayerHoldObject); } // =========================================================================== @@ -311,4 +316,12 @@ function setLocalPlayerSkin(skinId) { } } +// =========================================================================== + +function makePedHoldObject(client, modelIndex) { + if(getGame() == VRR_GAME_GTA_IV) { + + } +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/client/sync.js b/scripts/client/sync.js index 7b7d7413..56802738 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -393,15 +393,34 @@ function syncElementProperties(element) { // =========================================================================== -function receiveBlipFromServer(model, position) { +function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) { if(getGame() == VRR_GAME_GTA_IV) { - + if(typeof businessBlips[businessId] != "undefined") { + if(blipModel == -1) { + natives.removeBlipAndClearIndex(businessBlips[businessId]); + businessBlips.splice(businessId, 1); + } else { + natives.setBlipCoordinates(businessBlips[businessId], entrancePosition); + natives.changeBlipSprite(businessBlips[businessId], blipModel); + natives.changeBlipNameFromAscii(businessBlips[businessId], `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`); + } + } else { + if(blipModel != -1) { + let blipId = natives.addBlipForCoord(entrancePosition); + if(blipId) { + businessBlips[businessId] = blipId; + natives.changeBlipSprite(blipId, blipModel); + natives.setBlipMarkerLongDistance(blipId, true); + natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`); + } + } + } } } // =========================================================================== -function receivePickupFromServer(model, position) { +function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) { if(getGame() == VRR_GAME_GTA_IV) { } diff --git a/scripts/server/business.js b/scripts/server/business.js index 24af8bfa..54be2b14 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -1335,11 +1335,7 @@ function createAllBusinessBlips() { // =========================================================================== -function createBusinessEntrancePickup(businessId) { - if(!areServerElementsSupported()) { - return false; - } - +function createBusinessEntrancePickup(businessId) { if(!getServerConfig().createBusinessPickups) { return false; } @@ -1359,6 +1355,8 @@ function createBusinessEntrancePickup(businessId) { setElementDimension(getBusinessData(businessId).entrancePickup, getBusinessData(businessId).entranceDimension); updateBusinessPickupLabelData(businessId); addToWorld(getBusinessData(businessId).entrancePickup); + } else { + sendBusinessEntranceToPlayer(null, businessId, getBusinessData(businessId), getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false); } } } @@ -1388,6 +1386,8 @@ function createBusinessEntranceBlip(businessId) { setElementOnAllDimensions(getBusinessData(businessId).entranceBlip, false); setElementDimension(getBusinessData(businessId).entranceBlip, getBusinessData(businessId).entranceDimension); addToWorld(getBusinessData(businessId).entranceBlip); + } else { + sendBusinessEntranceToPlayer(null, businessId, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, blipModelId, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false); } } } @@ -1551,6 +1551,10 @@ function doesBusinessHaveInterior(businessId) { // =========================================================================== function deleteBusinessEntrancePickup(businessId) { + if(!areServerElementsSupported()) { + return false; + } + if(getBusinessData(businessId).entrancePickup != null) { //removeFromWorld(getBusinessData(businessId).entrancePickup); deleteGameElement(getBusinessData(businessId).entrancePickup); @@ -1561,6 +1565,10 @@ function deleteBusinessEntrancePickup(businessId) { // =========================================================================== function deleteBusinessExitPickup(businessId) { + if(!areServerElementsSupported()) { + return false; + } + if(getBusinessData(businessId).exitPickup != null) { //removeFromWorld(getBusinessData(businessId).exitPickup); deleteGameElement(getBusinessData(businessId).exitPickup); @@ -1571,6 +1579,10 @@ function deleteBusinessExitPickup(businessId) { // =========================================================================== function deleteBusinessEntranceBlip(businessId) { + if(!areServerElementsSupported()) { + return false; + } + if(getBusinessData(businessId).entranceBlip != null) { //removeFromWorld(getBusinessData(businessId).entranceBlip); deleteGameElement(getBusinessData(businessId).entranceBlip); @@ -1581,6 +1593,10 @@ function deleteBusinessEntranceBlip(businessId) { // =========================================================================== function deleteBusinessExitBlip(businessId) { + if(!areServerElementsSupported()) { + return false; + } + if(getBusinessData(businessId).exitBlip != null) { //removeFromWorld(getBusinessData(businessId).exitBlip); deleteGameElement(getBusinessData(businessId).exitBlip); diff --git a/scripts/server/client.js b/scripts/server/client.js index c0ea074c..94f0c851 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -1146,4 +1146,32 @@ function sendHouseEntranceToPlayer(client, houseId, entrancePosition, blipModel, sendNetworkEventToPlayer("vrr.house", client, houseId, entrancePosition, blipModel, pickupModel, hasInterior); } +// ========================================================================== + +function sendAllBusinessEntrancesToPlayer(client) { + let businesses = getServerData().businesses; + for(let i in businesses) { + if(businesses[i].entranceBlipModel > 0) { + sendBusinessEntranceToPlayer(client, businesses[i].index, businesses[i].name, businesses[i].entrancePosition, businesses[i].entranceBlipModel, businesses[i].entrancePickupModel, businesses[i].hasInterior, false); + } + } +} + +// ========================================================================== + +function sendAllHouseEntrancesToPlayer(client) { + let houses = getServerData().houses; + for(let i in houses) { + if(houses[i].entranceBlipModel > 0) { + sendBusinessEntranceToPlayer(client, businesses[i].index, houses[i].entrancePosition, houses[i].entranceBlipModel, houses[i].entrancePickupModel, houses[i].hasInterior); + } + } +} + +// ========================================================================== + +function makePlayerHoldObjectModel(client, modelIndex) { + sendNetworkEventToPlayer("vrr.holdObject", client, modelIndex); +} + // ========================================================================== \ No newline at end of file diff --git a/scripts/server/event.js b/scripts/server/event.js index fbe1edf7..cd147046 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -596,6 +596,12 @@ function onPlayerSpawn(client) { logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`); updateAllPlayerNameTags(); + if(!areServerElementsSupported()) { + sendAllBusinessEntrancesToPlayer(client); + sendAllHouseEntrancesToPlayer(client); + //sendAllJobLocationsToPlayer(client); + } + getPlayerData(client).payDayTickStart = sdl.ticks; //} } diff --git a/scripts/server/house.js b/scripts/server/house.js index 2eac6c2c..ba1d52d0 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -1140,6 +1140,10 @@ function doesHouseHaveInterior(houseId) { // =========================================================================== function deleteHouseEntrancePickup(houseId) { + if(!areServerElementsSupported()) { + return false; + } + if(getHouseData(houseId).entrancePickup != null) { //removeFromWorld(getHouseData(houseId).entrancePickup); deleteGameElement(getHouseData(houseId).entrancePickup); @@ -1150,6 +1154,10 @@ function deleteHouseEntrancePickup(houseId) { // =========================================================================== function deleteHouseExitPickup(houseId) { + if(!areServerElementsSupported()) { + return false; + } + if(getHouseData(houseId).exitPickup != null) { //removeFromWorld(getHouseData(houseId).exitPickup); deleteGameElement(getHouseData(houseId).exitPickup); @@ -1160,6 +1168,10 @@ function deleteHouseExitPickup(houseId) { // =========================================================================== function deleteHouseEntranceBlip(houseId) { + if(!areServerElementsSupported()) { + return false; + } + if(getHouseData(houseId).entranceBlip != null) { //removeFromWorld(getHouseData(houseId).entranceBlip); deleteGameElement(getHouseData(houseId).entranceBlip); @@ -1170,6 +1182,10 @@ function deleteHouseEntranceBlip(houseId) { // =========================================================================== function deleteHouseExitBlip(houseId) { + if(!areServerElementsSupported()) { + return false; + } + if(getHouseData(houseId).exitBlip != null) { //removeFromWorld(getHouseData(houseId).exitBlip); deleteGameElement(getHouseData(houseId).exitBlip); From 157e6c954dba4fe8758610b95fe8ac11c1f7a91c Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 7 Mar 2022 07:37:52 -0600 Subject: [PATCH 02/16] Woops wrong ID for burger blip --- scripts/shared/gamedata.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/shared/gamedata.js b/scripts/shared/gamedata.js index d89577a2..31d9fe6d 100644 --- a/scripts/shared/gamedata.js +++ b/scripts/shared/gamedata.js @@ -3405,7 +3405,7 @@ let gameData = { Clothes: 50, Pizza: 0, Chicken: 22, - Burger: 10, + Burger: 21, Bar: 47, Club: 48, Gym: 54, From dc2c156eb9c472a71d356a8373d480b8b8581f88 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 7 Mar 2022 07:38:08 -0600 Subject: [PATCH 03/16] Fix weapon slot util for IV --- scripts/client/utilities.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index 260cc2ff..1c761b69 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -404,7 +404,11 @@ function clearLocalPedState() { // =========================================================================== function getWeaponSlot(weaponId) { - return weaponSlots[game.game][weaponId]; + if(getGame() == VRR_GAME_GTA_IV) { + return false; + } + + return weaponSlots[getGame()][weaponId]; } // =========================================================================== From 7a21edc8f628bbe366b73c17c1d74f58776739a5 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 8 Mar 2022 01:08:14 -0600 Subject: [PATCH 04/16] New business stuff --- scripts/client/business.js | 52 ++++++++++++++++++++++++ scripts/client/label.js | 81 +++++++++++++++++++++----------------- scripts/client/main.js | 6 +-- scripts/client/sync.js | 37 ----------------- 4 files changed, 100 insertions(+), 76 deletions(-) create mode 100644 scripts/client/business.js diff --git a/scripts/client/business.js b/scripts/client/business.js new file mode 100644 index 00000000..599fec5c --- /dev/null +++ b/scripts/client/business.js @@ -0,0 +1,52 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: business.js +// DESC: Provides business functions and usage +// TYPE: Client (JavaScript) +// =========================================================================== + +class BusinessData() { + constructor(index, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) { + this.index = index; + this.name = name; + this.entrancePosition = entrancePosition; + this.blipModel = blipModel; + this.pickupModel = pickupModel; + this.hasInterior = hasInterior; + this.hasItems = hasItems; + this.blipId = -1; + } +} + +// =========================================================================== + +function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) { + if(getGame() == VRR_GAME_GTA_IV) { + if(getBusinessData(businessId) != false) { + if(blipModel == -1) { + natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId); + businesses.splice(getBusinessData(businessId).index, 1); + } else { + natives.setBlipCoordinates(getBusinessData(businessId).blipId, getBusinessData(businessId).entrancePosition); + natives.changeBlipSprite(getBusinessData(businessId).blipId, getBusinessData(businessId).blipModel); + natives.changeBlipNameFromAscii(getBusinessData(businessId).blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`); + } + } else { + if(blipModel != -1) { + let blipId = natives.addBlipForCoord(entrancePosition); + if(blipId) { + let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems); + tempBusinessData.blipId = blipId; + natives.changeBlipSprite(blipId, blipModel); + natives.setBlipMarkerLongDistance(blipId, true); + natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`); + businesses.push(tempBusinessData); + } + } + } + } +} + +// =========================================================================== \ No newline at end of file diff --git a/scripts/client/label.js b/scripts/client/label.js index 70e2df8e..1dd15426 100644 --- a/scripts/client/label.js +++ b/scripts/client/label.js @@ -249,42 +249,51 @@ function renderJobLabel(name, position, jobType) { function processLabelRendering() { if(renderLabels && areWorldLabelsSupported()) { if(localPlayer != null) { - let pickups = getElementsByType(ELEMENT_PICKUP); - for(let i in pickups) { - if(pickups[i].getData("vrr.label.type") != null) { - if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { - if(!pickups[i].isOnScreen) { - let price = "0"; - let rentPrice = "0"; - let labelInfoType = VRR_PROPLABEL_INFO_NONE; - if(pickups[i].getData("vrr.label.price") != null) { - price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price")); - } - - if(pickups[i].getData("vrr.label.rentprice") != null) { - rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice")); - } - - if(pickups[i].getData("vrr.label.help") != null) { - labelInfoType = pickups[i].getData("vrr.label.help"); - } - - switch(pickups[i].getData("vrr.label.type")) { - case VRR_LABEL_BUSINESS: - renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType); - break; - - case VRR_LABEL_HOUSE: - renderPropertyEntranceLabel("House", pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType); - break; - - case VRR_LABEL_JOB: - renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType")); - break; - - case VRR_LABEL_EXIT: - renderPropertyExitLabel(pickups[i].position); - break; + if(!areServerElementsSupported()) { + //for(let i in businessBlips) { + // if(pickups[i].getData("vrr.label.type") != null) { + // if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { + + // natives.getScreenViewportId + // natives.getViewportPositionOfCoord + } else { + let pickups = getElementsByType(ELEMENT_PICKUP); + for(let i in pickups) { + if(pickups[i].getData("vrr.label.type") != null) { + if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) { + if(!pickups[i].isOnScreen) { + let price = "0"; + let rentPrice = "0"; + let labelInfoType = VRR_PROPLABEL_INFO_NONE; + if(pickups[i].getData("vrr.label.price") != null) { + price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price")); + } + + if(pickups[i].getData("vrr.label.rentprice") != null) { + rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice")); + } + + if(pickups[i].getData("vrr.label.help") != null) { + labelInfoType = pickups[i].getData("vrr.label.help"); + } + + switch(pickups[i].getData("vrr.label.type")) { + case VRR_LABEL_BUSINESS: + renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType); + break; + + case VRR_LABEL_HOUSE: + renderPropertyEntranceLabel("House", pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType); + break; + + case VRR_LABEL_JOB: + renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType")); + break; + + case VRR_LABEL_EXIT: + renderPropertyExitLabel(pickups[i].position); + break; + } } } } diff --git a/scripts/client/main.js b/scripts/client/main.js index fb292248..7e56d8ce 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -69,8 +69,8 @@ let forceWantedLevel = 0; // Pre-cache all allowed skins let allowedSkins = getAllowedSkins(getGame()); -let businessBlips = {}; -let houseBlips = {}; -let jobBlips = {}; +let businesses = {}; +let houses = {}; +let jobs = {}; // =========================================================================== \ No newline at end of file diff --git a/scripts/client/sync.js b/scripts/client/sync.js index 56802738..2ffe01e3 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -14,18 +14,6 @@ function processSync(event, deltaTime) { sendNetworkEventToServer("vrr.player.heading", localPlayer.heading); } - //if(game.game == VRR_GAME_GTA_SA) { - // let lookAtPos = getLocalPlayerLookAtPosition(); - // sendNetworkEventToServer("vrr.player.lookat", lookAtPos); - // setEntityData(localPlayer, "vrr.headLook", lookAtPos); - // let peds = getPeds(); - // for(let i in peds) { - // if(doesEntityDataExist(peds[i], "vrr.headLook")) { - // peds[i].lookAt(getEntityData(peds[i], "vrr.headLook"), 99999); - // } - // } - //} - if(localPlayer.health <= 0) { if(!calledDeathEvent) { logToConsole(LOG_DEBUG, `Local player died`); @@ -391,32 +379,7 @@ function syncElementProperties(element) { } } -// =========================================================================== -function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) { - if(getGame() == VRR_GAME_GTA_IV) { - if(typeof businessBlips[businessId] != "undefined") { - if(blipModel == -1) { - natives.removeBlipAndClearIndex(businessBlips[businessId]); - businessBlips.splice(businessId, 1); - } else { - natives.setBlipCoordinates(businessBlips[businessId], entrancePosition); - natives.changeBlipSprite(businessBlips[businessId], blipModel); - natives.changeBlipNameFromAscii(businessBlips[businessId], `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`); - } - } else { - if(blipModel != -1) { - let blipId = natives.addBlipForCoord(entrancePosition); - if(blipId) { - businessBlips[businessId] = blipId; - natives.changeBlipSprite(blipId, blipModel); - natives.setBlipMarkerLongDistance(blipId, true); - natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`); - } - } - } - } -} // =========================================================================== 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 05/16] 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, "