Debug logging

This commit is contained in:
Vortrex
2022-03-09 02:49:53 -06:00
parent 8d5ca7ed6b
commit cf6970e3e1

View File

@@ -24,19 +24,25 @@ class BusinessData {
// ===========================================================================
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
if(getGame() == VRR_GAME_GTA_IV) {
if(getBusinessData(businessId) != false) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
if(blipModel == -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
getBusinessData(businessId).blipId = -1;
//businesses.splice(getBusinessData(businessId).index, 1);
//setAllBusinessDataIndexes();
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
if(getBusinessData(businessId).blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been modified by the server`);
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 {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server`);
let blipId = natives.addBlipForCoord(entrancePosition);
if(blipId) {
getBusinessData(businessId).blipId = blipId;
@@ -46,8 +52,10 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
if(blipModel != -1) {
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server`);
let blipId = natives.addBlipForCoord(entrancePosition);
if(blipId) {
tempBusinessData.blipId = blipId;
@@ -55,9 +63,9 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
natives.setBlipMarkerLongDistance(blipId, false);
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
}
businesses.push(tempBusinessData);
setAllBusinessDataIndexes();
}
businesses.push(tempBusinessData);
setAllBusinessDataIndexes();
}
}
}