Jump to content
  • 0

Fast Craft Script


Assomnia

Question

Hello everyone !

I'm seeking for help for a strange problem I have with a Fast Craft Script. Basically it's a script that allows player to craft epoch stuff via GUI.
It looks like this :

fastcraft.jpg

The problem as you can see is that it doesn't show the Items Name, same for the tools needed...
I followed a (very) old tutorial which is here :

It looks different I know, but the files are not available anymore on the link provided so I had to find some other files online.

The craft itself is actually working (without checking for the right tools apparently, even if you don't have the tool required the craft works) but appart from the name and tool everything is OK.

All my folders regarding this script look like this :

fastcraft2.jpg

My Init is looking like that :
 

//Load in compiled functions
call compile preprocessFileLineNumbers "custom\Buildables\variables.sqf";

progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "custom\Buildables\Crafting_Compiles.sqf";

if (!isDedicated) then {
call compile preprocessFileLineNumbers "custom\crafting\Init.sqf";



My Description :
 

#include "custom\crafting\dialog.hpp"



My Space_interrupt :
 

if (_dikCode == 0x24) then {
    ExecVM "custom\crafting\start.sqf";
    _handled = true;
};

if (_dikCode == 0x02) then {
AAC_1 = true;
};
if (_dikCode == 0x04) then {
AAC_3 = true;
};


Compiles :

 

    player_removeObject =            compile preprocessFileLineNumbers "custom\Buildables\interior\remove.sqf";


That's it, I forgot something, can someone help me with this ? If you need any other file or stuff tell me, anything that can help I take it !

Thanks in advance

The files are here : http://www.filedropper.com/fastcraft

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Figure out a few things...

The buildable folder is actually not necessary as it is mixing the stuff together.
I think the code in the init is ok but for some reason it wont show up the name from the items...

Can someone tell me if it's coming from the crafting\init and where ?

 

Spoiler

Crafting_Items = [];
_magTypes = ["PartGeneric","PartWoodPile","ItemSandbag","ItemPlotDeed","ItemDocumentRamp","ItemWoodFloorHalf","ItemWoodFloorQuarter","ItemWoodStairs","ItemWoodWall","ItemWoodWallThird","ItemWoodWallDoor","ItemWoodWallWithDoor","ItemWoodWallGarageDoor","ItemWoodWallLg","ItemWoodWallDoorLg","ItemWoodWallWithDoorLg","ItemCanvas","ItemBurlap","ItemLightBulb","ItemCorrugated","ItemPole","ItemFuelBarrelEmpty","metal_panel_kit","desert_net_kit","forest_net_kit","PartPlankPack","CinderBlocks","PartPlywoodPack","PartWoodLumber","PartWoodPlywood","ItemTentOld","ItemTentDomed","ItemTentDomed2","BagFenceRound_DZ_kit","ItemSandbagLarge","ItemSandbagExLarge"];

_actions = ["Crafting"];
for "_i" from 1 to 7 do { _actions set [count _actions, "Crafting" + str _i]; };

{
    _magCfg = configFile >> "CfgMagazines" >> _x;
    _actionsCfg = _magCfg >> "ItemActions";

    for "_i" from 0 to count _actionsCfg - 1 do {
        _actionCfg = _actionsCfg select _i;
        _actionName = configName _actionCfg;

        if (isClass _actionCfg && {_actionName in _actions}) then {
            _text = format ["%1 (%2)", _x call fnc_getName, getText (_actionCfg >> "text")];
            Crafting_Items set [count Crafting_Items, [_x, _text, _actionName]];
        };
    };

} count _magTypes;

Crafting_Load = {
    _dialog = _this select 0;
    _listbox = _dialog displayCtrl 1500;

    call Crafting_ListboxLoad;

    for "_i" from 1 to 10 do { (_dialog displayCtrl 2100) lbAdd str _i; };
    (_dialog displayCtrl 2100) lbSetCurSel 0;

    (_dialog displayCtrl 1600) ctrlEnable false;
};

Crafting_Unload = {
    saveProfileNamespace;
};

Crafting_LBDblClick = {
    _listbox = _this select 0;
    _index = _this select 1;

    _data = call compile (_listbox lbData _index);
    _type = (_data select 0) + "/" + (_data select 2);
    _favourites = profileNamespace getVariable ["CraftingFavourites", []];

    if (_data call Crafting_isFavourite) then {
        _listbox lbSetPicture [_index, "custom\crafting\favourite_none.paa"];
        _favourites = _favourites - [_type];
    } else {
        _listbox lbSetPicture [_index, "custom\crafting\favourite.paa"];
        _favourites = _favourites + [_type];
    };

    profileNamespace setVariable ["CraftingFavourites", _favourites];

    call Crafting_ListboxLoad;
};

Crafting_LBSelChanged = {
    _listbox = _this select 0;
    _index = _this select 1;

    _data = call compile (_listbox lbData _index);
    _type = _data select 0;
    _text = _data select 1;
    _action = _data select 2;

    _config = configFile >> "CfgMagazines" >> _type >> "ItemActions" >> _action;
    
    _config2 = configFile >> "CfgMagazines" >> _type >> "ItemActions" >> _action;
    _arrayToText = {
        private ["_output","_type","_quantity"];
        _output = "";
        {
            if (typeName _x == "ARRAY") then {
                _output = _output + format ["%1 x %2<br/>", _x select 1, (_x select 0) call fnc_getName];
            } else {
                _output = _output + format ["%1<br/>", _x call fnc_getName];
            };
        } count _this;
        _output
    };

    _formatTitle = { parseText format ["<t align='left' size='0.7' color='#00FF40'>%1</t><br/>", _this] };
    _formatText = { parseText format ["<t align='left'>%1</t><br/>", _this] };

    /*_needNear = getArray (_config >> "neednearby") - ["sand","sawmill"];*/
    
    _needNear =     getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> _action >> "neednearby") - ["sand","sawmill"];

    _text = composeText [
        if (count _needNear > 0) then { "REQUIRED NEARBY:" call _formatTitle } else { parseText "" },
        if (count _needNear > 0) then { (_needNear call _arrayToText) call _formatText } else { parseText "" },
        "REQUIRED TOOLS:" call _formatTitle,
        (getArray (_config >> "requiretools") call _arrayToText) call _formatText,
        "ITEMS INPUT:" call _formatTitle,
        (getArray (_config >> "input") call _arrayToText) call _formatText,
        "ITEMS OUTPUT:" call _formatTitle,
        (getArray (_config >> "output") call _arrayToText) call _formatText
    ];

    ((ctrlParent _listbox) displayCtrl 1100) ctrlSetStructuredText _text;
};

Crafting_ButtonClick = {
    _button = _this select 0;
    _dialog = ctrlParent _button;
    _buttons = [_dialog displayCtrl 1600, _dialog displayCtrl 1601, _dialog displayCtrl 1602];

    if (_button in _buttons) exitWith {
        { _x ctrlEnable (_x != _button); } count _buttons;
    };

    _listbox = _dialog displayCtrl 1500;
    _index = lbCurSel _listbox;

    if (_index < 0) exitWith { systemChat "<Crafting> Select an item to craft."; };

    _data = call compile (_listbox lbData _index);
    _config = configFile >> "CfgMagazines" >> _data select 0 >> "ItemActions" >> _data select 2;

    _requiredNear = getArray (_config >> "neednearby") - ["sand","sawmill"];
    _requiredTools = getArray (_config >> "requiretools");
    _itemsIn = getArray (_config >> "input");
    _itemsOut = getArray (_config >> "output");

    _amount = lbCurSel (_dialog displayCtrl 2100) + 1;

    // Inventory
    if (!ctrlEnabled (_buttons select 0)) exitWith {
        _crafted = 0;

        for "_i" from 1 to _amount do {
            _mags = magazines player;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _count = { _x == _item } count _mags;
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                for "_x" from 1 to _quantity do {
                    player removeMagazine _item;
                };
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                for "_x" from 1 to _quantity do {
                    player addMagazine _item;
                };
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in Inventory.", _crafted, (_itemsOut select 0 select 0) call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };

    // Backpack
    if (!ctrlEnabled (_buttons select 1)) exitWith {
        _backpack = unitBackpack player;
        if (isNull _backpack) exitWith { systemChat "<Crafting> You are not wearing a backpack."; };

        _crafted = 0;

        for "_i" from 1 to _amount do {
            _mags = getMagazineCargo _backpack;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _index = (_mags select 0) find _item;
                _count = if (_index < 0) then { 0 } else { (_mags select 1) select _index };
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                ["Magazine", _backpack, _item, _quantity] call fnc_removeCargoGlobal;
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                _backpack addMagazineCargoGlobal [_item, _quantity];
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in %3.", _crafted, (_itemsOut select 0 select 0) call fnc_getName, _backpack call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };

    // Vehicle
    if (!ctrlEnabled (_buttons select 2)) exitWith {
        _vehicle = vehicle player;
        if (_vehicle == player || {driver _vehicle != player}) exitWith { systemChat "<Crafting> You must be in the driver's seat of a vehicle."; };

        _crafted = 0;

        for "_i" from 1 to _amount do {
            _mags = getMagazineCargo _vehicle;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _index = (_mags select 0) find _item;
                _count = if (_index < 0) then { 0 } else { (_mags select 1) select _index };
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                ["Magazine", _vehicle, _item, _quantity] call fnc_removeCargoGlobal;
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                _vehicle addMagazineCargoGlobal [_item, _quantity];
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in %3.", _crafted, (_itemsOut select 0 select 0) call fnc_getName, _vehicle call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };
};

Crafting_ListboxLoad = {
    lbClear _listbox;

    {
        _index = _listbox lbAdd (_x select 1);
        _listbox lbSetPicture [_index, "custom\crafting\favourite" + (["_none",""] select (_x call Crafting_isFavourite)) + ".paa"];
        _listbox lbSetData [_index, str _x];
    } count Crafting_Items;

    lbSort _listbox;

    for "_i" from 0 to lbSize _listbox - 1 do {
        _listbox lbSetValue [_i, if ((call compile (_listbox lbData _i)) call Crafting_isFavourite) then { _i - 100 } else { _i }];
    };

    lbSortByValue _listbox;
};

Crafting_isFavourite = {
    private ["_favourites","_type","_action"];
    _favourites = profileNamespace getVariable ["CraftingFavourites", []];
    _type = _this select 0;
    _action = _this select 2;
    (_type + "/" + _action) in _favourites
};

 

 

Link to comment
Share on other sites

  • 0

Found this piece of code :

 

	fnc_getName = {
		if (typeName _this == "OBJECT") then { _this = typeOf _this; };

		{
			if (isClass (configFile >> _x >> _this)) exitWith { getText (configFile >> _x >> _this >> "displayName") };
			_this
		} forEach ["CfgVehicles","CfgWeapons","CfgMagazines"];
	};

Where is it going ? ^^

Link to comment
Share on other sites

  • 0

Ok I got my thing to work finally.
No buildable folder needed, and my crafting\init :

 

Spoiler

Crafting_Items = [];
_magTypes = ["PartGeneric","PartWoodPile","ItemSandbag","ItemPlotDeed","ItemDocumentRamp","ItemWoodFloorHalf","ItemWoodFloorQuarter","ItemWoodStairs","ItemWoodWall","ItemWoodWallThird","ItemWoodWallDoor","ItemWoodWallWithDoor","ItemWoodWallGarageDoor","ItemWoodWallLg","ItemWoodWallDoorLg","ItemWoodWallWithDoorLg","ItemCanvas","ItemBurlap","ItemLightBulb","ItemCorrugated","ItemPole","ItemFuelBarrelEmpty","metal_panel_kit","desert_net_kit","forest_net_kit","PartPlankPack","CinderBlocks","PartPlywoodPack","PartWoodLumber","PartWoodPlywood","ItemTentOld","ItemTentDomed","ItemTentDomed2","BagFenceRound_DZ_kit","ItemSandbagLarge","ItemSandbagExLarge"];

_actions = ["Crafting"];
for "_i" from 1 to 7 do { _actions set [count _actions, "Crafting" + str _i]; };

    fnc_getName = {
        if (typeName _this == "OBJECT") then { _this = typeOf _this; };

        {
            if (isClass (configFile >> _x >> _this)) exitWith { getText (configFile >> _x >> _this >> "displayName") };
            _this
        } forEach ["CfgVehicles","CfgWeapons","CfgMagazines"];
    };

{
    _magCfg = configFile >> "CfgMagazines" >> _x;
    _actionsCfg = _magCfg >> "ItemActions";

    for "_i" from 0 to count _actionsCfg - 1 do {
        _actionCfg = _actionsCfg select _i;
        _actionName = configName _actionCfg;

        if (isClass _actionCfg && {_actionName in _actions}) then {
            _text = format ["%1 (%2)", _x call fnc_getName, getText (_actionCfg >> "text")];
            Crafting_Items set [count Crafting_Items, [_x, _text, _actionName]];
        };
    };

} count _magTypes;

Crafting_Load = {
    _dialog = _this select 0;
    _listbox = _dialog displayCtrl 1500;

    call Crafting_ListboxLoad;

    for "_i" from 1 to 10 do { (_dialog displayCtrl 2100) lbAdd str _i; };
    (_dialog displayCtrl 2100) lbSetCurSel 0;

    (_dialog displayCtrl 1600) ctrlEnable false;
};

Crafting_Unload = {
    saveProfileNamespace;
};

Crafting_LBDblClick = {
    _listbox = _this select 0;
    _index = _this select 1;

    _data = call compile (_listbox lbData _index);
    _type = (_data select 0) + "/" + (_data select 2);
    _favourites = profileNamespace getVariable ["CraftingFavourites", []];

    if (_data call Crafting_isFavourite) then {
        _listbox lbSetPicture [_index, "custom\crafting\favourite_none.paa"];
        _favourites = _favourites - [_type];
    } else {
        _listbox lbSetPicture [_index, "custom\crafting\favourite.paa"];
        _favourites = _favourites + [_type];
    };

    profileNamespace setVariable ["CraftingFavourites", _favourites];

    call Crafting_ListboxLoad;
};

Crafting_LBSelChanged = {
    _listbox = _this select 0;
    _index = _this select 1;

    _data = call compile (_listbox lbData _index);
    _type = _data select 0;
    _text = _data select 1;
    _action = _data select 2;

    _config = configFile >> "CfgMagazines" >> _type >> "ItemActions" >> _action;
    
    _config2 = configFile >> "CfgMagazines" >> _type >> "ItemActions" >> _action;
    _arrayToText = {
        private ["_output","_type","_quantity"];
        _output = "";
        {
            if (typeName _x == "ARRAY") then {
                _output = _output + format ["%1 x %2<br/>", _x select 1, (_x select 0) call fnc_getName];
            } else {
                _output = _output + format ["%1<br/>", _x call fnc_getName];
            };
        } count _this;
        _output
    };

    _formatTitle = { parseText format ["<t align='left' size='0.7' color='#00FF40'>%1</t><br/>", _this] };
    _formatText = { parseText format ["<t align='left'>%1</t><br/>", _this] };

    /*_needNear = getArray (_config >> "neednearby") - ["sand","sawmill"];*/
    
    _needNear =     getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> _action >> "neednearby") - ["sand","sawmill"];

    _text = composeText [
        if (count _needNear > 0) then { "REQUIRED NEARBY:" call _formatTitle } else { parseText "" },
        if (count _needNear > 0) then { (_needNear call _arrayToText) call _formatText } else { parseText "" },
        "REQUIRED TOOLS:" call _formatTitle,
        (getArray (_config >> "requiretools") call _arrayToText) call _formatText,
        "ITEMS INPUT:" call _formatTitle,
        (getArray (_config >> "input") call _arrayToText) call _formatText,
        "ITEMS OUTPUT:" call _formatTitle,
        (getArray (_config >> "output") call _arrayToText) call _formatText
    ];

    ((ctrlParent _listbox) displayCtrl 1100) ctrlSetStructuredText _text;
};

Crafting_ButtonClick = {
    _button = _this select 0;
    _dialog = ctrlParent _button;
    _buttons = [_dialog displayCtrl 1600, _dialog displayCtrl 1601, _dialog displayCtrl 1602];

    if (_button in _buttons) exitWith {
        { _x ctrlEnable (_x != _button); } count _buttons;
    };

    _listbox = _dialog displayCtrl 1500;
    _index = lbCurSel _listbox;

    if (_index < 0) exitWith { systemChat "<Crafting> Select an item to craft."; };

    _data = call compile (_listbox lbData _index);
    _config = configFile >> "CfgMagazines" >> _data select 0 >> "ItemActions" >> _data select 2;

    _requiredNear = getArray (_config >> "neednearby") - ["sand","sawmill"];
    _requiredTools = getArray (_config >> "requiretools");
    _itemsIn = getArray (_config >> "input");
    _itemsOut = getArray (_config >> "output");

    _amount = lbCurSel (_dialog displayCtrl 2100) + 1;

    // Inventory
    if (!ctrlEnabled (_buttons select 0)) exitWith {
        _crafted = 0;

        for "_i" from 1 to _amount do {
            _mags = magazines player;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _count = { _x == _item } count _mags;
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                for "_x" from 1 to _quantity do {
                    player removeMagazine _item;
                };
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                for "_x" from 1 to _quantity do {
                    player addMagazine _item;
                };
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in Inventory.", _crafted, (_itemsOut select 0 select 0) call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };

    // Backpack
    if (!ctrlEnabled (_buttons select 1)) exitWith {
        _backpack = unitBackpack player;
        if (isNull _backpack) exitWith { systemChat "<Crafting> You are not wearing a backpack."; };

        _crafted = 0;

        for "_i" from 1 to _amount do {
            _mags = getMagazineCargo _backpack;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _index = (_mags select 0) find _item;
                _count = if (_index < 0) then { 0 } else { (_mags select 1) select _index };
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                ["Magazine", _backpack, _item, _quantity] call fnc_removeCargoGlobal;
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                _backpack addMagazineCargoGlobal [_item, _quantity];
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in %3.", _crafted, (_itemsOut select 0 select 0) call fnc_getName, _backpack call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };

    // Vehicle
    if (!ctrlEnabled (_buttons select 2)) exitWith {
        _vehicle = vehicle player;
        if (_vehicle == player || {driver _vehicle != player}) exitWith { systemChat "<Crafting> You must be in the driver's seat of a vehicle."; };

        _crafted = 0;

        for "_i" from 1 to _amount do {
            _mags = getMagazineCargo _vehicle;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _index = (_mags select 0) find _item;
                _count = if (_index < 0) then { 0 } else { (_mags select 1) select _index };
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                ["Magazine", _vehicle, _item, _quantity] call fnc_removeCargoGlobal;
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                _vehicle addMagazineCargoGlobal [_item, _quantity];
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in %3.", _crafted, (_itemsOut select 0 select 0) call fnc_getName, _vehicle call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };
};

Crafting_ListboxLoad = {
    lbClear _listbox;

    {
        _index = _listbox lbAdd (_x select 1);
        _listbox lbSetPicture [_index, "custom\crafting\favourite" + (["_none",""] select (_x call Crafting_isFavourite)) + ".paa"];
        _listbox lbSetData [_index, str _x];
    } count Crafting_Items;

    lbSort _listbox;

    for "_i" from 0 to lbSize _listbox - 1 do {
        _listbox lbSetValue [_i, if ((call compile (_listbox lbData _i)) call Crafting_isFavourite) then { _i - 100 } else { _i }];
    };

    lbSortByValue _listbox;
};

Crafting_isFavourite = {
    private ["_favourites","_type","_action"];
    _favourites = profileNamespace getVariable ["CraftingFavourites", []];
    _type = _this select 0;
    _action = _this select 2;
    (_type + "/" + _action) in _favourites
};

 

The problem of the correct Tools remain.

Someone to tell me where is the problem ? I can still craft items without any tools if I want...

Thanks

Link to comment
Share on other sites

  • 0

@Assomnia maybe you can make your own.

i made something similar a few time ago you can see through the files :

Spoiler

 

the workshop works with hpp menus and scroll menus....

if u want craft using right click action then here you have a script base: (see lines in red to entry your values)

Spoiler

 private ["_playerPos","_nearhouse","_inventory","_hasitem1","_Playersurvived","_removed","_helperColor","_objectHelper","_objectHelperDir","_objectHelperPos","_canDo", "_pos", "_cnt",
"_location","_dir","_classname","_item","_hasrequireditem","_missing","_hastoolweapon","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_need","_objHupDiff","_needNear","_vehicle","_inVehicle","_requireplot","_objHDiff","_isLandFireDZ","_isTankTrap"];
 
//VARIABLES
_inventory = items player;

//_hasitem1 = ["itemID, amount"]
_hasitem1 = [["ItemWoodWall",4], "ItemWoodFloor"] call player_checkItems;

 


////////////////////////FIND NEAREST HOUSES/OBJETS AND PREVENT SAME  BUILD
_playerPos = getPosATL player;
_nearhouse = count nearestObjects [_playerPos, ["MAP_deutshe_mini","MAP_Mil_Mil_Guardhouse","MAP_bouda2_vnitrek"], 45] > 0;
 
if (_nearhouse) exitWith {
    [format["<t align='center' size='0.75' color='#ff5200'>%1 You cannot build another house in this plot area.</t>",(name player)],0,0,2,2] spawn BIS_fnc_dynamicText;
        };

/////////////////////////////////////////////     

//CHECK ITEMS ///

if (!_hasitem1) exitWith {cutText
[format["Needs 4xItemWoodWall and 1xFloorCelling4/4"], "PLAIN DOWN"];};
//////////////////////////


//Proceed if check succes
if (_hasitem1) then {

 

 

// objet class
 
_classname = "MAP_bouda2_vnitrek"; //OBJET ID TO CRAFT
 
//objet class
 
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

//snap vars -- temporary fix for errors so variables.sqf can be skipped
if (isNil "snapProVariables") then {
    if (isNil "DZE_snapExtraRange") then {
        DZE_snapExtraRange = 0;
    };
    if (isNil "DZE_checkNearbyRadius") then {
        DZE_checkNearbyRadius = 30;
    };
    s_player_toggleSnap = -1;
    s_player_toggleSnapSelect = -1;
    s_player_toggleSnapSelectPoint=[];
    snapActions = -1;
    snapGizmos = [];
    snapGizmosNearby = [];
    snapProVariables = true; // will skip this statement from now on.
};
// snap vars
// disallow building if too many objects are found within (30m by default) add DZE_checkNearbyRadius = 30; to your init.sqf to change
_pos = [player] call FNC_GetPos;
_cnt = count (_pos nearObjects ["All",DZE_checkNearbyRadius]);
 if (_cnt >= DZE_BuildingLimit) exitWith { //end script if too many objects nearby
     DZE_ActionInProgress = false;
     cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"];
 };

 
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_isWater =  dayz_isSwimming;
_cancel = false;
_reason = "";
_canBuildOnPlot = false;
 
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
 
helperDetach = false;
_canDo = (!r_drag_sqf and !r_player_unconscious);
 
DZE_Q = false;
DZE_Z = false;
 
DZE_Q_alt = false;
DZE_Z_alt = false;
 
DZE_Q_ctrl = false;
DZE_Z_ctrl = false;
 
DZE_5 = false;
DZE_4 = false;
DZE_6 = false;
DZE_F = false;
 
DZE_cancelBuilding = false;
 
call gear_ui_init;
closeDialog 1;
 
if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];};
if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];};
if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];};
if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];};
 
_item = _this;
 
// Need Near Requirements
_abort = false;
_distance = 3;
_reason = "";
 
 
if(_abort) exitWith {
cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"];
DZE_ActionInProgress = false;
};
 

_classnametmp = _classname;
_require =  getArray (configFile >> "ItemHemp" >> _this >> "ItemActions" >> "Build" >> "require");
_text =  getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");
 
_lockable = 0;
 
_requireplot = DZE_requireplot;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
};
 
_isAllowedUnderGround = 1;
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
_isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
};
 
_offset =  getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
if((count _offset) <= 0) then {
_offset = [0,7,2];
};
 
_isPole = (_classname == "Plastic_Pole_EP1_DZ");
_isLandFireDZ = (_classname == "Land_Fire_DZ");
 
_distance = DZE_PlotPole select 0;
_needText = localize "str_epoch_player_246";
 
if(_isPole) then {
_distance = DZE_PlotPole select 1;
};
 
// check for near plot
_findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance];
_findNearestPole = [];
 
{
if (alive _x) then {
_findNearestPole set [(count _findNearestPole),_x];
};
} foreach _findNearestPoles;
 
_IsNearPlot = count (_findNearestPole);
 
// If item is plot pole and another one exists within 45m
if(_isPole and _IsNearPlot > 0) exitWith {  DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; };
 
if(_IsNearPlot == 0) then {
 
// Allow building of plot
_canBuildOnPlot = false;
 
} else {
// Since there are plots nearby we check for ownership and then for friend status
 
// check nearby plots ownership and then for friend status
_nearestPole = _findNearestPole select 0;
 
// Find owner
_ownerID = _nearestPole getVariable["CharacterID","0"];
 
// diag_log format["DEBUG BUILDING: %1 = %2", dayz_characterID, _ownerID];
 
// check if friendly to owner
if(dayz_characterID == _ownerID) then {  //Keep ownership
// owner can build anything within his plot except other plots
if(!_isPole) then {
_canBuildOnPlot = true;
};
 
} else {
// disallow building plot
_canBuildOnPlot = false;
};
};
 
// _message
if(!_canBuildOnPlot) exitWith {  DZE_ActionInProgress = false; cutText [format["Thers a plot in here or needs a plot"], "PLAIN DOWN",3]; };
 
_missing = "";
 
_location = [0,0,0];
_isOk = true;
 
// get inital players position
_location1 = [player] call FNC_GetPos;
_dir = getDir player;
 
// if ghost preview available use that instead
if (_ghost != "") then {
_classname = _ghost;
};
 
_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
 
//Build gizmo
    _objectHelper = "Sign_sphere10cm_EP1" createVehicle _location;
    _helperColor = "#(argb,8,8,3)color(0,0,0,0,ca)";
    _objectHelper setobjecttexture [0,_helperColor];
    _objectHelper attachTo [player,_offset];
    _object attachTo [_objectHelper,[0,0,0]];
    _position = [_objectHelper] call FNC_GetPos;
 
_objHDiff = 0;
 
while {_isOk} do {
 
_zheightchanged = false;
_zheightdirection = "";
_rotate = false;
 
if (DZE_Q) then {
DZE_Q = false;
_zheightdirection = "up";
_zheightchanged = true;
};
if (DZE_Z) then {
DZE_Z = false;
_zheightdirection = "down";
_zheightchanged = true;
};
if (DZE_Q_alt) then {
DZE_Q_alt = false;
_zheightdirection = "up_alt";
_zheightchanged = true;
};
if (DZE_Z_alt) then {
DZE_Z_alt = false;
_zheightdirection = "down_alt";
_zheightchanged = true;
};
if (DZE_Q_ctrl) then {
DZE_Q_ctrl = false;
_zheightdirection = "up_ctrl";
_zheightchanged = true;
};
if (DZE_Z_ctrl) then {
DZE_Z_ctrl = false;
_zheightdirection = "down_ctrl";
_zheightchanged = true;
};
if (DZE_4) then {
_rotate = true;
DZE_4 = false;
_dir = -45;
};
if (DZE_6) then {
_rotate = true;
DZE_6 = false;
_dir = 45;
};
 
if (DZE_F and _canDo) then {    
            if (helperDetach) then {
                _objectHelperDir = getDir _objectHelper;
                _objectHelper attachTo [player];
                _objectHelper setDir _objectHelperDir-(getDir player);
                helperDetach = false;
            } else {
                _objectHelperDir = getDir _objectHelper;
                detach _objectHelper;
                [_objectHelper]    call FNC_GetSetPos;
                _objectHelper setVelocity [0,0,0]; //fix sliding glitch
                helperDetach = true;
            };
            DZE_F = false;
        };
 
if(_rotate) then {
            if (helperDetach) then {
                _objectHelperDir = getDir _objectHelper;
                _objectHelper setDir _objectHelperDir+_dir;
                [_objectHelper]    call FNC_GetSetPos;
            } else {
                detach _objectHelper;
                _objectHelperDir = getDir _objectHelper;
                _objectHelper setDir _objectHelperDir+_dir;
                [_objectHelper]    call FNC_GetSetPos;
                _objectHelperDir = getDir _objectHelper;
                _objectHelper attachTo [player];
                _objectHelper setDir _objectHelperDir-(getDir player);        
            };

        };
 
if(_zheightchanged) then {
            if (!helperDetach) then {
                detach _objectHelper;
                _objectHelperDir = getDir _objectHelper;
            };

            _position = [_objectHelper] call FNC_GetPos;

            if(_zheightdirection == "up") then {
                _position set [2,((_position select 2)+0.1)];
                _objHDiff = _objHDiff + 0.1;
            };
            if(_zheightdirection == "down") then {
                _position set [2,((_position select 2)-0.1)];
                _objHDiff = _objHDiff - 0.1;
            };

            if(_zheightdirection == "up_alt") then {
                _position set [2,((_position select 2)+1)];
                _objHDiff = _objHDiff + 1;
            };
            if(_zheightdirection == "down_alt") then {
                _position set [2,((_position select 2)-1)];
                _objHDiff = _objHDiff - 1;
            };

            if(_zheightdirection == "up_ctrl") then {
                _position set [2,((_position select 2)+0.01)];
                _objHDiff = _objHDiff + 0.01;
            };
            if(_zheightdirection == "down_ctrl") then {
                _position set [2,((_position select 2)-0.01)];
                _objHDiff = _objHDiff - 0.01;
            };

            if((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
                _position set [2,0];
            };

            if (surfaceIsWater _position) then {
                _objectHelper setPosASL _position;
            } else {
                _objectHelper setPosATL _position;
            };

            if (!helperDetach) then {
            _objectHelper attachTo [player];
            _objectHelper setDir _objectHelperDir-(getDir player);
            };
        };

        sleep 0.5;
 
_location2 = [player] call FNC_GetPos;
        _objectHelperPos = [_objectHelper] call FNC_GetPos;

        if(DZE_5) exitWith {
            _isOk = false;
            _position = [_object] call FNC_GetPos;
            detach _object;
            _dir = getDir _object;
            deleteVehicle _object;
            detach _objectHelper;
            deleteVehicle _objectHelper;
        };
 
if(_location1 distance _location2 > 10) exitWith {
            _isOk = false;
            _cancel = true;
            _reason = "You've moved to far away from where you started building (within 10 meters)";
            detach _object;
            deleteVehicle _object;
            detach _objectHelper;
            deleteVehicle _objectHelper;
        };
        
        if(_location1 distance _objectHelperPos > 10) exitWith {
            _isOk = false;
            _cancel = true;
            _reason = "Object is placed to far away from where you started building (within 10 meters)";
            detach _object;
            deleteVehicle _object;
            detach _objectHelper;
            deleteVehicle _objectHelper;
        };

        if(abs(_objHDiff) > 10) exitWith {
            _isOk = false;
            _cancel = true;
            _reason = "Cannot move up or down more than 10 meters";
            detach _object;
            deleteVehicle _object;
            detach _objectHelper;
            deleteVehicle _objectHelper;
        };
 
if (player getVariable["combattimeout", 0] >= time) exitWith {
            _isOk = false;
            _cancel = true;
            _reason = (localize "str_epoch_player_43");
            detach _object;
            deleteVehicle _object;
            detach _objectHelper;
            deleteVehicle _objectHelper;
        };

        if (DZE_cancelBuilding) exitWith {
            _isOk = false;
            _cancel = true;
            _reason = "Cancelled building.";
            detach _object;
            deleteVehicle _object;
            detach _objectHelper;
            deleteVehicle _objectHelper;
        };
    };
 
//No building on roads unless toggled
if (!DZE_BuildOnRoads) then {
if (isOnRoad _position) then { _cancel = true; _reason = "Cannot build on a road."; };
};
 
// No building in trader zones
if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };
 
if(!_cancel) then {
 
_classname = _classnametmp;
 
// Start Build
_tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
 
_tmpbuilt setdir _dir;
 
// Get position based on object
_location = _position;
 
if((_isAllowedUnderGround == 0) and ((_location select 2) < 0)) then {
_location set [2,0];
};
 
_tmpbuilt setPosATL _location;
 
 
cutText [format[(localize "str_epoch_player_138"),_text], "PLAIN DOWN"];
 
_limit = 1;
 
if (DZE_StaticConstructionCount > 0) then {
_limit = DZE_StaticConstructionCount;
}
else {
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
_limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
};
};
 
player playActionNow "Medic";
[player,"repair",0,false,10] call dayz_zombieSpeak;
[player,10,true,(getPosATL player)] spawn player_alertZombies;
sleep 3;
_removed = [["CinderBlocks",2], "PartWoodLumber"] call player_removeItems;
cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];
 
if (_isPole) then {
[] spawn player_plotPreview;
};
 
_tmpbuilt setVariable ["OEMPos",_location,true];
 
_tmpbuilt setVariable ["CharacterID",dayz_characterID,true];
 
_charID = dayz_characterID;
_activatingPlayer = player;
 
PVDZE_veh_Publish = [_tmpbuilt,[_dir,_location],_classname,true,_charid,_activatingPlayer];
publicVariableServer  "PVDZE_veh_Publish";
 
// MESSAGE HERE///////////////
[format["<t align='center' size='0.50' color='#FFCC00'>>Nice! A Small House Survivor!<</t>",_Playersurvived],0,0,2,2] spawn BIS_fnc_dynamicText;  
//cutText [format["Nice House Survivor!"], "PLAIN DOWN",3];
 
////////////////////////////////////////////
 
player reveal _tmpbuilt;
DZE_ActionInProgress = false;
 
} else {
cutText [format[(localize "str_epoch_player_47"),_text,_reason], "PLAIN DOWN"];
DZE_ActionInProgress = false;
};
 
