From 833f8872e2797e6cadb76fc080f0a516b4963928 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 11 Dec 2022 02:02:34 -0600 Subject: [PATCH] Add entrance fee to business labels --- scripts/client/business.js | 4 +++- scripts/client/label.js | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/client/business.js b/scripts/client/business.js index f151cc6f..7d256938 100644 --- a/scripts/client/business.js +++ b/scripts/client/business.js @@ -23,6 +23,7 @@ class BusinessData { this.blipId = -1; this.labelInfoType = 0; 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`); 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.hasItems = hasItems; businessData.locked = locked; + businessData.entranceFee = entranceFee; if (hasInterior && !hasItems) { businessData.labelInfoType = AGRP_PROPLABEL_INFO_ENTER; diff --git a/scripts/client/label.js b/scripts/client/label.js index 8721c13c..34efb3ca 100644 --- a/scripts/client/label.js +++ b/scripts/client/label.js @@ -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) { return false; } @@ -122,6 +122,15 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, 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) { text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open")); } else { @@ -318,7 +327,7 @@ function processLabelRendering() { } 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"); } + if (pickups[i].getData("agrp.label.fee") != null) { + fee = pickups[i].getData("agrp.label.fee"); + } + switch (pickups[i].getData("agrp.label.type")) { 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; }