Add debug logging
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user