DZE_ActionInProgress = false;

};
 

or more easy use the mudzarelli mod:

Spoiler

 

 

Link to comment
Share on other sites

  • 0

Hello Juan !
Thanks for your answer. Unfortunately I'm very bad in coding stuff myself :/. I have to look on your tutorial explaining the base of scripting
I already have the Deploy anything script.
In addition to that I just wanted this Craft Menu to work  to save time when assembling all the materials to create something. Skip the animation thing + having the recipe in front of the player to see what's missing. Once build it goes directly in inventory of backpack or vehicle. Its very handy.
Even tho your workshop looks cool and I will try it out, I'd like this menu to work properly.
The script somehow don't care if I have the tools or not, can you help me to find the mistake in the code ?
Also, do you know from where it get's the recipes ? And if we can add or change them ? Dayz_server I assume but not sure
Thanks
 

Edited by Assomnia
UPD
Link to comment
Share on other sites

  • 0
10 hours ago, Assomnia said:

Hello Juan !
Thanks for your answer. Unfortunately I'm very bad in coding stuff myself :/. I have to look on your tutorial explaining the base of scripting
I already have the Deploy anything script.
In addition to that I just wanted this Craft Menu to work  to save time when assembling all the materials to create something. Skip the animation thing + having the recipe in front of the player to see what's missing. Once build it goes directly in inventory of backpack or vehicle. Its very handy.
Even tho your workshop looks cool and I will try it out, I'd like this menu to work properly.
The script somehow don't care if I have the tools or not, can you help me to find the mistake in the code ?
Also, do you know from where it get's the recipes ? And if we can add or change them ? Dayz_server I assume but not sure
Thanks
 

