DayZ Chenarus Auto Refuel! All stations!

Was just informed that my script is actually working right now, just only on the tanks without the ladder on the side. Such as the one near Lubjansk entrance. If anyone figures out the ID for the tank with the ladder on the side, please let me know, my searches have come up with nothing so far :/.
 
Getting "data file is to short" error. I've replaced the code in my mission file with your code mattz, and put the other file in the right place. Have any idea what I can do to make it work? :)
 
Figured it out, had the chopper part too. But now i still get #44 kick. Though i added the 4 lines. (1 for refuel, 3 for chopper)
 
I am having issues with BE script restriction 45 - I have tried adding the line: !"scriptsMZ\MZ_reload.sqf"

- this is what I have:

5 setFuel !"\"setFuel\"," !"z\addons\dayz_code\compile\local_setFuel.sqf" !"\"dayzSetFuel\" !"scriptsMZ\MZ_reload.sqf"


- This is a private bliss server (so the file loc. is bliss\battleye\scripts.txt
Any suggestions?
 
- This is a private bliss server (so the file loc. is bliss\battleye\scripts.txt
Any suggestions?

Are you sure about that path? That sounds like the path to your Bliss repo, which isn't where you run the server from. Check (arma2oafolder)\dayz_1.chernarus(/namalsk)\battleye\scripts.txt
 
I'm trying to get this to work with multiple station types, but it doesn't work. What would I need to change to make this work with 3 different types of fuel tank/station?

This is what I changed, but it doesn't work:

Code:
["Land_A_FuelStation_Shed","Land_repair_center","FuelStation","FuelStation_army","Land_Mil_Repair_center_EP1","Land_A_FuelStation_Build","Land_A_FuelStation_Feed","Land_Ind_FuelStation_Feed_EP1","Land_Ind_FuelStation_Build_EP1","Land_Ind_FuelStation_Shed_EP1","Land_Ind_Garage01_EP1","HeliH", 30]) > 0;


why is everyone making this so hard for them selves having to add extra objects to their mission file. I use a script that brings a refuel scroll wheel option up when you are near a pump, all it requires is a single line added to the init.sqf. I could easily modify it to be automatic.

add this code after "if (!isDedicated) then {" in your missions init.sqf
PHP:
[] execVM "Scripts\kh_actions.sqf";

Then make a folder called "Scripts" and add these two files

kh_actions.sqf
PHP:
private ["_vehicle", "_vehicle_refuel_id"];
//Awesomely Edited by Seven
_vehicle = objNull;
diag_log "Running ""kh_actions"".";
while {true} do
{
    if (!isNull player) then
    {
        private ["_currentVehicle", "_isNearFeed"];
 
 
        _currentVehicle = vehicle player;
        _isNearFeed = count ((position _currentVehicle) nearObjects ["Land_A_FuelStation_Feed", 10]) > 0;
 
        if (_vehicle != _currentVehicle) then
        {
            if (!isNull _vehicle) then
            {
                _vehicle removeAction _vehicle_refuel_id;
                _vehicle = objNull;
            };
 
            if (_currentVehicle != player && _isNearFeed) then
            {
                _vehicle = _currentVehicle;
 
                _vehicle_refuel_id = _vehicle addAction ["Refuel", "Scripts\kh_vehicle_refuel.sqf", [], -1, false, false, "",
                  "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", "_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", "_cfcust"];
     
            _velocity = velocity _target;
            _cfcust = fuel _target;
 
            if ((_velocity select 0 > 1) or (_velocity select 1 > 1) or (_velocity select 2 > 1)) exitWith { };
            if (_cfcust >= 1.0) exitWith { };
 
            sleep 0.5;
 
            _cfcust = _cfcust + 0.005;
 
            if (_cfcust >= 1.0) then { _cfcust = 1.0; };
 
            _target setFuel _cfcust;
        };
 
        titleFadeOut 1;
 
        ib_refueling_in_progress = false;
    };
};
 
When I use the bus when I enter the station I only have access to the refueling script about the first foot under the station roof then it stops working. If I drive into the station and move the bus into the parked postion it does not work. Seem to be a really small area where this works.
 
For more fuel stations: nearObjects doesn't take an array just a single typeName. I am going to add this to my server at the weekend and would like to do the same so will have a look then at tweaking it.

For the refuelling script_isNearFeed needs setting to true or false. I like the way it has been done with a (count >0), very nice.. I have tried replacing nearObject with nearestObjects on the same line but just got errors, it was late.

To increase the distance change the 10 (10 meters), on the nearObjects to something higher, try 15 or 20 in both sqf files
Code:
_isNearFeed = count ((position <vehicle>) nearObjects ["Land_A_FuelStation_Feed", 10]) > 0;
 
Haven't tried it yet, but logically the following should work.

PHP:
         _isNearFeed = count ((position _currentVehicle) nearObjects ["Land_A_FuelStation_Feed", 10] || (position _currentVehicle) nearObjects ["Land_A_FuelStation_Shed", 10] || (position _currentVehicle) nearObjects ["Land_repair_center", 10] || (position _currentVehicle) nearObjects ["FuelStation", 10] || (position _currentVehicle) nearObjects ["FuelStation_army", 10] || (position _currentVehicle) nearObjects ["Land_Mil_Repair_center_EP1", 10] || (position _currentVehicle) nearObjects ["Land_A_FuelStation_Build", 10] || (position _currentVehicle) nearObjects ["Land_A_FuelStation_Feed", 10] || (position _currentVehicle) nearObjects ["Land_Ind_FuelStation_Feed_EP1", 10] || (position _currentVehicle) nearObjects ["Land_Ind_FuelStation_Build_EP1", 10] || (position _currentVehicle) nearObjects ["Land_Ind_FuelStation_Shed_EP1", 10] || (position _currentVehicle) nearObjects ["Land_Ind_Garage01_EP1", 10] || (position _currentVehicle) nearObjects ["HeliH", 10]) > 0;
 
Got this script working on dayz.st , perfectly! Even added a few heli pads to it and put the code in the sensors array. Great work :)
 
There seems to be two completely separate scripts on this thread. The original script uses the positions (coordinates) of each gas station, so in theory you could put in the coordinates for a dog shed and if a vehicle was close enough to the dog shed it would refuel. The second script (the one that hijacked the original thread) uses object detection and unfortunately only detects Gas Stations , and as such isn't practical for me (I did post asking how to add additional objects, but the poster of that script isn't answering question).

