DayZ Chenarus Auto Refuel! All stations!

Yeah i cant even test out the scripts because of the new battleeye filters. it hates me!!

if anyone got a fix for those it would be awesome. =)
 
this seems to work for me with the default filters right now. I think its because the default ones has everything on 1. ha.
but seems to be working fine with 1.7.7
 
As I've said before, this is not my code, I take no credit in its creation, only to my modifications so that it wasn't automatic refuel.
 
I modified the code of the script left only refuel in Gas Stations equal to what was posted by Seven and Muddr.(Thanks Seven, for correcting me.)

here is:

kh_actions.sqf
PHP:
    private ["_vehicle", "_vehicle_refuel_id"];
    //Awesomely Edited by Seven, Then modified by Muddr, Then modified by Davison
    _vehicle = objNull;
    diag_log "Running ""kh_actions"".";
 
    _distance = 15; // Distance from object to display Refuel Message
    _amount= 0.02; // Amount of fuel to add per loop. Default was 0.005
 
    while {true} do
    {
        if (!isNull player) then {
            private ["_currentVehicle", "_isNearFeed", "_countFuel"];
                    _currentVehicle = vehicle player;
                    _countFuel = (count ((position _currentVehicle) nearObjects ["Land_A_FuelStation_Feed", _distance]));
                    _countFuel = _countFuel + (count ((position _currentVehicle) nearObjects ["Land_A_FuelStation_Feed", _distance]));
                    _isNearFeed = _countFuel > 0;
 
            if (_vehicle != _currentVehicle) then {
                if (!isNull _vehicle) then {
                    _vehicle removeAction _vehicle_refuel_id;
                    _vehicle = objNull;
                };
 
                if (_currentVehicle != player && _isNearFeed && !(_currentVehicle isKindof "Bicycle")) then {
                    _vehicle = _currentVehicle;
 
                    _vehicle_refuel_id = _vehicle addAction ["Refuel", "Scripts\kh_vehicle_refuel.sqf", [_amount], -1, false, true, "", "vehicle _this == _target && local _target"];
                };
            };
 
            if (!_isNearFeed) then {
                _vehicle removeAction _vehicle_refuel_id;
                _vehicle = objNull;
            };
        };
        sleep 2;
    }


kh_vehicle_refuel.sqf

PHP:
    private ["_target", "_caller", "_id","_object"];
 
    _object = _this select 0;
    _target = _this select 0;
    _caller = _this select 1;
    _id = _this select 2;
    _args = _this select 3;
    _amount = _args select 0;
    _object engineOn false;
 
    if (isNil "ib_refueling_in_progress") then { ib_refueling_in_progress = false; };
 
    if (!ib_refueling_in_progress) then {
 
            ib_refueling_in_progress = true;
 
            titleText ["Refueling", "PLAIN DOWN", 3];
 
            while {(vehicle _caller == _target) and (local _target)} do {
                    private ["_velocity", "_cfcust"];
 
                    _velocity = velocity _target;
                    _cfcust = fuel _target;
 
                    if ((_velocity select 0 > 1) or (_velocity select 1 > 1) or (_velocity select 2 > 1)) exitWith {
                            titleText ["Refueling Stopped", "PLAIN DOWN", 3];
                    };
                    if (_cfcust >= 1.0) exitWith {
                            titleText ["Done Refueling", "PLAIN DOWN", 3];
                    };
 
                    sleep 0.5;
 
                    _cfcust = _cfcust + _amount;
 
                    if (_cfcust >= 1.0) then { _cfcust = 1.0; };
 
                    _target setFuel _cfcust;
            };
 
            titleFadeOut 1;
 
            ib_refueling_in_progress = false;
    };


reedited by Dávison. added new parameter to turn off the car engine when refueling
 
I have changed it a little on mine to only allow air vehicles to refuel and tossed in a restriction that the engine needs to be off in order to prevent hover fueling.

kh_actions.sqf
Code:
private ["_vehicle", "_vehicle_refuel_id"];
//Awesomely Edited by Seven, Then modified by Muddr, Then modified by Davison
_vehicle = objNull;
diag_log "Running ""kh_actions"".";
 
_distance = 15; // Distance from object to display Refuel Message
_amount= 0.003; // Amount of fuel to add per loop. Default was 0.005
 
while {true} do
{
    if (!isNull player) then {
        private ["_currentVehicle", "_isNearFeed", "_countFuel"];
                _currentVehicle = vehicle player;
                _countFuel = (count ((position _currentVehicle) nearObjects ["Land_Fuel_tank_big", _distance]));
                _countFuel = _countFuel + (count ((position _currentVehicle) nearObjects ["Land_A_FuelStation_Feed", _distance]));
                _countFuel = _countFuel + (count ((position _currentVehicle) nearObjects ["Land_Ind_TankSmall", _distance]));
                _countFuel = _countFuel + (count ((position _currentVehicle) nearObjects ["Land_Ind_TankSmall2", _distance]));
                _countFuel = _countFuel + (count ((position _currentVehicle) nearObjects ["Land_Ind_TankSmall2_EP1", _distance]));
                _countFuel = _countFuel + (count ((position _currentVehicle) nearObjects ["Land_fuel_tank_stairs", _distance]));
                _isNearFeed = _countFuel > 0;
 
        if (_vehicle != _currentVehicle) then {
            if (!isNull _vehicle) then {
                _vehicle removeAction _vehicle_refuel_id;
                _vehicle = objNull;
            };
 
            if (_currentVehicle != player && _isNearFeed && !(_currentVehicle isKindof "Land")) then { //change "Bicycle" to "Land" to allow only air vehicles use.
                _vehicle = _currentVehicle;
 
                _vehicle_refuel_id = _vehicle addAction ["Refuel", "Scripts\kh_vehicle_refuel.sqf", [_amount], -1, false, true, "", "vehicle _this == _target && local _target"];
            };
        };
   
        if (!_isNearFeed) then {
            _vehicle removeAction _vehicle_refuel_id;
            _vehicle = objNull;
        };
    };
    sleep 2;
}