see im not sure but this part do the check about items to craft and remove the materiales.

for "_i" from 1 to _amount do {
            _mags = magazines player;

            _gotRequired = {
                _item = _x select 0;
                _quantity = _x select 1;
                _count = { _x == _item } count _mags;
                _count >= _quantity
            } count _itemsIn;

            if (_gotRequired < count _itemsIn) exitWith {};

            {
                _item = _x select 0;
                _quantity = _x select 1;
                for "_x" from 1 to _quantity do {
                    player removeMagazine _item;
                };
            } count _itemsIn;

            {
                _item = _x select 0;
                _quantity = _x select 1;
                for "_x" from 1 to _quantity do {
                    player addMagazine _item;
                };
            } count _itemsOut;

            _crafted = _crafted + 1;
        };

        if (_crafted > 0) then {
            systemChat format ["<Crafting> Crafted %1 x %2 in Inventory.", _crafted, (_itemsOut select 0 select 0) call fnc_getName];
        } else {
            systemChat "<Crafting> Insufficient items.";
        };
    };

heres the epoch original player_craftItems.sqf

Spoiler

/*
    DayZ Epoch Crafting 0.3
    Made for DayZ Epoch && Unleashed by [VB]AWOL please ask permission to use/edit/distrubute email [email protected].
    Thanks to thevisad for help with the spawn call fixes.

USAGE EXAMPLE:
class ItemActions
{
    class Crafting
    {
        text = "Craft Tent";
        script = ";['Crafting','CfgMagazines', _id] spawn player_craftItem;"; // [Class of itemaction,CfgMagazines || CfgWeapons, item]
        neednearby[] = {"workshop","fire"};
        requiretools[] = {"ItemToolbox","ItemKnife"}; // (cfgweapons only)
        output[] = {{"ItemTent",1}}; // (CfgMagazines, qty)
        input[] = {{"ItemCanvas",2},{"ItemPole",2}}; // (CfgMagazines, qty)
        inputstrict = true; // (CfgMagazines input without inheritsFrom) Optional
        inputweapons[] = {"ItemToolbox"}; // consume toolbox (cfgweapons only)
        outputweapons[] = {"ItemToolbox"}; // return toolbox (cfgweapons only)
    };
};
*/
private ["_tradeComplete","_onLadder","_canDo","_selectedRecipeOutput","_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_itemOut","_countOut","_started","_finished","_animState","_isMedic","_removed","_tobe_removed_total","_textCreate","_textMissing","_selectedRecipeInput","_selectedRecipeInputStrict","_num_removed","_removed_total","_temp_removed_array","_abort","_waterLevel","_waterLevel_lowest","_reason","_isNear","_missingTools","_hastoolweapon","_selectedRecipeTools","_distance","_crafting","_needNear","_item","_baseClass","_num_removed_weapons","_outputWeapons","_inputWeapons","_randomOutput","_craft_doLoop","_selectedWeapon","_selectedMag","_sfx"];

