I have refuel script in my server and it works perfectly. BUT I wan't option "Refuel" when you scroll to be REMOVED unless you are at gas station. I don't know how to do it. Please help.
Here's my files:
init.sqf
kh_actions.sqf
kh_vehicle_refuel.sqf
Here's my files:
init.sqf
Code:
// Extra actions for Taviana:
if (!isDedicated) then {
[] execVM "kh_actions.sqf";
};
kh_actions.sqf
Code:
private ["_vehicle", "_vehicle_refuel_id"];
_vehicle = objNull;
diag_log "Running ""kh_actions"".";
while {true} do
{
if (!isNull player) then
{
private "_currentVehicle";
_currentVehicle = vehicle player;
if (_vehicle != _currentVehicle) then
{
if (!isNull _vehicle) then
{
_vehicle removeAction _vehicle_refuel_id;
_vehicle = objNull;
};
if (_currentVehicle != player) then
{
_vehicle = _currentVehicle;
_vehicle_refuel_id = _vehicle addAction ["Refuel", "kh_vehicle_refuel.sqf", [], -1, false, false, "",
"vehicle _this == _target && local _target"];
};
};
};
sleep 2;
}
kh_vehicle_refuel.sqf
Code:
private ["_target", "_caller", "_id", "_isNearFeed"];
_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;
if (isNil "ib_refueling_in_progress") then { ib_refueling_in_progress = false; };
if (!ib_refueling_in_progress) then
{
_isNearFeed = count ((position _caller) nearObjects ["Land_A_FuelStation_Feed", 10]) > 0;
if (!_isNearFeed) then
{
titleText ["You must be near a fuel station pump.", "PLAIN DOWN", 3];
titleFadeOut 3;
}
else
{
ib_refueling_in_progress = true;
titleText ["Refueling", "PLAIN", 3];
while {(vehicle _caller == _target) and (local _target)} do
{
private ["_velocity", "_fuel"];
_velocity = velocity _target;
_fuel = fuel _target;
if ((_velocity select 0 > 1) or (_velocity select 1 > 1) or (_velocity select 2 > 1)) exitWith { };
if (_fuel >= 1.0) exitWith { };
sleep 0.5;
_fuel = _fuel + 0.005;
if (_fuel >= 1.0) then { _fuel = 1.0; };
_target setFuel _fuel;
};
titleFadeOut 1;
ib_refueling_in_progress = false;
};
};