From 9c16ceeb3a954a864ce02013e580a66feb43836c Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:49:00 -0600 Subject: [PATCH] Fix job label rendering --- scripts/client/label.js | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/scripts/client/label.js b/scripts/client/label.js index 0a88ecb9..5c3c35c8 100644 --- a/scripts/client/label.js +++ b/scripts/client/label.js @@ -230,17 +230,12 @@ function renderPropertyExitLabel(position) { } } - let tempPosition = position; - tempPosition.z = tempPosition.z + propertyLabelHeight; + position = getPosAbovePos(position, propertyLabelHeight); let screenPosition = new Vec3(0.0, 0.0, 0.0); if (getGame() == V_GAME_GTA_IV) { - screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); + screenPosition = natives.getViewportPositionOfCoord(position, natives.getGameViewportId()); } else { - screenPosition = getScreenFromWorldPosition(tempPosition); - } - - if (screenPosition.x < 0 || screenPosition.x > game.width) { - return false; + screenPosition = getScreenFromWorldPosition(position); } let text = "EXIT"; @@ -275,15 +270,16 @@ function renderJobLabel(name, position, jobType) { } } - let tempPosition = position; - tempPosition.z = tempPosition.z + propertyLabelHeight; + position = getPosAbovePos(position, propertyLabelHeight); let screenPosition = new Vec3(0.0, 0.0, 0.0); if (getGame() == V_GAME_GTA_IV) { - screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId()); + screenPosition = natives.getViewportPositionOfCoord(position, natives.getGameViewportId()); } else { - screenPosition = getScreenFromWorldPosition(tempPosition); + screenPosition = getScreenFromWorldPosition(position); } + logToConsole(LOG_VERBOSE, `[V.RP.Label] World [${position.x}, ${position.y}, ${position.z}] to screen [${screenPosition.x}, ${screenPosition.y}, ${screenPosition.z}]`); + if (screenPosition.x < 0 || screenPosition.x > game.width) { return false; } @@ -325,9 +321,7 @@ function processLabelRendering() { natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255); } - if (getDistance(localPlayer.position, business.entrancePosition) <= propertyLabelRenderDistance) { - renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType, business.entranceFee); - } + renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType, business.entranceFee); } }); @@ -337,9 +331,7 @@ function processLabelRendering() { natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255); } - if (getDistance(localPlayer.position, house.entrancePosition) <= propertyLabelRenderDistance) { - renderPropertyEntranceLabel(house.description, house.entrancePosition, house.locked, true, house.buyPrice, house.rentPrice, house.labelInfoType); - } + renderPropertyEntranceLabel(house.description, house.entrancePosition, house.locked, true, house.buyPrice, house.rentPrice, house.labelInfoType); } }); @@ -349,15 +341,13 @@ function processLabelRendering() { natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255); } - if (getDistance(localPlayer.position, job.position) <= propertyPickupRenderDistance) { - renderJobLabel(job.name, job.position, job.jobType); - } + renderJobLabel(job.name, job.position, job.jobId); } }); } } - if (areWorldLabelsSupported()) { + if (arePickupsSupported() && areWorldLabelsSupported()) { if (localPlayer != null) { let pickups = getElementsByType(ELEMENT_PICKUP); for (let i in pickups) {