Skip to content

Commit

Permalink
Fixing refuelling (#549)
Browse files Browse the repository at this point in the history
Fix vehicle refuelling
  • Loading branch information
DomT602 authored and Jason2605 committed May 3, 2019
1 parent 56f4447 commit 261754e
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 114 deletions.
4 changes: 2 additions & 2 deletions Altis_Life.Altis/config/Config_SpyGlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ class SpyGlass {
{ "civ_air_2", "OBJECT" }, { "civ_air_1", "OBJECT" }, { "vendor_hospital_3", "OBJECT" }, { "vendor_hospital_2", "OBJECT" }, { "hospital_assis_3", "OBJECT" }, { "hospital_assis_2", "OBJECT" }, { "cop_air_3", "OBJECT" }, { "cop_air_2", "OBJECT" },{ "civ_air_2_3", "OBJECT" }, { "civ_air_2_2", "OBJECT" }, { "atm_hospital_3", "OBJECT" }, { "atm_hospital_2", "OBJECT" }, { "civ_air_1_2", "OBJECT" },
{ "ton_fnc_handleblastingcharge", "CODE" }, { "bis_egspectator_showcamerabuttons", "BOOL" }, { "bis_egspectator_allow3ppcamera", "BOOL" }, { "bis_egspectatorcamera_lights", "ARRAY" }, { "bis_egspectatorcamera_lightson", "BOOL" }, { "bis_egspectator_showcontrolshelper", "BOOL" }, { "bis_egspectator_showlists", "BOOL" }, { "bis_egspectator_viewdistance", "SCALAR" }, { "life_broadcasttimer", "SCALAR" },
{ "bis_egspectator_showheader", "BOOL" }, { "cash", "SCALAR" }, { "life_action_spikestripdeploy", "SCALAR" }, { "rscegspectator_lastticktime", "SCALAR" }, { "bis_pp_burndamage", "ARRAY" }, { "life_safeobj", "OBJECT" }, { "life_dp_point", "OBJECT" }, { "life_dp_start", "OBJECT" }, { "bis_fnc_diagmacrossimpleobject", "CODE" }, { "bis_fnc_groupfromnetid", "CODE" }, { "bis_fnc_tasktype", "CODE" },
{ "bis_fnc_tasksetalwaysvisible", "CODE" }, { "bis_fnc_tasktypeicon", "CODE" }, { "bis_fnc_tasksettype", "CODE" }, { "bis_fnc_objectfromnetid", "CODE" }, { "bis_fnc_sunrisesunsettime", "CODE" }, { "bis_fnc_netid", "CODE" }, { "bis_fnc_getarea", "CODE" }, { "bis_fnc_taskalwaysvisible", "CODE" }, { "life_fuelprices", "SCALAR" }, { "life_markers_vehicles", "ARRAY" }, { "life_markers_players", "ARRAY" },
{ "advanced_log", "STRING" }, { "money_log", "STRING" }, { "life_markers_Vehicles", "ARRAY" }, { "life_markers_Players", "ARRAY" },{ "vehiclefuellist", "ARRAY" }, { "life_vinact_curtarget", "OBJECT" }, { "life_ticket_cop", "OBJECT" }, { "life_ticket_unit", "OBJECT" }, { "life_ticket_val", "SCALAR" }, { "life_ticket_paid", "BOOL" }, { "life_boltcutter_uses", "SCALAR" }, { "life_pinact_container", "OBJECT" },
{ "bis_fnc_tasksetalwaysvisible", "CODE" }, { "bis_fnc_tasktypeicon", "CODE" }, { "bis_fnc_tasksettype", "CODE" }, { "bis_fnc_objectfromnetid", "CODE" }, { "bis_fnc_sunrisesunsettime", "CODE" }, { "bis_fnc_netid", "CODE" }, { "bis_fnc_getarea", "CODE" }, { "bis_fnc_taskalwaysvisible", "CODE" }, { "life_markers_vehicles", "ARRAY" }, { "life_markers_players", "ARRAY" },
{ "advanced_log", "STRING" }, { "money_log", "STRING" }, { "life_markers_Vehicles", "ARRAY" }, { "life_markers_Players", "ARRAY" }, { "life_vinact_curtarget", "OBJECT" }, { "life_ticket_cop", "OBJECT" }, { "life_ticket_unit", "OBJECT" }, { "life_ticket_val", "SCALAR" }, { "life_ticket_paid", "BOOL" }, { "life_boltcutter_uses", "SCALAR" }, { "life_pinact_container", "OBJECT" },
{ "luce_1", "SCRIPT" }, { "life_bail_amount", "SCALAR" }, { "life_canpay_bail", "BOOL" }, { "hc_life", "SCALAR" }, { "life_fnc_requestclientid", "OBJECT" }, { "life_hc_isactive", "BOOL" }, { "ton_fnc_playtime_values", "ARRAY" }, { "ton_fnc_playtime_values_request", "ARRAY" }, { "hc_1", "OBJECT" }, { "hc_life", "BOOL" }, { "rscdisplaympinterrupt_respawntime", "SCALAR" }, { "bis_dynamictext_spawn_8", "SCRIPT" },
{ "life_my_gang", "OBJECT" }, {"am_exit","SCALAR"}, { "life_garage_sp", "ARRAY" }, { "life_garage_sp", "STRING" }, { "0", "ARRAY" }, { "life_oldvestitems", "ARRAY" }, { "life_shop_cam", "OBJECT" }, { "life_oldclothes", "STRING" }, { "life_cmenu_lock", "BOOL" }, { "life_oldhat", "STRING" }, { "life_oldvest", "STRING" }, { "life_oldglasses", "STRING" }, { "life_oldbackpackitems","ARRAY"},
{"life_oldbackpack","STRING"}, { "rscnotification_data", "ARRAY" }, { "life_curwep_h", "STRING" }, { "carshop_lux_1", "OBJECT" }, { "life_olduniformitems", "ARRAY" }, { "bis_fnc_setvehiclemass_fsm", "SCALAR" }, { "life_3dPreview_light", "OBJECT" }, { "life_3dPreview_camera", "OBJECT" }, { "life_3dPreview_object", "OBJECT" },
Expand Down
34 changes: 19 additions & 15 deletions Altis_Life.Altis/core/pmenu/fn_s_onSliderChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
Description:
Called when the slider is changed for any field and updates the view distance for it.
*/
private ["_mode","_value"];
_mode = [_this,0,-1,[0]] call BIS_fnc_param;
_value = [_this,1,-1,[0]] call BIS_fnc_param;
params [
["_mode",-1,[0]],
["_value",-1,[0]]
];
if (_mode isEqualTo -1 || _value isEqualTo -1) exitWith {};
disableSerialization;

switch (_mode) do {
switch _mode do {
case 0:
{
life_settings_viewDistanceFoot = round(_value);
Expand All @@ -38,19 +38,23 @@ switch (_mode) do {
};

case 3: {
_classname = lbData[20302,(lbCurSel 20302)];
_index = lbValue[20302,(lbCurSel 20302)];
if ((lbCurSel 20302) isEqualTo -1) exitWith {hint localize "STR_Select_Vehicle_Pump";};
if (!isNil "_classname" || _classname =="") then {
_car = (vehiclefuelList select _index) select 0;
_vehicleInfo = [_className] call life_fnc_fetchVehInfo;
_fuel = fuel _car;
_fueltank = (_vehicleInfo select 12);
private _index = lbCurSel 20302;
private _classname = lbData[20302,_index];
if (_index isEqualTo -1) exitWith {hint localize "STR_Select_Vehicle_Pump"};

if (!isNil "_classname" || _classname isEqualTo "") then {

private _vehicleFuelList = uiNamespace getVariable ["fuel_list",[]];
(_vehicleFuelList select _index) params ["_car"];
private _vehicleInfo = [_className] call life_fnc_fetchVehInfo;
private _fuel = fuel _car;
private _fuelTank = _vehicleInfo select 12;
if (_car isKindOf "B_Truck_01_box_F" || _car isKindOf "B_Truck_01_transport_F") then {
_fueltank = 450;
};
ctrlSetText[20324,format ["Fuel : %1 liters",round(_value) - (floor(_fuel * _fueltank))]];
ctrlSetText [20323,format ["Total : $%1",round (life_fuelPrices * (round(_value) -(floor(_fuel * _fueltank)))) ]];
_value = (parseNumber(_value toFixed 2));
ctrlSetText [20324,format ["Fuel : %1 liters",_value - (floor(_fuel * _fueltank))]];
ctrlSetText [20323,format ["Total : $%1",round ((uiNamespace getVariable ["fuel_cost",0]) * (_value -(floor(_fuel * _fueltank)))) ]];
} else {
hint localize "STR_Select_Vehicle_Pump";
};
Expand Down
43 changes: 19 additions & 24 deletions Altis_Life.Altis/core/shops/fn_fuelLBChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,35 @@
Author: NiiRoZz
Description:
Change when slide change. That descripotion
Changes when slider is changed.
*/
disableSerialization;
private ["_control","_index","_className","_basePrice","_vehicleInfo","_colorArray","_ctrl"];
_control = _this select 0;
_index = _this select 1;
params [
["_control",controlNull,[controlNull]],
["_index",-1,[0]]
];

//Fetch some information.
_className = _control lbData _index;
_vIndex = _control lbValue _index;
_vehicle = (vehiclefuelList select _vindex) select 0;
_vehicleInfo = [_className] call life_fnc_fetchVehInfo;
private _className = _control lbData _index;
private _vehicleFuelList = uiNamespace getVariable ["fuel_list",[]];
(_vehicleFuelList select _index) params ["_vehicle"];
private _vehicleInfo = [_className] call life_fnc_fetchVehInfo;

_fuel = fuel _vehicle;
_fueltank = (_vehicleInfo select 12);
if (_vehicle isKindOf "B_Truck_01_box_F" || _vehicle isKindOf "B_Truck_01_transport_F") then {_fueltank = 350;};//hemtt
if (_vehicle isKindOf "C_Van_01_box_F") then {_fueltank = 100;};
if (_vehicle isKindOf "I_Truck_02_covered_F" || _vehicle isKindOf "I_Truck_02_transport_F") then {_fueltank = 175;};
private _fuel = fuel _vehicle;
private _fuelTank = _vehicleInfo select 12;
if (_vehicle isKindOf "B_Truck_01_box_F" || _vehicle isKindOf "B_Truck_01_transport_F") then {_fuelTank = 350};//hemtt
if (_vehicle isKindOf "C_Van_01_box_F") then {_fuelTank = 100};
if (_vehicle isKindOf "I_Truck_02_covered_F" || _vehicle isKindOf "I_Truck_02_transport_F") then {_fuelTank = 175};
ctrlShow [20330,true];

(CONTROL(20300,20303)) ctrlSetStructuredText parseText format [
(localize "STR_Shop_Veh_UI_Fuel")+ " %1l<br/>" +
(localize "STR_Fuel_Tank_Vehicle")+ " %2l",
_fueltank,
round(_fueltank * _fuel)
_fuelTank,
round(_fuelTank * _fuel)
];

{
slidersetRange [_x,(floor(_fuel * _fueltank)),_fueltank];
} forEach [20901];

{
sliderSetPosition[_x ,(floor(_fuel * _fueltank))];
} forEach [20901];
sliderSetRange [20901,(floor(_fuel * _fuelTank)),_fuelTank];
sliderSetPosition [20901 ,(floor(_fuel * _fuelTank))];

ctrlSetText [20323,format ["Total : %1$",life_fuelPrices * ((SliderPosition 20901) -(floor(_fuel * _fueltank))) ]];
ctrlSetText [20323,format ["Total : %1$",(uiNamespace getVariable ["fuel_cost",0]) * ((SliderPosition 20901) -(floor(_fuel * _fuelTank))) ]];
true;
55 changes: 25 additions & 30 deletions Altis_Life.Altis/core/shops/fn_fuelStatOpen.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,42 @@
Open dialog Pump.
*/

private ["_shop","_sideCheck","_spawnPoints","_shopFlag","_disableBuy","_fuelCost"];
if (dialog || life_action_inUse || life_is_processing) exitWith {};

disableSerialization;
//Long boring series of checks
if (life_action_inUse) exitWith {};
if (dialog) exitWith {};
if (life_is_processing) exitWith {};
private _fuelStations = nearestObjects [player, ["Land_fs_feed_F", "Land_FuelStation_01_pump_F", "Land_FuelStation_02_pump_F"], 10];
if (_fuelstations isEqualTo []) exitWith {};

private _vehicleList = nearestObjects [player, ["Car","Air"], 10];
if (_vehicleList isEqualTo []) exitWith {hint localize "STR_NOTF_VehicleNear"};

createDialog "Life_FuelStat";
life_action_inUse = true;
_fuelstations = nearestObjects [player, ["Land_fs_feed_F", "Land_FuelStation_01_pump_F", "Land_FuelStation_02_pump_F"], 10];
if (_fuelstations isEqualTo []) exitWith {life_action_inUse = false;};
_vehicleList = nearestObjects [player, ["Car","air"], 10];
if (count _vehicleList < 1) exitWith {hint localize "STR_NOTF_VehicleNear"; life_action_inUse = false;};
if (!createDialog "Life_FuelStat") exitWith {};
_fuelCost = LIFE_SETTINGS(getNumber,"fuel_cost");
[] spawn {waitUntil {!dialog}; life_action_inUse = false;};

private _fuelCost = LIFE_SETTINGS(getNumber,"fuel_cost");
uiNamespace setVariable ["fuel_cost",_fuelCost];
ctrlSetText [20301,"Fuel Station"];
if (isNil "life_fuelPrices") then {
life_fuelPrices = _fuelCost;
};

//Fetch the shop config.
vehicleFuelList =[];
private _vehicleFuelList = [];
{
_fuel = fuel _x;
vehicleFuelList pushBack [_x,_fuel];
private _fuel = fuel _x;
_vehicleFuelList pushBack [_x,_fuel];
} forEach _vehicleList;
uiNamespace setVariable ["fuel_list",_vehicleFuelList];

_control = ((findDisplay 20300) displayCtrl 20302);
lbClear _control; //Flush the list.
private _control = (findDisplay 20300) displayCtrl 20302;
lbClear _control;

ctrlSetText [20322,format [localize "STR_Price_Fuel_Pump",life_fuelPrices]];
ctrlSetText [20323,format ["Total : %1$",life_fuelPrices * 0.1]];
ctrlSetText [20322,format [localize "STR_Price_Fuel_Pump",_fuelCost]];
ctrlSetText [20323,format ["Total : %1$",_fuelCost * 0.1]];

//Loop through
{
_className = typeOf (_x select 0);
_fuelleft = _x select 1;
_x params ["_vehicle","_fuelLeft"];
private _className = typeOf _vehicle;

_vehicleInfo = [_className]call life_fnc_fetchVehInfo;
private _vehicleInfo = [_className] call life_fnc_fetchVehInfo;
_control lbAdd (_vehicleInfo select 3);
_control lbSetPicture [(lbSize _control)-1,(_vehicleInfo select 2)];
_control lbSetData [(lbSize _control)-1,_className];
_control lbSetValue [(lbSize _control)-1,_ForEachIndex];
} forEach vehicleFuelList;
_control lbSetPicture [_forEachIndex,(_vehicleInfo select 2)];
_control lbSetData [_forEachIndex,_className];
} forEach _vehicleFuelList;
69 changes: 27 additions & 42 deletions Altis_Life.Altis/core/vehicle/fn_fuelRefuelCar.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,42 @@
Description:
Adds fuel in car.
*/
disableSerialization;
private ["_control","_index","_className","_basePrice","_vehicleInfo","_colorArray","_ctrl"];
_classname = lbData[20302,(lbCurSel 20302)];
_index = lbValue[20302,(lbCurSel 20302)];
private _index = lbCurSel 20302;
private _classname = lbData[20302,_index];

if (isNil "_classname" || _classname isEqualTo "") exitWith {
hint localize "STR_Select_Vehicle_Pump";
vehiclefuelList = [];
life_action_inUse = false;
closeDialog 0;
};
private _vehicleFuelList = uiNamespace getVariable ["fuel_list",[]];

_car = (vehiclefuelList select _index) select 0;
_vehicleInfo = [_className]call life_fnc_fetchVehInfo;
_fuelNow = fuel _car;
_fueltank = (_vehicleInfo select 12);
if (_car isKindOf "B_Truck_01_box_F" || _car isKindOf "B_Truck_01_transport_F") then {_fueltank = 350;};//hemtt
if (_car isKindOf "C_Van_01_box_F") then {_fueltank = 100;};
if (_car isKindOf "I_Truck_02_covered_F" || _car isKindOf "I_Truck_02_transport_F") then {_fueltank = 175;};
_fueltoput= ((SliderPosition 20901)-(floor(_fuelnow * _fueltank)));
_setfuell = _fuelnow + (_fueltoput/_fueltank);
_timer = ((_fueltoput * .25)/100);
(_vehicleFuelList select _index) params ["_car"];
private _vehicleInfo = [_className] call life_fnc_fetchVehInfo;
private _fuelNow = fuel _car;
private _fueltank = _vehicleInfo select 12;
if (_car isKindOf "B_Truck_01_box_F" || _car isKindOf "B_Truck_01_transport_F") then {_fueltank = 350};//hemtt
if (_car isKindOf "C_Van_01_box_F") then {_fueltank = 100};
if (_car isKindOf "I_Truck_02_covered_F" || _car isKindOf "I_Truck_02_transport_F") then {_fueltank = 175};
private _fueltoput = ((parseNumber((sliderPosition 20901) toFixed 2))-(floor(_fuelnow * _fueltank)));
private _setfuel = _fuelnow + (_fueltoput/_fueltank);
private _timer = ((_fueltoput * .25)/100);
if (_car distance player > 10 && !(isNull objectParent player)) exitWith {
hint localize "STR_Distance_Vehicle_Pump";
vehiclefuelList = [];
life_action_inUse = false;
closeDialog 0;
};

if ((BANK - (_fueltoput * life_fuelPrices))> 0)then {
private _fuelCost = uiNamespace getVariable ["fuel_cost",0];
if ((BANK - (_fueltoput * _fuelCost)) > 0) then {
life_is_processing = true;
//Setup our progress bar.
disableSerialization;
"progressBar" cutRsc ["life_progress","PLAIN"];
_ui = uiNameSpace getVariable "life_progress";
_progress = _ui displayCtrl 38201;
_pgText = _ui displayCtrl 38202;
private _ui = uiNameSpace getVariable "life_progress";
private _progress = _ui displayCtrl 38201;
private _pgText = _ui displayCtrl 38202;
_pgText ctrlSetText format ["%2 (1%1)...","%","Refuel:"];
_progress progressSetPosition 0.01;
_cP = 0.01;
_tp =0;
_totalcost = _fueltoput * life_fuelPrices;
private _cP = 0.01;
for "_i" from 0 to 1 step 0 do {
uiSleep _timer;
_cP = _cP + 0.01;
Expand All @@ -56,30 +50,21 @@ if ((BANK - (_fueltoput * life_fuelPrices))> 0)then {
if (_cP >= 1) exitWith {};
if (player distance _car > 10) exitWith {};
if !(isNull objectParent player) exitWith {};
if !((BANK - round(0.01 * _totalcost))> 0) exitWith {};
BANK = BANK - round((0.01 * _totalcost));
_tp = _tp +1;
if (_tp == 9) then {
_tp = 0;
[_car,_cp * _setfuell] remoteExecCall ["life_fnc_setFuel",_car];
if (((_cP * 100) mod 10) isEqualTo 0) then {
[_car,_cP * _setfuel] remoteExecCall ["life_fnc_setFuel",_car];
};
};
private _toPay = floor((_fueltoput * _fuelCost) * _cP);
BANK = BANK - _toPay; //pay the received fuel
[_car,_cP * _setfuel] remoteExecCall ["life_fnc_setFuel",_car]; //update the fuel
"progressBar" cutText ["","PLAIN"];
if (_car distance player > 10 || !(isNull objectParent player)) then {
hint localize "STR_Distance_Vehicle_Pump";
vehiclefuelList = [];
life_is_processing = false;
life_action_inUse = false;
[0] call SOCK_fnc_updatePartial;
closeDialog 0;
} else {
life_is_processing = false;
[0] call SOCK_fnc_updatePartial;
};
[0] call SOCK_fnc_updatePartial;
life_is_processing = false;
} else {
hint localize "STR_NOTF_NotEnoughMoney";
};

vehiclefuelList = [];
life_action_inUse = false;
closeDialog 0;
closeDialog 0;
1 change: 1 addition & 0 deletions Altis_Life.Altis/dialog/FuelStat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Life_FuelStat {
movingEnabled = 0;
enableSimulation = 1;
onLoad = "ctrlShow [2330,false];";
onUnload = "life_action_inUse = false;";

class controlsBackground {
class Life_RscTitleBackground: Life_RscText {
Expand Down
2 changes: 1 addition & 1 deletion life_server/Functions/Systems/fn_clientDisconnect.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (life_save_civilian_position && {side _unit isEqualTo civilian}) then {
private _position = getPosATL _unit;
if ((getMarkerPos "respawn_civilian" distance _position) > 300) then {
private _alive = alive _unit;
if (life_HC_isActive) then {[_uid,_side,_alive,4,_position] remoteExec ["HC_fnc_updatePartial",HC_Life]} else {[_uid,_side,_alive,4,_position] spawn DB_fnc_updatePartial};
if (life_HC_isActive) then {[_uid,civilian,_alive,4,_position] remoteExec ["HC_fnc_updatePartial",HC_Life]} else {[_uid,civilian,_alive,4,_position] spawn DB_fnc_updatePartial};
};
};
};
Expand Down

0 comments on commit 261754e

Please sign in to comment.