if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_63") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

// This is used to find correct recipe based what itemaction was click allows multiple recipes per item.
_crafting = _this select 0;

// This tells the script what type of item we are clicking on
_baseClass = _this select 1;

_item =  _this select 2;

_abort = false;
_distance = 3;
_reason = "";
_waterLevel = 0;
_outputWeapons = [];
_selectedRecipeOutput = [];
_onLadder =    (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf && !r_player_unconscious && !_onLadder);

// Need Near Requirements
_needNear = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "neednearby");
if("fire" in _needNear) then {
    _isNear = {inflamed _x} count (getPosATL player nearObjects _distance);
    if(_isNear == 0) then {
        _abort = true;
        _reason = "fire";
    };
};
if("workshop" in _needNear) then {
    _isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
    if(_isNear == 0) then {
        _abort = true;
        _reason = "workshop";
    };
};
if(_abort) exitWith {
    cutText [format[(localize "str_epoch_player_149"),_reason,_distance], "PLAIN DOWN"];
    DZE_ActionInProgress = false;
};

// diag_log format["Checking for fire: %1", _isFireNear];

if (_canDo) then {

    _selectedRecipeTools = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "requiretools");
    _selectedRecipeOutput = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "output");
    _selectedRecipeInput = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "input");
    _selectedRecipeInputStrict = if ((isNumber (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "inputstrict")) && (getNumber (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "inputstrict") > 0)) then {true} else {false};
    _outputWeapons = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "outputweapons");
    _inputWeapons = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "inputweapons");

    _sfx = getText(configFile >> _baseClass >> _item >> "sfx");
    if(_sfx == "") then {
        _sfx = "repair";
    };

    _randomOutput = 0;
    if(isNumber (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "randomOutput")) then {
        _randomOutput = getNumber(configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "randomOutput");
    };

    _craft_doLoop = true;
    _tradeComplete = 0;

    while {_craft_doLoop} do {

        _temp_removed_array = [];

        _missing = "";
        _missingTools = false;
        {
            _hastoolweapon = _x in weapons player;
            if(!_hastoolweapon) exitWith { _craft_doLoop = false; _missingTools = true; _missing = _x; };
        } forEach _selectedRecipeTools;

        if(!_missingTools) then {


            // Dry run to see if all parts are available.
            _proceed = true;
            if (count _selectedRecipeInput > 0) then {
                {
                    _itemIn = _x select 0;
                    _countIn = _x select 1;

                    _qty = { (_x == _itemIn) || (!_selectedRecipeInputStrict && configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;

                    if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };

                } forEach _selectedRecipeInput;
            };

            // If all parts proceed
            if (_proceed) then {

                cutText [(localize "str_epoch_player_62"), "PLAIN DOWN"];

                [1,1] call dayz_HungerThirst;
                player playActionNow "Medic";

                [player,_sfx,0,false] call dayz_zombieSpeak;
                [player,50,true,(getPosATL player)] spawn player_alertZombies;

                r_interrupt = false;
                _animState = animationState player;
                r_doLoop = true;
                _started = false;
                _finished = false;

                while {r_doLoop} do {
                    _animState = animationState player;
                    _isMedic = ["medic",_animState] call fnc_inString;
                    if (_isMedic) then {
                        _started = true;
                    };
                    if (_started && !_isMedic) then {
                        r_doLoop = false;
                        _finished = true;
                    };
                    if (r_interrupt) then {
                        r_doLoop = false;
                    };
                    sleep 0.1;
                };
                r_doLoop = false;

                if (_finished) then {

                    _removed_total = 0; // count total of removed items
                    _tobe_removed_total = 0; // count total of all to be removed items
                    _waterLevel_lowest = 0; // find the lowest _waterLevel
                    // Take items
                    {
                        _removed = 0;
                        _itemIn = _x select 0;
                        _countIn = _x select 1;
                        // diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
                        _tobe_removed_total = _tobe_removed_total + _countIn;

                        // Preselect the item
                        {
                            _configParent = configName(inheritsFrom(configFile >> "cfgMagazines" >> _x));
                            if ((_x == _itemIn) || (!_selectedRecipeInputStrict && _configParent == _itemIn)) then {
                                // Get lowest waterlevel
                                if ((_x == "ItemWaterbottle") ||( _configParent == "ItemWaterbottle")) then {
                                    _waterLevel = floor((getNumber(configFile >> "CfgMagazines" >> _x >> "wateroz")) - 1);
                                    if (_waterLevel_lowest == 0 || _waterLevel < _waterLevel_lowest) then {
                                        _waterLevel_lowest = _waterLevel;
                                    };
                                };
                            };
                        } forEach magazines player;

                        {
                            _configParent = configName(inheritsFrom(configFile >> "cfgMagazines" >> _x));
                            if( (_removed < _countIn) && ((_x == _itemIn) || (!_selectedRecipeInputStrict && _configParent == _itemIn))) then {
                                if ((_waterLevel_lowest == 0) || ((_waterLevel_lowest > 0) && (getNumber(configFile >> "CfgMagazines" >> _x >> "wateroz") == _waterLevel_lowest))) then {
                                    _num_removed = ([player,_x] call BIS_fnc_invRemove);
                                }
                                else {
                                    _num_removed = 0;
                                };
                                _removed = _removed + _num_removed;
                                _removed_total = _removed_total + _num_removed;
                                if(_num_removed >= 1) then {
                                    //diag_log format["debug remove: %1 of: %2", _configParent, _x];
                                    if (_x == "ItemWaterbottle" || _configParent == "ItemWaterbottle") then {
                                        _waterLevel = floor((getNumber(configFile >> "CfgMagazines" >> _x >> "wateroz")) - 1);
                                    };
                                    _temp_removed_array set [count _temp_removed_array,_x];
                                };
                            };
                        } forEach magazines player;

                    } forEach _selectedRecipeInput;

                    //diag_log format["removed: %1 of: %2", _removed, _tobe_removed_total];

                    // Only proceed if all parts were removed successfully
                    if(_removed_total == _tobe_removed_total) then {
                        _num_removed_weapons = 0;
                        {
                            _num_removed_weapons = _num_removed_weapons + ([player,_x] call BIS_fnc_invRemove);
                        } forEach _inputWeapons;
                        if (_num_removed_weapons == (count _inputWeapons)) then {
                            if(_randomOutput == 1) then {
                                if (!isNil "_outputWeapons" && count _outputWeapons > 0) then {
                                    _selectedWeapon = _outputWeapons call BIS_fnc_selectRandom;
                                    _outputWeapons = [_selectedWeapon];
                                };
                                if (!isNil "_selectedRecipeOutput" && count _selectedRecipeOutput > 0) then {
                                    _selectedMag = _selectedRecipeOutput call BIS_fnc_selectRandom;
                                    _selectedRecipeOutput = [_selectedMag];
                                };
                                // exit loop
                                _craft_doLoop = false;
                            };
                            {
                                player addWeapon _x;
                            } forEach _outputWeapons;
                            {

                                _itemOut = _x select 0;
                                _countOut = _x select 1;

                                if (_itemOut == "ItemWaterbottleUnfilled") then {

                                    if (_waterLevel > 0) then {
                                        _itemOut = format["ItemWaterbottle%1oz",_waterLevel];
                                    };

                                };

                                // diag_log format["Checking for water level: %1", _waterLevel];

                                for "_x" from 1 to _countOut do {
                                    player addMagazine _itemOut;
                                };

                                _textCreate = getText(configFile >> "CfgMagazines" >> _itemOut >> "displayName");

                                // Add crafted item
                                cutText [format[(localize "str_epoch_player_150"),_textCreate,_countOut], "PLAIN DOWN"];
                                // sleep here
                                sleep 1;

                            } forEach _selectedRecipeOutput;

                            _tradeComplete = _tradeComplete+1;
                        };

                    } else {
                        // Refund parts since we failed
                        {player addMagazine _x; } forEach _temp_removed_array;

                        cutText [format[(localize "str_epoch_player_151"),_removed_total,_tobe_removed_total], "PLAIN DOWN"];
                    };

                } else {
                    r_interrupt = false;
                    if (vehicle player == player) then {
                        [objNull, player, rSwitchMove,""] call RE;
                        player playActionNow "stop";
                    };
                    cutText [(localize "str_epoch_player_64"), "PLAIN DOWN"];
                    _craft_doLoop = false;
                };

            } else {
                _textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
                cutText [format[(localize "str_epoch_player_152"),_missingQty, _textMissing,_tradeComplete], "PLAIN DOWN"];
                _craft_doLoop = false;
            };
        } else {
            _textMissing = getText(configFile >> "CfgWeapons" >> _missing >> "displayName");
            cutText [format[(localize "STR_EPOCH_PLAYER_137"),_textMissing], "PLAIN DOWN"];
            _craft_doLoop = false;
        };
    };
} else {
    cutText [(localize "str_epoch_player_64"), "PLAIN DOWN"];
};
DZE_ActionInProgress = false;

 

