From f121b473aa7e2b38619510251871e551c1052259 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Fri, 17 Jun 2022 15:14:17 -0500 Subject: [PATCH] Add debug logging --- scripts/server/item.js | 10 ++++++++-- scripts/server/job.js | 20 ++++++++++---------- scripts/server/npc.js | 4 ++-- scripts/server/paintball.js | 17 +++++++++++++++-- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/scripts/server/item.js b/scripts/server/item.js index 24caf1e5..f75f2132 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -241,14 +241,15 @@ class ItemTypeData { // =========================================================================== function initItemScript() { - logToConsole(LOG_INFO, "[VRR.Item]: Initializing item script ..."); - logToConsole(LOG_INFO, "[VRR.Item]: Item script initialized successfully!"); + logToConsole(LOG_DEBUG, "[VRR.Item]: Initializing item script ..."); + logToConsole(LOG_DEBUG, "[VRR.Item]: Item script initialized successfully!"); return true; } // =========================================================================== function loadItemsFromDatabase() { + logToConsole(LOG_DEBUG, `[VRR.Item]: Loading items from database ...`); let tempItems = []; let dbConnection = connectToDatabase(); let dbFetchAssoc; @@ -259,18 +260,21 @@ function loadItemsFromDatabase() { while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) { let tempItemData = new ItemData(dbFetchAssoc); tempItems.push(tempItemData); + logToConsole(LOG_VERBOSE, `[VRR.Item]: Loaded item ${tempItemData.databaseId} (type ${tempItemData.itemType})} from database`); } } freeDatabaseQuery(dbQuery); } disconnectFromDatabase(dbConnection); } + logToConsole(LOG_DEBUG, `[VRR.Item]: Loaded ${tempItems.length} items from database ...`); return tempItems; } // =========================================================================== function loadItemTypesFromDatabase() { + logToConsole(LOG_DEBUG, `[VRR.Item]: Loading item types from database ...`); let tempItemTypes = []; let dbConnection = connectToDatabase(); let dbFetchAssoc; @@ -281,6 +285,7 @@ function loadItemTypesFromDatabase() { while (dbFetchAssoc = fetchQueryAssoc(dbQuery)) { let tempItemTypeData = new ItemTypeData(dbFetchAssoc); tempItemTypes.push(tempItemTypeData); + logToConsole(LOG_VERBOSE, `[VRR.Item]: Loaded item type ${tempItemTypeData.name} (id ${tempItemTypeData.databaseId}} from database`); } } freeDatabaseQuery(dbQuery); @@ -288,6 +293,7 @@ function loadItemTypesFromDatabase() { disconnectFromDatabase(dbConnection); } + logToConsole(LOG_DEBUG, `[VRR.Item]: Loaded ${tempItemTypes.length} item types from database ...`); return tempItemTypes; } diff --git a/scripts/server/job.js b/scripts/server/job.js index fd3777fb..ebcee1ea 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -348,8 +348,8 @@ class JobBlackListData { // =========================================================================== function initJobScript() { - logToConsole(LOG_INFO, "[VRR.Job]: Initializing job script ..."); - logToConsole(LOG_INFO, "[VRR.Job]: Job script initialized successfully!"); + logToConsole(LOG_DEBUG, "[VRR.Job]: Initializing job script ..."); + logToConsole(LOG_DEBUG, "[VRR.Job]: Job script initialized successfully!"); return true; } @@ -374,7 +374,7 @@ function loadJobsFromDatabase() { tempJobData.uniforms = loadJobUniformsFromDatabase(tempJobData.databaseId); tempJobData.routes = loadJobRoutesFromDatabase(tempJobData.databaseId); tempJobs.push(tempJobData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job '${tempJobData.name}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job '${tempJobData.name}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -436,7 +436,7 @@ function loadJobRoutesFromDatabase(jobDatabaseId) { let tempJobRouteData = new JobRouteData(dbAssoc); tempJobRouteData.locations = loadJobRouteLocationsFromDatabase(tempJobRouteData.databaseId); tempJobRoutes.push(tempJobRouteData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job route '${tempJobRouteData.name}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job route '${tempJobRouteData.name}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -465,7 +465,7 @@ function loadJobRouteLocationsFromDatabase(jobRouteId) { while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobRouteLocationData = new JobRouteLocationData(dbAssoc); tempJobRouteLocations.push(tempJobRouteLocationData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job route location '${tempJobRouteLocationData.databaseId}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job route location '${tempJobRouteLocationData.databaseId}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -495,7 +495,7 @@ function loadJobEquipmentsFromDatabase(jobDatabaseId) { let tempJobEquipmentData = new JobEquipmentData(dbAssoc); tempJobEquipmentData.items = loadJobEquipmentItemsFromDatabase(tempJobEquipmentData.databaseId); tempJobEquipments.push(tempJobEquipmentData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment '${tempJobEquipmentData.name}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job equipment '${tempJobEquipmentData.name}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -524,7 +524,7 @@ function loadJobLocationsFromDatabase(jobDatabaseId) { while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobLocationData = new JobLocationData(dbAssoc); tempJobLocations.push(tempJobLocationData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job location '${tempJobLocationData.databaseId}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job location '${tempJobLocationData.databaseId}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -553,7 +553,7 @@ function loadJobUniformsFromDatabase(jobDatabaseId) { while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobUniformData = new JobUniformData(dbAssoc); tempJobUniforms.push(tempJobUniformData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job uniform '${tempJobUniformData.databaseId}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job uniform '${tempJobUniformData.databaseId}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -582,7 +582,7 @@ function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) { while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempJobEquipmentItemData = new JobEquipmentItemData(dbAssoc); tempJobEquipmentItems.push(tempJobEquipmentItemData); - logToConsole(LOG_DEBUG, `[VRR.Job]: Job equipment item '${tempJobEquipmentItemData.databaseId}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[VRR.Job]: Job equipment item '${tempJobEquipmentItemData.databaseId}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -633,7 +633,7 @@ function createAllJobPickups() { setElementDimension(getServerData().jobs[i].locations[j].pickup, getServerData().jobs[i].locations[j].dimension); addToWorld(getServerData().jobs[i].locations[j].pickup); - logToConsole(LOG_DEBUG, `[VRR.Job] Job '${getServerData().jobs[i].name}' location pickup ${j} spawned!`); + logToConsole(LOG_VERBOSE, `[VRR.Job] Job '${getServerData().jobs[i].name}' location pickup ${j} spawned!`); } } } diff --git a/scripts/server/npc.js b/scripts/server/npc.js index 2a60dac2..4398ae3e 100644 --- a/scripts/server/npc.js +++ b/scripts/server/npc.js @@ -202,8 +202,8 @@ class NPCTriggerResponseData { // =========================================================================== function initNPCScript() { - logToConsole(LOG_INFO, "[VRR.NPC]: Initializing NPC script ..."); - logToConsole(LOG_INFO, "[VRR.NPC]: NPC script initialized successfully!"); + logToConsole(LOG_DEBUG, "[VRR.NPC]: Initializing NPC script ..."); + logToConsole(LOG_DEBUG, "[VRR.NPC]: NPC script initialized successfully!"); } // =========================================================================== diff --git a/scripts/server/paintball.js b/scripts/server/paintball.js index 20505d3b..176fc8e4 100644 --- a/scripts/server/paintball.js +++ b/scripts/server/paintball.js @@ -49,13 +49,14 @@ let paintBallItemNames = { // =========================================================================== function initPaintBallScript() { - logToConsole(LOG_INFO, "[VRR.PaintBall]: Initializing paintball script ..."); - logToConsole(LOG_INFO, "[VRR.PaintBall]: Paintball script initialized successfully!"); + logToConsole(LOG_DEBUG, "[VRR.PaintBall]: Initializing paintball script ..."); + logToConsole(LOG_DEBUG, "[VRR.PaintBall]: Paintball script initialized successfully!"); } // =========================================================================== function startPaintBall(client) { + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Starting paintball for ${getPlayerDisplayForConsole(client)} ...`); if (isPlayerWorking(client)) { stopWorking(client); } @@ -67,18 +68,22 @@ function startPaintBall(client) { getPlayerData(client).paintBallBusiness = getPlayerBusiness(client); givePlayerPaintBallItems(client); + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Started paintball for ${getPlayerDisplayForConsole(client)} successfully`); } // =========================================================================== function stopPaintBall(client) { + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Stopping paintball for ${getPlayerDisplayForConsole(client)} ...`); deletePaintBallItems(client); restorePlayerTempLockerItems(client); + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Stopped paintball for ${getPlayerDisplayForConsole(client)} successfully`); } // =========================================================================== function givePlayerPaintBallItems(client) { + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Giving ${getPlayerDisplayForConsole(client)} paintball items ...`); for (let i in paintBallItems) { let itemId = createItem(paintBallItems[i], value, VRR_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId); getItemData(itemId).needsSaved = false; @@ -88,39 +93,47 @@ function givePlayerPaintBallItems(client) { getPlayerData(client).paintBallItemCache.push(itemId); updatePlayerHotBar(client); } + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Gave ${getPlayerDisplayForConsole(client)} paintball items successfully`); } // =========================================================================== function deletePaintBallItems(client) { + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} ...`); for (let i in getPlayerData(client).paintBallItemCache) { deleteItem(getPlayerData(client).paintBallItemCache[i]); } cachePlayerHotBarItems(client); updatePlayerHotBar(client); + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} successfully`); } // =========================================================================== function cacheAllPaintBallItemTypes() { + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Cacheing all paintball item types ...`); for (let i in paintBallItemNames[getGame()]) { let itemTypeId = getItemTypeFromParams(paintBallItems[getGame()][i]); if (itemTypeId != -1 && getItemTypeData(itemTypeId) != false) { paintBallItems.push(getItemTypeData(itemTypeId)); } } + + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Cached all paintball item types`); } // =========================================================================== function respawnPlayerForPaintBall(client) { + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Respawning ${getPlayerDisplayForConsole(client)} for paintball ...`); despawnPlayer(client); let businessId = getPlayerData(client).paintBallBusiness; let spawnId = getRandom(0, getBusinessData(businessId).paintBallSpawns.length - 1); spawnPlayer(client, getBusinessData(businessId).paintBallSpawns[spawnId], 0.0, getPlayerSkin(client), getBusinessData(businessId).exitInterior, getBusinessData(businessId).exitPosition, getBusinessData(businessId).exitDimension); + logToConsole(LOG_DEBUG, `[VRR.PaintBall]: Respawned ${getPlayerDisplayForConsole(client)} for paintball successfully`); } // =========================================================================== \ No newline at end of file