Fix IV businesses
This commit is contained in:
@@ -8,8 +8,9 @@
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
class BusinessData {
|
class BusinessData {
|
||||||
constructor(index, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
constructor(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
||||||
this.index = index;
|
this.index = -1;
|
||||||
|
this.businessId = businessId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.entrancePosition = entrancePosition;
|
this.entrancePosition = entrancePosition;
|
||||||
this.blipModel = blipModel;
|
this.blipModel = blipModel;
|
||||||
@@ -28,6 +29,7 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
|||||||
if(blipModel == -1) {
|
if(blipModel == -1) {
|
||||||
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
||||||
businesses.splice(getBusinessData(businessId).index, 1);
|
businesses.splice(getBusinessData(businessId).index, 1);
|
||||||
|
setAllBusinessDataIndexes();
|
||||||
} else {
|
} else {
|
||||||
natives.setBlipCoordinates(getBusinessData(businessId).blipId, getBusinessData(businessId).entrancePosition);
|
natives.setBlipCoordinates(getBusinessData(businessId).blipId, getBusinessData(businessId).entrancePosition);
|
||||||
natives.changeBlipSprite(getBusinessData(businessId).blipId, getBusinessData(businessId).blipModel);
|
natives.changeBlipSprite(getBusinessData(businessId).blipId, getBusinessData(businessId).blipModel);
|
||||||
@@ -35,18 +37,38 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(blipModel != -1) {
|
if(blipModel != -1) {
|
||||||
|
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
||||||
let blipId = natives.addBlipForCoord(entrancePosition);
|
let blipId = natives.addBlipForCoord(entrancePosition);
|
||||||
if(blipId) {
|
if(blipId) {
|
||||||
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
|
||||||
tempBusinessData.blipId = blipId;
|
tempBusinessData.blipId = blipId;
|
||||||
natives.changeBlipSprite(blipId, blipModel);
|
natives.changeBlipSprite(blipId, blipModel);
|
||||||
natives.setBlipMarkerLongDistance(blipId, true);
|
natives.setBlipMarkerLongDistance(blipId, true);
|
||||||
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
|
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
|
// Pre-cache all allowed skins
|
||||||
let allowedSkins = getAllowedSkins(getGame());
|
let allowedSkins = getAllowedSkins(getGame());
|
||||||
|
|
||||||
let businesses = {};
|
let businesses = [];
|
||||||
let houses = {};
|
let houses = [];
|
||||||
let jobs = {};
|
let jobs = [];
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user