[WIP/RELEASE] Client Sided Crafting Menu

Discussion in 'Script/Addon releases' started by Inkko, Aug 24, 2014.

  1. Inkko

    Inkko Valued Member!

    Joined:
    Jan 12, 2013
    Messages:
    657
    Likes Received:
    76
    Client Sided Crafting
    v.01a


    This moves over the built in crafting system in DayZ 1.8.1 (works with 1.8.0.3 as well) and allows you to modify, add, or remove recipes from the built in crafting system.
    Requirements (PBO Manager and Notepad ++ recommended)

    • Moderate = Orange >10 < 30 (may take longer if you decide to create your own recipes)


    Installation Steps:

    If you have a custom compiles you can skip to 6.

    1. In your mission folder open init.sqf and find this:

    Code:
    call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";
    And change it to:

    Code:
    call compile preprocessFileLineNumbers "custom\compiles.sqf";
    2. Create a new folder in your mission pbo called custom.

    3. Unpack your local dazy_code.pbo and find the compiles.sqf (located in the init folder).

    4. Copy and paste the compiles.sqf to your mission pbo into the new custom folder you created.

    **5. If you do not have your dayz_code.pbo unpacked do so. Find these 3 files and copy them player_craftitemGUI.sqf (located in actions folder), player_checkRecipe.sqf (located in actions folder), fn_updateCraftUI.sqf (compiles folder),and CfgCrafting folder (located in Configs folder).
    **Step was updated, I forgot a portion.

    6. Paste all the files into your mission pbo in the custom folder.

    **7. Open up your custom compiles.sqf and find this:

    Code:
    fn_updateCraftUI = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_updateCraftUI.sqf";
    
    player_craftItemGUI = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_craftItemGUI.sqf";
    
    player_checkRecipe = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_checkRecipe.sqf";
    Change it to:

    Code:
    fn_updateCraftUI = compile preprocessFileLineNumbers "custom\fn_updateCraftUI.sqf";
    
    player_craftItemGUI = compile preprocessFileLineNumbers “custom\player_craftItemGUI.sqf";
    
    player_checkRecipe = compile preprocessFileLineNumbers “custom\player_checkRecipe.sqf";
    ** Step was updated, I forgot a portion.

    ^8. Open up fn_updateCraftUI.sqf and find this chunk of code:
    Code:
    _config = configFile >> "CfgCrafting";
    Change it to this:

    Code:
    _config = missionconfigFile >> "CfgCrafting";
    ^ this is a new step that was added
    9. Open your description.ext and at the top add this:


    Code:
    #include "custom\CfgCrafting\CfgCrafting.hpp"

    10. Open up player_checkRecipe.sqf and look for this:

    Code:
    _config = configFile >> "CfgCrafting";

    And change it to this:

    Code:
    _config = missionconfigFile >> "CfgCrafting";
    Once this step is completed you now have the crafting system mission sided.




    Additional Instructions:

    If you wish to modify current recipes, locate the recipe and change it how you desire.

    If you wish to remove recipes, open up CfgCrafting.hpp and comment out the lines (//) or delete the line entirely.

    If you wish to create a new recipe, open up CfgCrafting.hpp and add a new #include. The order it will show up in the crafting menu is determined on where it is included in the CfgCrafting.hpp.
    **If you want to create vehicles that can be crafted you need to change something in player_craftitemGUI.sqf**

    For Vehicle craftables look at this spoiler:

    For vehicle crafting in player_craftitemGUI.sqf find this:
    Code:
    {
                            switch (_selection) do {
                                    case "CfgWeapons":
                                    {
                                        player addWeapon _item;
                                    };
                                    case "CfgMagazines":
                                    {
                                        player addMagazine _item;
                                    };
                                    case "CfgVehicles":
                                    {
                                        player addBackpack _item;
                                    };
                                };
    
    and change it to this:
    Code:
    switch (_selection) do {
                                    case "CfgWeapons":
                                    {
                                        player addWeapon _item;
                                    };
                                    case "CfgMagazines":
                                    {
                                        player addMagazine _item;
                                    };
                                    case "CfgVehicles":
                                    {
                                    _mypos = getposATL player;
                                    _dir = getdir player;
                                    _mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
                                    _veh = createVehicle [_item, _mypos,[],0,"CAN_COLLIDE"];
                                    _veh setposATL _mypos;
                                    _veh setDir _dir;
                                    _veh setVariable ["Mission",1,true];
                                    _veh setfuel 0.2;
                                    cutText [format["Warning: '%1' will not save after server restart!",_itemName,3], "PLAIN DOWN"];
                                   };
                                };
    
    I have not set it up to save to the database and this will effect the craftable backpack. There needs to be a check added for if its a vehicle and I need to look into adding an option to save them to the database.

    EX:
    If you wish to create a craftable bike, in CfgCrafting.hpp near the end you could add #include "Recipes\Other\Bike.hpp"


    Then in the folder Other (custom\CfgCrafting\Recipes\Other) create a new file named Bike.hpp.

    The file should be setup as so:
    Code:
    class Bike : Recipe {
    
      displayName = Bike;
    
      descriptionShort = Bike;
    
      input[] =
    
      {
    
      {"PartGeneric","CfgMagazines",1}
    
      };
    
      output[] =
    
      {
    
      {"Old_bike_TK_INS_EP1","CfgVehicles",1}
    
      };
    
      required[] =
    
      {
    
      {"ItemToolbox","CfgWeapons",1}
    
      };
    
    };

    Other examples of custom craftables:
    This recipe has 2 variations in it:
    Code:
    class M9_to : Recipe {
        displayName = "M9 to M9SD ammo";
        input[] =
        {
            {"15Rnd_9x19_M9","CfgMagazines",1}
        };
        output[] =
        {
            {"15Rnd_9x19_M9SD","CfgMagazines",1}
        };
        required[] =
        {
        };
    };
    
    class M9SD_to : Recipe {
        displayName = "M9SD to M9 ammo";
        input[] =
        {
            {"15Rnd_9x19_M9SD","CfgMagazines",1}
        };
        output[] =
        {
            {"15Rnd_9x19_M9","CfgMagazines",1}
        };
        required[] =
        {
        };
    };
    
    
    This recipe has 2 different variations in it:
    Code:
    class Stanag_to : Recipe {
        displayName = "Stanag to StanagSD";
        input[] =
        {
            {"30Rnd_556x45_Stanag","CfgMagazines",1}
        };
        output[] =
        {
            {"30Rnd_556x45_StanagSD","CfgMagazines",1}
        };
        required[] =
        {
        };
    };
    
    class StanagSD_to : Recipe {
        displayName = "StanagSD to Stanag";
        input[] =
        {
            {"30Rnd_556x45_StanagSD","CfgMagazines",1}
        };
        output[] =
        {
            {"30Rnd_556x45_Stanag","CfgMagazines",1}
        };
        required[] =
        {
        };
    };
    
    
    Code:
    class NVG_Craft : Recipe {
        displayName = "NVGS";
        input[] =
        {
            {"Binocular","CfgWeapons",1},
            {"equip_rail_screws","CfgMagazines",1} //Don't think this item is available ingame unless your force it in via custom loot tables. Change this is you want to use this recipe.
        };
        output[] =
        {
            {"NVGoggles","CfgWeapons",1}
        };
        required[] =
        {
           {"ItemToolbox","CfgWeapons",1}
        };
    };
    

    Credit goes where it should, all files came from dayz_code. Any recipes I guess would go to the creator?

    If you have any additions or improvements on this script please post them, if you have any recipes you'd like to share please share them.

    [​IMG]

    Discussion: http://opendayz.net/threads/mission-sided-crafting-menu-1-8-1.20773/

    Here is what my files look like, please note I have my files setup differently then the tutorial:
    https://www.dropbox.com/sh/95y5pafiz6kz42x/AACYRDk7PdVohWHjM07KgFbra?dl=0
     
    Last edited: Aug 30, 2014
    MDark and Stuff and Junk like this.
  2. Inkko

    Inkko Valued Member!

    Joined:
    Jan 12, 2013
    Messages:
    657
    Likes Received:
    76
    Updated files for 1.8.6.1 and includes a fix for logs to planks and planks to wood pile.

    Installation is the same as above. (Unless I missed something again...)

    https://www.dropbox.com/sh/g0b3z681tzbt5ph/AACaJkHx6yyLTQlmDox6e72qa?dl=0

    *Note: player_craftItem.sqf is only for right click fix for logs, planks, and wood.

    Installation made easy (Requires custom compiles.sqf):

    Download the dayz_code folder from the link above and put it in the main directory of your mission folder.

    open up your compiles.sqf

    Find this in your compiles.sqf:
    Code:
    //Crafting
        fn_updateCraftUI = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_updateCraftUI.sqf";
        player_craftItem = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_craftItem.sqf";
        player_craftItemGUI = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_craftItemGUI.sqf";
        player_checkRecipe = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_checkRecipe.sqf";
    

    and change to this (remove the \z\addons\ from each):
    Code:
    //Crafting
        fn_updateCraftUI = compile preprocessFileLineNumbers "dayz_code\compile\fn_updateCraftUI.sqf";
        player_craftItem = compile preprocessFileLineNumbers "dayz_code\actions\player_craftItem.sqf";
        player_craftItemGUI = compile preprocessFileLineNumbers "dayz_code\actions\player_craftItemGUI.sqf";
        player_checkRecipe = compile preprocessFileLineNumbers "dayz_code\actions\player_checkRecipe.sqf";
    Open up your description.ext

    At the very end add this:

    Code:
    #include "dayz_code\Configs\CfgCrafting\CfgCrafting.hpp"
    Then you're done.

    *Note: you can delete any older files if you do the installation this way.
     
    Last edited: Aug 14, 2015

Share This Page