Jump to content
Gruntini

Refuel vehicle add action on unit?

Recommended Posts

unitName addAction 
[
	"Refuel Vehicle",
	{
		vehicle (_this select 0) setFuel 1;
		_handle = [] spawn
		{
			hintSilent "Refueled.";
			sleep 3;
			hintSilent "";
		};
	},
	nil,
	6,
	true,
	true,
	"",
	"
		vehicle _this != _this && 
		vehicle _this isKindOf 'LandVehicle' &&
		fuel vehicle _this < 1
	"
];

Works only for Land Vehicles, but that can be changed.

  • Like 1

Share this post


Link to post
Share on other sites

I would also add in a check to see if the vehicle is local to the client trying to refuel it, or the 'setFuel' command will not work. Just a small addition to JShocks code which should work fine anyways.

// JShocks code
unitName addAction 
[
"Refuel Vehicle",
{
vehicle (_this select 0) setFuel 1;
_handle = [] spawn
{
hintSilent "Refueled.";
sleep 3;
hintSilent "";
};
},
nil,
6,
true,
true,
"",
"
vehicle _this != _this && 
vehicle _this isKindOf 'LandVehicle' &&
fuel vehicle _this < 1 &&
(local (vehicle _this))
"
];

^ last line

Share this post


Link to post
Share on other sites

This script should handle refueling for non local vehicles. Obviously adjust and add whatever else you need where needed:

this addAction 
[
  "Refuel",
  {
    params ["_target"];
    _target = vehicle _target;

    if (local _target) then {
      _target setFuel 1;
    } else {
      [_target, 1] remoteExecCall ["setFuel", _target];
    };
  },
  nil,
  6,
  true,
  true,
  "",
  "
    !isNull objectParent _this && 
    vehicle _this isKindOf ""LandVehicle"" &&
    fuel vehicle _this < 1
  "
];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×