BetterDeadThanZed

[Release] Refuel helicopters with fuel barrels/Fill fuel barrels at gas pumps

14 posts in this topic

Advertisement
2 minutes ago, kuplion said:

It looks like you've copied a special character. Make sure you press "RAW" and then select all and copy.

already find the problem :) thx

  • Like 1

Share this post


Link to post
Share on other sites

@BetterDeadThanZed Not sure if this would actually work or not to drain into the barrel. However, it might be a start. In the code, I set the barrel to a "volume" of 200 (~50 gal), as the can is 20 (~5 gal). 

ExileClient_object_vehicle_drain.sqf

Spoiler

/**
 * ExileClient_object_vehicle_drain
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_object","_hasACan","_hasABarrel","_magazines","_amount","_fuelDetails","_fuelAmount"];
_object = _this select 0;
_hasACan = [];
_hasABarrel = [];
_magazines = magazinesAmmo player;

{
    if((_x select 0) isEqualTo "Exile_Item_FuelCanisterEmpty")then
    {
        _amount = 20;
        _hasACan = ["Exile_Item_FuelCanisterEmpty",_amount,1];
    };
    if((_x select 0) isEqualTo "Exile_Item_FuelCanisterFull")then
    {
        if((_x select 1) < 20)then
        {
            _amount = 20 - (_x select 1);
            _hasACan = ["Exile_Item_FuelCanisterFull",_amount,_x select 1];
        };
    };
    if((count _hasACan) isEqualTo 3)exitWith{};
}
forEach _magazines;

{
    if((_x select 0) isEqualTo "Exile_Item_FuelBarrelEmpty")then
    {
        _amount = 200;
        _hasABarrel = ["Exile_Item_FuelBarrelEmpty",_amount,1];
    };
    if((_x select 0) isEqualTo "Exile_Item_FuelBarrelFull")then
    {
        if((_x select 1) < 200)then
        {
            _amount = 200 - (_x select 1);
            _hasABarrel = ["Exile_Item_FuelBarrelFull",_amount,_x select 1];
        };
    };
    if((count _hasABarrel) isEqualTo 3)exitWith{};
}
forEach _magazines;

if((count _hasACan) isEqualTo 3)then
{
    _fuelDetails = _object call ExileClient_util_fuel_getRealFuel;
    _fuelAmount = _fuelDetails select 0;
    if(_fuelAmount isEqualTo 0)exitWith
    {
        ["ErrorTitleAndText", ["Failed to drain fuel!", "There is no fuel left to drain."]] call ExileClient_gui_toaster_addTemplateToast;
    };
    if((_hasACan select 1) > _fuelAmount)then
    {
        [
            player,
            [_hasACan select 0,_hasACan select 2],
            ["Exile_Item_FuelCanisterFull",(20 -(_hasACan select 1)) + _fuelAmount]
        ] call ExileClient_util_inventory_replaceMagazine;
        _amount = _fuelAmount;
    }
    else
    {
        [
            player,
            [_hasACan select 0,_hasACan select 2],
            ["Exile_Item_FuelCanisterFull",(20 -(_hasACan select 1)) + _amount]
        ] call ExileClient_util_inventory_replaceMagazine;
    };     

if((count _hasABarrel) isEqualTo 3)then
{
    _fuelDetails = _object call ExileClient_util_fuel_getRealFuel;
    _fuelAmount = _fuelDetails select 0;
    if(_fuelAmount isEqualTo 0)exitWith
    {
        ["ErrorTitleAndText", ["Failed to drain fuel!", "There is no fuel left to drain."]] call ExileClient_gui_toaster_addTemplateToast;
    };
    if((_hasABarrel select 1) > _fuelAmount)then
    {
        [
            player,
            [_hasABarrel select 0,_hasACan select 2],
            ["Exile_Item_FuelBarrelFull",(200 -(_hasABarrel select 1)) + _fuelAmount]
        ] call ExileClient_util_inventory_replaceMagazine;
        _amount = _fuelAmount;
    }
    else
    {
        [
            player,
            [_hasABarrel select 0,_hasABarrel select 2],
            ["Exile_Item_FuelBarrelFull",(200 -(_hasABarrel select 1)) + _amount]
        ] call ExileClient_util_inventory_replaceMagazine;
    };

    call ExileClient_object_player_save;
    if(local _object)then
    {
        [_object,-_amount] call ExileClient_util_fuel_setFuel;
    }
    else
    {
        ["setFuelRequest",[netId _object,-_amount]] call ExileClient_system_network_send;
    };
    ["SuccessTitleAndText", ["Drained fuel!", format ["You have drained %1L.", _amount]]] call ExileClient_gui_toaster_addTemplateToast;
}
else
{
    ["ErrorTitleAndText", ["Failed to drain fuel!", "You do not have a fuel canister."]] call ExileClient_gui_toaster_addTemplateToast;
};
true

 

Share this post


Link to post
Share on other sites

My setup for draining to barrels (which are 300 liters by the way):

private["_object","_hasACan","_magazines","_amount","_fuelDetails","_fuelAmount"];
_object = _this select 0;
_hasACan = [];
_magazines = magazinesAmmo player;
{
	if((_x select 0) isEqualTo "Exile_Item_FuelCanisterEmpty")then
	{
		_amount = 20;
		_hasACan = ["Exile_Item_FuelCanisterEmpty",_amount,1];
	};
	if((_x select 0) isEqualTo "Exile_Item_FuelCanisterFull")then
	{
		if((_x select 1) < 20)then
		{
			_amount = 20 - (_x select 1);
			_hasACan = ["Exile_Item_FuelCanisterFull",_amount,_x select 1];
		};
	};
	if ((_x select 0) isEqualTo "Exile_Item_FuelBarrelEmpty") then
	{
		_amount = 300;
		_hasACan = ["Exile_Item_FuelBarrelEmpty",_amount,1];
	};
	if ((_x select 0) isEqualTo "Exile_Item_FuelBarrelFull") then
	{
		if ((_x select 1) < 300) then
		{
			_amount = 300 - (_x select 1);
			_hasACan = ["Exile_Item_FuelBarrelFull",_amount,_x select 1];
		};
	};
	if((count _hasACan) isEqualTo 3)exitWith{};
}
forEach _magazines;
if((count _hasACan) isEqualTo 3)then
{
	_fuelDetails = _object call ExileClient_util_fuel_getRealFuel;
	_fuelAmount = _fuelDetails select 0;
	if(_fuelAmount isEqualTo 0)exitWith
	{
		["ErrorTitleAndText", ["Failed to drain fuel!", "There is no fuel left to drain."]] call ExileClient_gui_toaster_addTemplateToast;
	};
	if ((_hasACan select 0) isEqualTo "Exile_Item_FuelCanisterEmpty") then
	{
		if((_hasACan select 1) > _fuelAmount)then
		{
			[
				player,
				[_hasACan select 0,_hasACan select 2],
				["Exile_Item_FuelCanisterFull",(20 -(_hasACan select 1)) + _fuelAmount]
			] call ExileClient_util_inventory_replaceMagazine;
			_amount = _fuelAmount;
		}
		else
		{
			[
				player,
				[_hasACan select 0,_hasACan select 2],
				["Exile_Item_FuelCanisterFull",(20 -(_hasACan select 1)) + _amount]
			] call ExileClient_util_inventory_replaceMagazine;
		};
	};
	if ((_hasACan select 0) isEqualTo "Exile_Item_FuelBarrelEmpty") then
	{
		if((_hasACan select 1) > _fuelAmount)then
		{
			[
				player,
				[_hasACan select 0,_hasACan select 2],
				["Exile_Item_FuelBarrelFull",(300 -(_hasACan select 1)) + _fuelAmount]
			] call ExileClient_util_inventory_replaceMagazine;
			_amount = _fuelAmount;
		}
		else
		{
			[
				player,
				[_hasACan select 0,_hasACan select 2],
				["Exile_Item_FuelBarrelFull",(300 -(_hasACan select 1)) + _amount]
			] call ExileClient_util_inventory_replaceMagazine;
		};
	};
	call ExileClient_object_player_save;
	if(local _object)then
	{
		[_object,-_amount] call ExileClient_util_fuel_setFuel;
	}
	else
	{
		["setFuelRequest",[netId _object,-_amount]] call ExileClient_system_network_send;
	};
	["SuccessTitleAndText", ["Drained fuel!", format ["You have drained %1L.", _amount]]] call ExileClient_gui_toaster_addTemplateToast;
}
else
{
	["ErrorTitleAndText", ["Failed to drain fuel!", "You do not have a fuel canister."]] call ExileClient_gui_toaster_addTemplateToast;
};
true

 

Annoyingly the barrels use jerrycan models so putting them in the loot table was a no-go for me as they are identical to jerrycans visually. Weight and capacity seems to be correct so all that is needed is to make them use a barrel model and make an icon for inventory.

  • Thanks 1

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.