Ok, no i've tried to workaround to this problem. I was thinking when i use setfuel on every machine (server and all clients) the aircraft would be filled. so i've splitted up the scripts and fooled around with some publicvariables. But now even in Editor preview the aircraft will not be filled with gas. Here what i've done sofar:
The init script. This is called from the init.sqf therefor should it be runnin on all machines:
_object = _this select 0;
_object setfuelcargo 0;
refuel_params_ready = false;
refuel_params_plane = objnull;
refuel_params_added = 0;
mission_refueling = false;
mission_fuel = 500;
fuel_capacity_su34 = 12100;
fuel_capacity_mi17 = 1140;
fuel_capacity_ka50 = 1600;
fuel_flow_plane = 50;
fuel_flow_land = 0.8;
_nul = [] execVM "refuel_system\do_refuel.sqf";
if (! isServer) exitwith {};
refuel100 = _object addaction ["Refuel Aircraft 100%", "refuel_system\refuel2.sqf", 1, 6];
refuel75 = _object addaction ["Refuel Aircraft 75%", "refuel_system\refuel2.sqf", 0.75, 5];
refuel50 = _object addaction ["Refuel Aircraft 50%", "refuel_system\refuel2.sqf", 0.5, 4];
refuel25 = _object addaction ["Refuel Aircraft 25%", "refuel_system\refuel2.sqf", 0.25, 3];
_object addaction ["Check fuel status", "refuel_system\checkfueldepot.sqf", 0, 2];
As this is runnin on all machines, also the do_refuel.sqf is called on each:
private ["_plane", "_added", "_i"];
for [{_i=0}, {_i<10000}, {_i=_i+1}] do
{
waituntil {(refuel_params_ready)};
_plane = refuel_params_plane;
_added = refuel_params_added;
_plane setfuel _added;
refuel_params_ready = false;
publicvariable "refuel_params_ready";
};
And at last the script which is called by the action and therefor only runnin on the respective client:
private ["_using", "_fuel_diff", "_fuel_flow", "_limit_kg", "_limit", "_object", "_added", "_fuel_value"];
if (mission_refueling) exitwith {};
_object = _this select 0;
_limit = _this select 3;
refuel_params_plane = nearestobject [_object, "AIR"];
_fuel_flow = fuel_flow_plane;
switch (typeof refuel_params_plane) do
{
case "Su34":
{
_fuel_value = fuel_capacity_su34;
};
case "Su34B":
{
_fuel_value = fuel_capacity_su34;
};
case "KA50" :
{
_fuel_value = fuel_capacity_ka50;
};
case "Mi17_MG" :
{
_fuel_value = fuel_capacity_mi17;
};
};
_limit_kg = (_fuel_value / (1 / _limit));
if (mission_fuel <= 0) exitwith {hint "We have no gas for you"};
if (isnull refuel_params_plane) exitwith {hint "No Aircraft in range"};
if ((refuel_params_plane distance _object) >= 25) exitwith {hint "No Aircraft in range"};
if (fuel refuel_params_plane == 1) exitwith {hint format ["%1 is fuel", typeof refuel_params_plane]};
mission_refueling = true;
publicvariable "mission_refueling";
_object removeaction refuel100;
_object removeaction refuel75;
_object removeaction refuel50;
_object removeaction refuel25;
{
_x action ["Getout", refuel_params_plane];
}
foreach units vehicle refuel_params_plane;
while {fuel refuel_params_plane < _limit} do
{
if ((refuel_params_plane distance _object) >= 25) exitwith {hint "Refueling aborted!"};
_fuel_diff = ((_fuel_value / (1 / _limit)) - (_fuel_value * fuel refuel_params_plane));
if (mission_fuel >= _fuel_flow) then
{
if (_fuel_diff < _fuel_flow) then
{
_added = (1 / (_fuel_value / _fuel_diff)) + fuel refuel_params_plane;
_using = _fuel_diff;
}
else
{
_added = (1 / (_fuel_value / fuel_flow)) + fuel refuel_params_plane;
_using = _fuel_flow;
};
}
else
{
_added = (1 / (_fuel_value / mission_fuel)) + fuel refuel_params_plane;
_using = mission_fuel;
};
// refuel_params_plane setfuel _added;
refuel_params_added = _added;
mission_fuel = mission_fuel - _using;
publicvariable "mission_fuel";
publicvariable "refuel_params_plane";
publicvariable "refuel_params_added";
sleep 0.5;
refuel_params_ready = true;
publicvariable "refuel_params_ready";
hint format ["Refueling %1 with %2kg/s\n\nRequested fuel: %3kg\nCurrent fuel: %4kg\n\nRemaining in Depot: %5kg", typeof refuel_params_plane, _fuel_flow, (_fuel_value * _limit), (_fuel_value * fuel refuel_params_plane), mission_fuel];
sleep 1;
if (fuel refuel_params_plane >= _limit) exitwith {hint "Limit reached.\nRefueling terminated"};
if (mission_fuel <= 0) exitwith {hint "Gas tanks are empty"};
};
sleep 2;
mission_refueling = false;
publicvariable "mission_refueling";
refuel100 = _object addaction ["Refuel Aircraft 100%", "refuel_system\refueling.sqf", 1, 6];
refuel75 = _object addaction ["Refuel Aircraft 75%", "refuel_system\refueling.sqf", 0.75, 5];
refuel50 = _object addaction ["Refuel Aircraft 50%", "refuel_system\refueling.sqf", 0.5, 4];
refuel25 = _object addaction ["Refuel Aircraft 25%", "refuel_system\refueling.sqf", 0.25, 3];
if (fuel refuel_params_plane == 1) then
{
hint format ["%1 refueled.", typeof refuel_params_plane];
};
The "refueling..." hint shows me that the gas in the depot is subtracted but the aircrafts fuel stays at 0. If anyone has a solution to this, please share it with me because i'm goin slightly mad.
Myke out
:EDIT:
- solved -
..and again the problem was self made...missing underline.