From 2e75230d387c01b4e1ace4b079b07109744ce011 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sat, 29 Oct 2022 10:08:32 -0500 Subject: [PATCH] Shorten floats in near veh + don't take money for admin cmds --- scripts/server/vehicle.js | 43 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index ebe14652..3699a92b 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -428,11 +428,11 @@ function getNearbyVehiclesCommand(command, params, client) { } let vehiclesList = nearbyVehicles.map(function (x) { - return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {mediumGrey}(${toFloat(getDistance(getPlayerPosition(client), getVehiclePosition(x)), 2)} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections", getCardinalDirectionName(getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))))}`; + return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {mediumGrey}(${toFloat(getDistance(getPlayerPosition(client), getVehiclePosition(x))).toFixed(2)} ${toLowerCase(getLocaleString(client, "Meters"))} ${toLowerCase(getGroupedLocaleString(client, "CardinalDirections", getCardinalDirectionName(getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x)))))})`; }); let chunkedList = splitArrayIntoChunks(vehiclesList, 4); - messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList", `${distance} ${getLocaleString(client, "Meters")} `))); + messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList", `${distance} ${toLowerCase(getLocaleString(client, "Meters"))}`))); for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } @@ -609,8 +609,8 @@ function vehicleAdminColourCommand(command, params, client) { let colour1 = toInteger(getParam(params, " ", 1)) || 0; let colour2 = toInteger(getParam(params, " ", 2)) || 0; - takePlayerCash(client, getGlobalConfig().resprayVehicleCost); - updatePlayerCash(client); + //takePlayerCash(client, getGlobalConfig().resprayVehicleCost); + //updatePlayerCash(client); vehicle.colour1 = colour1; vehicle.colour2 = colour2; getVehicleData(vehicle).colour1 = colour1; @@ -618,7 +618,7 @@ function vehicleAdminColourCommand(command, params, client) { getVehicleData(vehicle).needsSaved = true; - meActionToNearbyPlayers(client, `resprays the ${getVehicleName(vehicle)}'s colours`); + //meActionToNearbyPlayers(client, `resprays the ${getVehicleName(vehicle)}'s colours`); } // =========================================================================== @@ -639,10 +639,10 @@ function vehicleAdminRepairCommand(command, params, client) { } logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} repaired their ${getVehicleName(vehicle)} vehicle`); - takePlayerCash(client, getGlobalConfig().repairVehicleCost); + //takePlayerCash(client, getGlobalConfig().repairVehicleCost); repairVehicle(vehicle); getVehicleData(vehicle).needsSaved = true; - meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicle)}`); + //meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicle)}`); } // =========================================================================== @@ -660,10 +660,10 @@ function vehicleAdminLiveryCommand(command, params, client) { return false; } - if (getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) { - messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need ${getCurrencyString(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`); - return false; - } + //if (getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) { + // messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need ${getCurrencyString(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`); + // return false; + //} let livery = toInteger(params) || 3; @@ -675,7 +675,7 @@ function vehicleAdminLiveryCommand(command, params, client) { setEntityData(vehicle, "agrp.livery", livery, true); forcePlayerToSyncElementProperties(null, vehicle); - meActionToNearbyPlayers(client, `sets the ${getVehicleName(vehicle)}'s livery/paintjob'`); + //meActionToNearbyPlayers(client, `sets the ${getVehicleName(vehicle)}'s livery/paintjob'`); } // =========================================================================== @@ -698,6 +698,11 @@ function buyVehicleCommand(command, params, client) { return false; } + if (canPlayerManageVehicle(client, vehicle)) { + messagePlayerError(client, getLocaleString(client, "AlreadyOwnVehicle")); + return false; + } + if (getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) { messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney")); return false; @@ -845,7 +850,7 @@ function doesPlayerHaveVehicleKeys(client, vehicle) { // =========================================================================== -function doesClientOwnVehicle(client, vehicle) { +function canPlayerManageVehicle(client, vehicle) { let vehicleData = getVehicleData(vehicle); if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { @@ -866,6 +871,12 @@ function doesClientOwnVehicle(client, vehicle) { } } + if (vehicleData.ownerType == AGRP_VEHOWNER_BIZ) { + if (canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(vehicleData.ownerId))) { + return true; + } + } + return false; } @@ -1079,9 +1090,10 @@ function setVehicleRentPriceCommand(command, params, client) { return false; } - if (!doesClientOwnVehicle(client, vehicle)) { + if (!canPlayerManageVehicle(client, vehicle)) { if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { messagePlayerError(client, "You can't set the rent price for this vehicle!"); + return false; } } @@ -1108,9 +1120,10 @@ function setVehicleBuyPriceCommand(command, params, client) { return false; } - if (!doesClientOwnVehicle(client, vehicle)) { + if (!canPlayerManageVehicle(client, vehicle)) { if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { messagePlayerError(client, "You can't set the buy price for this vehicle!"); + return false; } }