Fix IV businesses
This commit is contained in:
@@ -8,8 +8,9 @@
|
||||
// ===========================================================================
|
||||
|
||||
class BusinessData {
|
||||
constructor(index, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
||||
this.index = index;
|
||||
constructor(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
||||
this.index = -1;
|
||||
this.businessId = businessId;
|
||||
this.name = name;
|
||||
this.entrancePosition = entrancePosition;
|
||||
this.blipModel = blipModel;
|
||||
@@ -28,6 +29,7 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
||||
if(blipModel == -1) {
|
||||
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
||||
businesses.splice(getBusinessData(businessId).index, 1);
|
||||
setAllBusinessDataIndexes();
|
||||
} else {
|
||||
natives.setBlipCoordinates(getBusinessData(businessId).blipId, getBusinessData(businessId).entrancePosition);
|
||||
natives.changeBlipSprite(getBusinessData(businessId).blipId, getBusinessData(businessId).blipModel);
|
||||
@@ -35,18 +37,38 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
||||
}
|
||||
} else {
|
||||
if(blipModel != -1) {
|
||||
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
||||
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);
|
||||
}
|
||||
businesses.push(tempBusinessData);
|
||||
setAllBusinessDataIndexes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @param {number} businessId - The ID of the business (initially provided by server)
|
||||
* @return {BusinessData} The business's data (class instance)
|
||||
*/
|
||||
function getBusinessData(businessId) {
|
||||
let tempBusinessData = businesses.find((b) => b.businessId == businessId);
|
||||
return (typeof tempBusinessData != "undefined") ? tempBusinessData : false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setAllBusinessDataIndexes() {
|
||||
for(let i in businesses) {
|
||||
businesses[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -69,8 +69,8 @@ let forceWantedLevel = 0;
|
||||
// Pre-cache all allowed skins
|
||||
let allowedSkins = getAllowedSkins(getGame());
|
||||
|
||||
let businesses = {};
|
||||
let houses = {};
|
||||
let jobs = {};
|
||||
let businesses = [];
|
||||
let houses = [];
|
||||
let jobs = [];
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user