Fix client house/biz stuff
This commit is contained in:
@@ -17,6 +17,8 @@ class BusinessData {
|
|||||||
this.blipModel = blipModel;
|
this.blipModel = blipModel;
|
||||||
this.pickupModel = pickupModel;
|
this.pickupModel = pickupModel;
|
||||||
this.hasInterior = hasInterior;
|
this.hasInterior = hasInterior;
|
||||||
|
this.rentPrice = 0;
|
||||||
|
this.buyPrice = 0;
|
||||||
this.hasItems = hasItems;
|
this.hasItems = hasItems;
|
||||||
this.blipId = -1;
|
this.blipId = -1;
|
||||||
this.labelInfoType = 0;
|
this.labelInfoType = 0;
|
||||||
@@ -25,10 +27,10 @@ class BusinessData {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, hasItems) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Received business ${businessId} (${name}) from server`);
|
||||||
|
|
||||||
if (!areServerElementsSupported()) {
|
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||||
if (getBusinessData(businessId) != false) {
|
if (getBusinessData(businessId) != false) {
|
||||||
let businessData = getBusinessData(businessId);
|
let businessData = getBusinessData(businessId);
|
||||||
businessData.name = name;
|
businessData.name = name;
|
||||||
@@ -36,12 +38,24 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
|||||||
businessData.blipModel = blipModel;
|
businessData.blipModel = blipModel;
|
||||||
businessData.pickupModel = pickupModel;
|
businessData.pickupModel = pickupModel;
|
||||||
businessData.hasInterior = hasInterior;
|
businessData.hasInterior = hasInterior;
|
||||||
|
businessData.buyPrice = buyPrice;
|
||||||
|
businessData.rentPrice = rentPrice;
|
||||||
businessData.hasItems = hasItems;
|
businessData.hasItems = hasItems;
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
|
if (hasInterior && !hasItems) {
|
||||||
|
businessData.labelInfoType = AGRP_PROPLABEL_INFO_ENTER;
|
||||||
|
} else if (!hasInterior && hasItems) {
|
||||||
|
businessData.labelInfoType = AGRP_PROPLABEL_INFO_BUY;
|
||||||
|
} else {
|
||||||
|
if (businessData.buyPrice > 0) {
|
||||||
|
businessData.labelInfoType = AGRP_PROPLABEL_INFO_BUYBIZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId} already exists. Checking blip ...`);
|
||||||
if (blipModel == -1) {
|
if (blipModel == -1) {
|
||||||
if (businessData.blipId != -1) {
|
if (businessData.blipId != -1) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been removed by the server`);
|
||||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||||
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
||||||
} else {
|
} else {
|
||||||
@@ -51,11 +65,11 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
|||||||
//businesses.splice(businessData.index, 1);
|
//businesses.splice(businessData.index, 1);
|
||||||
//setAllBusinessDataIndexes();
|
//setAllBusinessDataIndexes();
|
||||||
} else {
|
} else {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip is unchanged`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (businessData.blipId != -1) {
|
if (businessData.blipId != -1) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been changed by the server`);
|
||||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||||
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
|
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
|
||||||
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
|
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
|
||||||
@@ -68,20 +82,20 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
|
|||||||
if (blipId != -1) {
|
if (blipId != -1) {
|
||||||
tempBusinessData.blipId = blipId;
|
tempBusinessData.blipId = blipId;
|
||||||
}
|
}
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId} doesn't exist. Adding ...`);
|
||||||
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
||||||
if (blipModel != -1) {
|
if (blipModel != -1) {
|
||||||
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
|
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
|
||||||
if (blipId != -1) {
|
if (blipId != -1) {
|
||||||
tempBusinessData.blipId = blipId;
|
tempBusinessData.blipId = blipId;
|
||||||
}
|
}
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||||
} else {
|
} else {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} has no blip.`);
|
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId} has no blip.`);
|
||||||
}
|
}
|
||||||
getServerData().businesses.push(tempBusinessData);
|
getServerData().businesses.push(tempBusinessData);
|
||||||
setAllBusinessDataIndexes();
|
setAllBusinessDataIndexes();
|
||||||
|
|||||||
@@ -17,16 +17,18 @@ class HouseData {
|
|||||||
this.blipModel = blipModel;
|
this.blipModel = blipModel;
|
||||||
this.pickupModel = pickupModel;
|
this.pickupModel = pickupModel;
|
||||||
this.hasInterior = hasInterior;
|
this.hasInterior = hasInterior;
|
||||||
|
this.rentPrice = 0;
|
||||||
|
this.buyPrice = 0;
|
||||||
this.blipId = -1;
|
this.blipId = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior) {
|
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] Received house ${houseId} (${name}) from server`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] Received house ${houseId} (${name}) from server`);
|
||||||
|
|
||||||
if (!areServerElementsSupported()) {
|
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||||
if (getHouseData(houseId) != false) {
|
if (getHouseData(houseId) != false) {
|
||||||
let houseData = getHouseData(houseId);
|
let houseData = getHouseData(houseId);
|
||||||
houseData.description = description;
|
houseData.description = description;
|
||||||
@@ -34,11 +36,23 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
|||||||
houseData.blipModel = blipModel;
|
houseData.blipModel = blipModel;
|
||||||
houseData.pickupModel = pickupModel;
|
houseData.pickupModel = pickupModel;
|
||||||
houseData.hasInterior = hasInterior;
|
houseData.hasInterior = hasInterior;
|
||||||
|
houseData.buyPrice = buyPrice;
|
||||||
|
houseData.rentPrice = rentPrice;
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} already exists. Checking blip ...`);
|
if (houseData.buyPrice > 0) {
|
||||||
|
houseData.labelInfoType = AGRP_PROPLABEL_INFO_BUYHOUSE;
|
||||||
|
} else {
|
||||||
|
if (houseData.rentPrice > 0) {
|
||||||
|
houseData.labelInfoType = AGRP_PROPLABEL_INFO_RENTHOUSE;
|
||||||
|
} else {
|
||||||
|
houseData.labelInfoType = AGRP_PROPLABEL_INFO_ENTER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId} already exists. Checking blip ...`);
|
||||||
if (blipModel == -1) {
|
if (blipModel == -1) {
|
||||||
if (houseData.blipId != -1) {
|
if (houseData.blipId != -1) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been removed by the server`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been removed by the server`);
|
||||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||||
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
|
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
|
||||||
} else {
|
} else {
|
||||||
@@ -46,11 +60,11 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
|||||||
}
|
}
|
||||||
houseData.blipId = -1;
|
houseData.blipId = -1;
|
||||||
} else {
|
} else {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip is unchanged`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip is unchanged`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (houseData.blipId != -1) {
|
if (houseData.blipId != -1) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been changed by the server`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been changed by the server`);
|
||||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||||
natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition);
|
natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition);
|
||||||
natives.changeBlipSprite(houseData.blipId, houseData.blipModel);
|
natives.changeBlipSprite(houseData.blipId, houseData.blipModel);
|
||||||
@@ -63,20 +77,20 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
|
|||||||
if (blipId != -1) {
|
if (blipId != -1) {
|
||||||
houseData.blipId = blipId;
|
houseData.blipId = blipId;
|
||||||
}
|
}
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} doesn't exist. Adding ...`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId} doesn't exist. Adding ...`);
|
||||||
let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior);
|
let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior);
|
||||||
if (blipModel != -1) {
|
if (blipModel != -1) {
|
||||||
let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House");
|
let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House");
|
||||||
if (blipId != -1) {
|
if (blipId != -1) {
|
||||||
tempHouseData.blipId = blipId;
|
tempHouseData.blipId = blipId;
|
||||||
}
|
}
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
|
||||||
} else {
|
} else {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} has no blip.`);
|
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId} has no blip.`);
|
||||||
}
|
}
|
||||||
getServerData().houses.push(tempHouseData);
|
getServerData().houses.push(tempHouseData);
|
||||||
setAllHouseDataIndexes();
|
setAllHouseDataIndexes();
|
||||||
|
|||||||
Reference in New Issue
Block a user