kh_vehicle_refuel.sqf
Code:
private ["_target", "_caller", "_id"];
 
_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_args = _this select 3;
_amount = _args select 0;
 
if (isNil "ib_refueling_in_progress") then { ib_refueling_in_progress = false; };
 
if (!ib_refueling_in_progress) then {
 
        ib_refueling_in_progress = true;
 
        titleText ["Refueling", "PLAIN DOWN", 3];
 
        while {(vehicle _caller == _target) and (local _target)} do {
                private ["_velocity", "_cfcust", "_OnOff"];
   
                _velocity = velocity _target;
                _cfcust = fuel _target;
                _OnOff = isEngineOn _target;
                
                if (_OnOff) exitWith {
                        titleText ["Engine must be turned off to refuel", "PLAIN DOWN", 3];
                };
                if ((_velocity select 0 > 1) or (_velocity select 1 > 1) or (_velocity select 2 > 1)) exitWith {
                        titleText ["Refueling Stopped", "PLAIN DOWN", 3];
                };
                if (_cfcust >= 1.0) exitWith {
                        titleText ["Done Refueling", "PLAIN DOWN", 3];
                };
 
                sleep 0.5;
 
                _cfcust = _cfcust + _amount;
 
                if (_cfcust >= 1.0) then { _cfcust = 1.0; };
 
                _target setFuel _cfcust;
        };
 
        titleFadeOut 1;
 
        ib_refueling_in_progress = false;
};
 
No idea what I'm doing wrong, I had it working perfectly fine before, but I don't get the scroll wheel option in order to run this.
This is at the bottom of my init file:
[] execVM "custom\kh_actions.sqf";
While I have Silva's scripts under custom, and yes I modified kh_actions for custom\kh_vehicle_refuel.sqf.
 
I modified the code of the script left only refuel in Gas Stations equal to what was posted by Seven and Muddr.(Thanks Seven, for correcting me.)

Thanks, works like a charm.

No idea what I'm doing wrong, I had it working perfectly fine before, but I don't get the scroll wheel option in order to run this.
This is at the bottom of my init file:
[] execVM "custom\kh_actions.sqf";
While I have Silva's scripts under custom, and yes I modified kh_actions for custom\kh_vehicle_refuel.sqf.
Its not meant to be at the bottom
add this code after "if (!isDedicated) then {" in your missions init.sqf
 
Thanks, works like a charm.


Its not meant to be at the bottom

just put the files in the Scripts folder in your mission.pbo or change the code:

find in
kh_actions.sqf
PHP:
                    _vehicle_refuel_id = _vehicle addAction ["Refuel", "Scripts\kh_vehicle_refuel.sqf", [_amount], -1, false, true, "", "vehicle _this == _target && local _target"];

and change

PHP:
                    _vehicle_refuel_id = _vehicle addAction ["Refuel", "Custom\kh_vehicle_refuel.sqf", [_amount], -1, false, true, "", "vehicle _this == _target && local _target"];


here: change the directory: "Scripts\kh_vehicle_refuel.sqf"
 
I have my folder + files in place but I can't see what needs to be added to the init/mission.sqf

Adding this to my second sever but it's all chanced since 1.7.7 :<
 
I modified the script that Seven posted to work with all the fuel tanks you can use with jerry cans and the gas pumps. I removed some code that wasn't needed and added messages for when the vehicle moves while fueling and when fueling is done. Added some variables to the kh_actions.sqf file (lines 6 & 7) for distance from tanks/pumps and amount of fuel per loop so it can be changed easily.

kh_actions.sqf - http://pastebin.com/rCW8sWCC
kh_vehicle_refuel.sqf - http://pastebin.com/6AmSQB8w



arent they supposed to be in sqf? also they go in the root directory, with the first posters class sensors.or what are the steps needed to make this work. with your 2 files here?
 
Do I need to edit the line for BattleEye scripts to begin with 1 instead of 5? I added the two files in a folder 'Scripts' to my mission.pbo then added the line to BattleEye scripts via ftp. Tried to get in server and was kicked for BattleEye script restriction #243.
 
I combined Seven and Muddr's posts and it works great! Thank you to you both!!

At first, I had an issue with being kicked for #44, but it was easily fixed. Remember to add this to your "5 setFuel" line:

5 setFuel !"\"setFuel\"," !"z\addons\dayz_code\compile\local_setFuel.sqf" !"\"dayzSetFuel\"" !"dayzSetFuel_code" !"dayzSetFuel = _val;" !"Scripts\kh_actions.sqf" !"Scripts\kh_vehicle_refuel.sqf"
 
Back
Top