Skip to content

Commit

Permalink
Update fn_vehiclePrice to not fail on absent vehicles. (#3228)
Browse files Browse the repository at this point in the history
* Update fn_vehiclePrice.sqf

* Update fn_vehiclePrice.sqf

* Update fn_vehiclePrice.sqf

* round to 5
  • Loading branch information
ante185 authored Apr 28, 2024
1 parent 1370484 commit 0811130
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions A3A/addons/core/functions/REINF/fn_vehiclePrice.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@ FIX_LINE_NUMBERS()

params ["_typeX"];

private _costs = server getVariable _typeX;
private _costs = 0;

if (isNil "_typeX") then
{
Error_1("Vehicle does not exist.");
_costs = 0;
}
else
{
_costs = server getVariable _typeX;
};

if (isNil "_costs") then
{
Error_1("Invalid vehicle price :%1.", _typeX);
{
Error_1("Invalid vehicle price :%1.", _typeX);
_costs = 0;
}
}
else
{
if (count seaports > 3) then
{
private _numFriendlySeaports = ({sidesX getVariable [_x,sideUnknown] == teamPlayer} count seaports) min 6;
_costs = round (_costs - (_costs * 0.05 * _numFriendlySeaports));
}
else
{
if (count seaports > 3) then {
private _numFriendlySeaports = ({sidesX getVariable [_x,sideUnknown] == teamPlayer} count seaports) min 6;
_costs = round (_costs - (_costs * 0.05 * _numFriendlySeaports));
} else {
_discount = switch (true) do {
case (tierWar in [1,2]): { 0 };
case (tierWar in [3,4]): { 0 };
case (tierWar in [5,6]): { 1 };
case (tierWar in [7,8]): { 2 };
case (tierWar in [9,10]): { 3 };
default { 0 };
};
_costs = round (_costs - (_costs * 0.1 * _discount));
};
_discount = 0 max ((tierWar - 4) * 0.5); //4 is the last war tier before discounts, the 0.5 makes the discount go from 0-3 instead of 0-6.
_costs = 5 * round ((_costs - (_costs * 0.1 * _discount))/5); //Applies the discount, rounds to the nearest 5€
};
};

_costs

0 comments on commit 0811130

Please sign in to comment.