Going back to the original script (page 1 of this thread) , I simply edited my map and added a custom gas tank and several heli pads. I then looked at the code he tells you to put in your mission file, and added several extra sensors in the array (remembering to update the object count and not mess up the syntax). I then copied the coordinates for each new object (i.e heli pad, gas tank) and put them in the new sensor arrays.

Was much more simpler than the second script and the code seems way cleaner as well.
 
There seems to be two completely separate scripts on this thread. The original script uses the positions (coordinates) of each gas station, so in theory you could put in the coordinates for a dog shed and if a vehicle was close enough to the dog shed it would refuel. The second script (the one that hijacked the original thread) uses object detection and unfortunately only detects Gas Stations , and as such isn't practical for me (I did post asking how to add additional objects, but the poster of that script isn't answering question).

Going back to the original script (page 1 of this thread) , I simply edited my map and added a custom gas tank and several heli pads. I then looked at the code he tells you to put in your mission file, and added several extra sensors in the array (remembering to update the object count and not mess up the syntax). I then copied the coordinates for each new object (i.e heli pad, gas tank) and put them in the new sensor arrays.

Was much more simpler than the second script and the code seems way cleaner as well.

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
 
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
This worked perfectly, with the exception of a fuel random things, like the ability to refuel a bicycle, but that is such a minor thing that it doesn't even register as a problem. Thanks for this.
 
Back
Top