Customizing Auto Refuel (Help Needed)

For anyone interested, here is my altered version of Auto refuel. It currently features;
-Different (and easily changeable) refuel rates for air and land vehicles
-Different (and easily changeable) refuel distances for air and land vehicles
-Requires engines to be off to refuel
-Calls you a variety naughty things to you if you try to refuel a bicycle (updated! because thats what I do with my time.)
-Added compatibility with boats (though you will probably need to edit your map to have fuel tanks in/near the water for it to mean anything)

To implement it you just need to follow the same directions as the regular Auto Refuel shown here1
http://dayz.st/w/HOW-TO_add_Auto_Refuel

With the small difference on the last step, in which you have to change
Code:
 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"
to
Code:
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 !"Scripts\kh_airvehicle_refuel.sqf"

To customize the refuel rates, or distances to refuel simply open kh_actions.sqf and find this
Code:
_distance = 15; // Distance from object to display Refuel Message for land vehicles
_airdistance = 30; // Distance from object to display Refuel Message for air vehicles
_seadistance = 25; // Distance from object to display Refuel Message for air vehicles
_amount= 0.006; // Amount of fuel to add per loop. Default was 0.005
_airamount= 0.0012; // Amount of fuel to add for air vehicles per loop. Default was 0.005
then change it to your heart's content.
 

Attachments

  • Scripts.zip
    2.3 KB · Views: 164
Honestly stating ideas is great, but exactly as you said you don't know how to code. First learn at least the basics of coding. If you do you wouldn't be asking these questions. Spend some of your personal time learning to code instead of asking for help to code something. People more than often help people who shows that they spent some time working on something.

Now off to answer what you stated. What you want can easily be done with basic coding. For the different refuel rates you'll have to use either a switch statement with for loops or if statements with for loops. As for the different heli range that's all but setting the height variable. Which is coding 101. Do learn to code and try to write a solution. And if you can't get it to work then post your code and the community will help you then.
 
At the cost of looking like a retard (which I was originally trying to avoid) I've come up with something that I think should do what I wanted it to do. However it seems I broke something because the refuel option doesn't come up any longer. Given the nature of the problem I think I probably did something stupid in kh_actions, but I'm not sure. Would you fine gentlemen please look at what I did and tell me what I'm doing wrong?
 

Attachments

  • kh_actions.sqf
    2.5 KB · Views: 11
  • kh_vehicle_refuel.sqf
    1.4 KB · Views: 8
Take a look at your else statement... it's in the wrong place and has nothing right about it !

Code:
    _vehicle_refuel_id = _vehicle addAction ["Refuel", "Scripts\kh_vehicle_refuel.sqf", [_airamount], -1, false, true, "", "vehicle _this == _target && local _target"];
            };
           
            else (_currentVehicle != player && _isNearFeed && !(_currentVehicle isKindof "Bicycle")) then {  //change "Bicycle" to "Land" to allow only air vehicles to auto-refuel
                _vehicle = _currentVehicle;
 
Code:
        if (_vehicle != _currentVehicle) then {
            if (!isNull _vehicle) then {
                _vehicle removeAction _vehicle_refuel_id;
                _vehicle = objNull;
            };
 
            if (_currentVehicle != player && _isNearFeed && !(_currentVehicle isKindof "Land")) then
            { 
                _vehicle = _currentVehicle;
 
                _vehicle_refuel_id = _vehicle addAction ["Refuel", "Scripts\kh_vehicle_refuel.sqf", [_airamount], -1, false, true, "", "vehicle _this == _target && local _target"];
            };
 
            else
            {
                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"];
                };
            };
        };

You don't need to check your criteria again, since you checked if it's a heli then do the airamount else it runs the original code. I haven't tried this code, just rearranged it. See if it works.

Go and look up proper uses of if and else statements. Lol
 
If it's only checked to be a heli in the first one, wouldn't the second line also include bicycles? I'm not sure what problems that causes but since they were originally excluded I had assumed something had to be done about them.
That's kinda what caused some confusion for me I guess?

Edit: Could the first check then be changed to read something like
Code:
if (_currentVehicle != player && _isNearFeed && (_currentVehicle isKindof "Air")) then {  //change "Bicycle" to "Land" to allow only air vehicles to auto-refuel
                _vehicle = _currentVehicle;
to bypass that problem?
 
Forgot about that. Edited my post.

That would be nice in theory, but I'm not sure what variable heli's and such are. You have to look into the cfg files and find what there defined as. If it is defined as air then go for it and try it out. But you would still need an exclusion for bicycles. So that the script doesn't run when a bike gets close.
 
Unfortunately the bit you gave me didn't make the refuel option appear either. Thanks for your time though, and if you can come up with anything else then it would be greatly appreciated.
 
You've made a real hash of your code mate, but kudos for giving it a go. I want to help you , but I'm confident you're just about to break through with it, so here's another tip for you...

You only need to check if it's an "AIR" vehicle, then if the Engine is still on (see that link I gave you) exit with a title text or hint saying something like "You cannot refuel, please land first". Scrap everything you've just done and start again, think less "else" and more just "if" statements , less is better ;)

You'll get there and when you do, share your work with the community, like I do. Good luck :)
 
Oh and for the bicycle issue, same thing... Check if it's a bicycle and again exitWith { hintSilent "You can't refuel a bicycle silly"; } .... Obviously you'll need to expand on that code ;)

Edited: Actually, I've just looked at the scripts and the bicycle doesn't get a refuel option.
 
You've made a real hash of your code mate, but kudos for giving it a go. I want to help you , but I'm confident you're just about to break through with it, so here's another tip for you...

You only need to check if it's an "AIR" vehicle, then if the Engine is still on (see that link I gave you) exit with a title text or hint saying something like "You cannot refuel, please land first". Scrap everything you've just done and start again, think less "else" and more just "if" statements , less is better ;)

You'll get there and when you do, share your work with the community, like I do. Good luck :)

Teaching is satisfying am I right?
Learning is too :)
 
Urban is right. Actually had time to sit down and look at the complete script. What you want can easily be done with if statements. Checking for each case you have. You almost got it. Hint for the cases to check for air, land, bicycle. Good luck and update if you get it working. :)
 
@Manatee: I'm glad I learnt to do this stuff myself, because now I can make my DayZ server experience whatever I can imagine (within my limited abilities of course, but still enough). I have custom menus with a "FOR FUN" menu option that gives players Dance moves, I've customised my debug monitor to show you who your cursor is pointing at within 40 meters, I've added in loads of atmospheric sound effects with triggers attached, and I'm almost finished with my safe bases (a bit messy , but once I'm done I'll clean it up). I get those "WOOOHOOOO HELL YEAH!!! WHO's YOUR DADDY" moments all the time haha!

It's a drug.. Once you start, you just can't stop :D
 
Dude sounds like you've made some freaking awesome progress, close range identification would be excellent. Dance moves, I seen some servers with it - it's rather hilarious dancing around a fire.

I still haven't really gotten into the meat yet of coding a whole script on my own, just modifying what is available here and making it work with other stuff that sometimes conflicts for reasons beyond my comprehension (for now!)
 
Back
Top