Link to comment
Share on other sites

  • 0

but i still thinking is much easier make your own :D

for example if u only wanna save time in craft actions.

i write it for craft clothes in a dress bench... just try to replace by your items required and items out.

Spoiler

private ["_inventory","_hastool","_hasitems","_playerPos","_nearRestr","_removed","_brokeChance"];

_inventory = items player;
_hastool = "ItemToolbox" in _inventory;//put any other tool if u want

//_hasitem variable:
//change by your items required//the number is equal to amount of same item
//you can add more or less the sctructure is:
//_hasitems = [["ItemID",1],["ItemID",4],[ItemID",2],[ItemID",1]] call player_checkItems;

_hasitems = [["ItemTrashRazor",1],["ItemBandage",4]] call player_checkItems;
_playerPos = getPosATL player;

//_nearrestr variable: this is used in case u need a workbench or plot pole to craft the item.If u dont wanna use it delete the whole line //bellow.

_nearRestr = count nearestObjects [_playerPos, ["MAP_office_table_a"], 15] > 0;//change "MAP_office_table_a" by your own
//////////////////////


_brokeChance = round(random 10);//chance to broke the item


/////////////////if u dont wanna use _nearRest variable delete this
if !(_nearRestr) exitWith {
cutText [format["Needs be near of YOUR OBJET CAN BE A PLOT POLE"], "PLAIN DOWN"];  
    };
//////////////////////////////

    
if !(_hastool) exitWith {
    cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];
};

if !(_hasitems) exitWith {
    cutText [format["Needs 1xRazor & 4xBandages."], "PLAIN DOWN"];///change the text by your own items
};


///////if u dont wanna use _nearRestr variable remove this part from bellow: "_nearRestr && " so its looks "if (_hastool && _hasitems) //then {"
if (_nearRestr && _hastool && _hasitems) then {
player playActionNow "PutDown";
[player,"repair",0,false,10] call dayz_zombieSpeak;
[player,10,true,(getPosATL player)] spawn player_alertZombies;
sleep 1;


if (_brokeChance < 2) then {r_player_infected = true;
    player removeMagazine "ItemTrashRazor";//remove the item broke
        cutText [format["%1, you broke your Razor",name player], "PLAIN DOWN"];
    };
    
    
_removed = [["ItemBandage",4]] call player_removeItems;//Remove the items used to craft


player addMagazine "Skin_FR_Rodriguez_DZ";//Add the new item
sleep 1;
titleText ["Craft your own clothes!!!", "PLAIN DOWN"];titleFadeOut 5;//Exit text.
};

so you can use this base for made all you want to craft.

 

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...