• 0
exilerist

[SOLVED] ExileClient_object_vehicle_drain.sqf

Question

Hello.

Sorry for inconvenience.

It's not a question, but rather a solution.

Maybe this bug already known, maybe don't.

If you don't have enough space in your inventory, you'll do not receive full and lost empty canisters.

I hope this code is right.

Spoiler


/**
 * ExileClient_object_vehicle_drain
 *
 * Exile Mod
 * www.exilemod.com
 * © 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", "_magazines", "_canAdd", "_amount", "_fuelDetails", "_fuelAmount"];
_object = _this select 0;
_hasACan = [];
_magazines = magazinesAmmo player;
_canAdd = [player, "Exile_Item_FuelCanisterFull"] call ExileClient_util_playerCargo_canAdd;
if !(_canAdd) exitWith
{
	["ErrorTitleAndText", ["Your inventory is full!", "You need more inventory space to carry a full canister!"]] call ExileClient_gui_toaster_addTemplateToast;
};
{
	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((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;
	};	 
	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

 

Actually, I have bad experience with crafting breaching charges too.

So all components have been removed, but the charge hasn't been added.

Maybe ExileClient_util_inventory_canExchangeItems logic do not work properly all the time and ExileClient_util_playerCargo_canAdd logic should be added?

Maybe it depends on 3rd party mods.

I hope you'll fix this issue in the next release.

Thanks for your efforts.

 

Good luck.

Edited by exilerist
  • Like 3

Share this post


Link to post
Share on other sites

10 answers to this question

  • 0

Good catch!

We brought that issue about crafting breaching charges up in forums and discord but didn't got any attention for it :|

However, ravmustang aka. DirtySanchez was helping out and wrote a quickfix back in the days #propz2dirtymusty:

Spoiler

/**
 * ExileClient_util_inventory_canExchangeItems
 *
 * Exile Mod
 * www.exilemod.com
 * © 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["_itemsToRemoveFirst", "_itemsToAddAfterwards", "_result", "_uniformLoad", "_uniformMaximumLoad", "_uniformContent", "_vestLoad", "_vestMaximumLoad", "_vestContent", "_backpackLoad", "_backpackMaximumLoad", "_backpackContent", "_quantity", "_itemClassName", "_itemMass", "_i", "_index"];
_itemsToRemoveFirst = _this select 0;
_itemsToAddAfterwards = _this select 1; 
_result = true;
//_uniformLoad = loadUniform player;
_uniformLoad = 0;
_uniformMaximumLoad = (uniform player) call ExileClient_util_gear_getMaximumLoad;
_uniformContent = uniformItems player;
{
    _itemMass = _x call ExileClient_util_gear_getMass;
    _uniformLoad = _uniformLoad + _itemMass;
}forEach _uniformContent;
//_vestLoad = loadVest player;
_vestLoad = 0;
_vestMaximumLoad = (vest player) call ExileClient_util_gear_getMaximumLoad;
_vestContent = vestItems player;
{
    _itemMass = _x call ExileClient_util_gear_getMass;
    _vestLoad = _vestLoad + _itemMass;
}forEach _vestContent;
//_backpackLoad = loadBackpack player;
_backpackLoad = 0;
_backpackMaximumLoad = (backpack player) call ExileClient_util_gear_getMaximumLoad;
_backpackContent = backpackItems player;
{
    _itemMass = _x call ExileClient_util_gear_getMass;
    _backpackLoad = _backpackLoad + _itemMass;
}forEach _backpackContent;
{
    _quantity = _x select 0;
    _itemClassName = _x select 1;
    _itemMass = _itemClassName call ExileClient_util_gear_getMass;
    for "_i" from 1 to _quantity do
    {
        _index = _backpackContent find _itemClassName;
        if (_index != -1) then
        {
            _backpackContent deleteAt _index;
            _backpackLoad = _backpackLoad - _itemMass;
        }
        else 
        {
            _index = _vestContent find _itemClassName;
            if (_index != -1) then
            {
                _vestContent deleteAt _index;
                _vestLoad = _vestLoad - _itemMass;
            }
            else 
            {
                _index = _uniformContent find _itemClassName;
                if (_index != -1) then
                {
                    _uniformContent deleteAt _index;
                    _uniformLoad = _uniformLoad - _itemMass;
                }
            };
        };
    };

forEach _itemsToRemoveFirst;
{
    _quantity = _x select 0;
    _itemClassName = _x select 1;
    _itemMass = _itemClassName call ExileClient_util_gear_getMass;
    for "_i" from 1 to _quantity do
    {
        if (_backpackLoad + _itemMass <= _backpackMaximumLoad) then
        {
            _backpackLoad = _backpackLoad + _itemMass;
        }
        else 
        {
            if (_vestLoad + _itemMass <= _vestMaximumLoad) then
            {
                _vestLoad = _vestLoad + _itemMass;
            }
            else 
            {
                if (_uniformLoad + _itemMass <= _uniformMaximumLoad) then
                {
                    _uniformLoad = _uniformLoad + _itemMass;
                }
                else 
                {
                    _result = false;
                };
            };
        }
    };
}
forEach _itemsToAddAfterwards;
_result

 

Edited by WURSTKETTE
  • Like 3

Share this post


Link to post
Share on other sites
Advertisement
  • 0

@exilerist
Can you provide an example of how to reproduce this? Like how your inventory was laid out, etc. Wurstkette has a great example in the link to his topic.
I am unable to reproduce it. 

@WURSTKETTE
I have fixed the crafting one, it will now attempt to add the item and if it can't, it will drop it at their feet. Arma inventory system sucks. 

  • Like 2

Share this post


Link to post
Share on other sites
  • 0

No. 

Just explain the exact steps you took to produce this bug, and I should be able to take it to my vanilla Exile server and be able to reproduce it. You shouldn't have to mention a server, or any mods.
As stated, WURSTKETTE provided a excellent example of what he did:

 

Share this post


Link to post
Share on other sites
  • 0

Hello.

@WolfkillArcadia

I'll try to explain, sorry for my English.

Spoiler

I've disabled overriding of ExileClient_object_vehicle_drain.sqf.

So, I have almost full inventory.

 

 

 

 

1 empty Fuel Canister, 24 items in total.

 

So, I've drained 20L of fuel...

 

And lost empty and do not get full canister.

Same situation goes to filling plastic canisters with dirty water, due to full canisters are spend more inventory space.

 

 

Good luck.

Thanks for your efforts.

Edited by exilerist

Share this post


Link to post
Share on other sites
Advertisement
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.