Add entrance fee to business labels

This commit is contained in:
Vortrex
2022-12-11 02:02:34 -06:00
parent 0b564d66e8
commit 833f8872e2
2 changed files with 19 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ class BusinessData {
this.blipId = -1; this.blipId = -1;
this.labelInfoType = 0; this.labelInfoType = 0;
this.locked = false; this.locked = false;
this.entranceFee = 0;
} }
} }
@@ -35,7 +36,7 @@ function initBusinessScript() {
// =========================================================================== // ===========================================================================
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked, hasItems) { function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked, hasItems, entranceFee) {
logToConsole(LOG_DEBUG, `[AGRP.Business] Received business ${businessId} (${name}) from server`); logToConsole(LOG_DEBUG, `[AGRP.Business] Received business ${businessId} (${name}) from server`);
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) { if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
@@ -50,6 +51,7 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
businessData.rentPrice = rentPrice; businessData.rentPrice = rentPrice;
businessData.hasItems = hasItems; businessData.hasItems = hasItems;
businessData.locked = locked; businessData.locked = locked;
businessData.entranceFee = entranceFee;
if (hasInterior && !hasItems) { if (hasInterior && !hasItems) {
businessData.labelInfoType = AGRP_PROPLABEL_INFO_ENTER; businessData.labelInfoType = AGRP_PROPLABEL_INFO_ENTER;

View File

@@ -65,7 +65,7 @@ function initLabelJobHelpFont() {
// =========================================================================== // ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) { function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType, fee) {
if (localPlayer == null) { if (localPlayer == null) {
return false; return false;
} }
@@ -122,6 +122,15 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
screenPosition.y -= propertyLabelPriceOffset; screenPosition.y -= propertyLabelPriceOffset;
} }
text = "";
if (toInteger(fee) > 0) {
text = getLocaleString("PropertyEntranceFeeLabel", getCurrencyString(fee));
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset;
}
if (isBusiness) { if (isBusiness) {
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open")); text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
} else { } else {
@@ -318,7 +327,7 @@ function processLabelRendering() {
} }
if (getDistance(localPlayer.position, business.entrancePosition) <= propertyLabelRenderDistance) { if (getDistance(localPlayer.position, business.entrancePosition) <= propertyLabelRenderDistance) {
renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType); renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType, business.entranceFee);
} }
} }
}); });
@@ -371,9 +380,13 @@ function processLabelRendering() {
labelInfoType = pickups[i].getData("agrp.label.help"); labelInfoType = pickups[i].getData("agrp.label.help");
} }
if (pickups[i].getData("agrp.label.fee") != null) {
fee = pickups[i].getData("agrp.label.fee");
}
switch (pickups[i].getData("agrp.label.type")) { switch (pickups[i].getData("agrp.label.type")) {
case AGRP_LABEL_BUSINESS: { case AGRP_LABEL_BUSINESS: {
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), true, price, rentPrice, labelInfoType); renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), true, price, rentPrice, labelInfoType, fee);
break; break;
} }