Allen Kaganovsky
Member
POST 1 of 2.
Hello, long time viewer, but here is my first contribution back to the community. I initially did these modifications to Manatees server, so many of the variables are named as such.
First off, special thanks to the original crafting system that was posted on these forums, sorry I can no longer find the name - but thanks to them for the crafting idea.
So if you used the crafting system, you'll find it very hard to add more combinations or items and easily customize it - I use the crafting system concept but make it so that the server admin can customize it much easier.
I'm going to assume that you already have a custom fn_selfActions.sqf file set up within your mission - if not, please view Krixes self blood on the initial setup for a custom fn_selfActions.sqf.
Step 1: Set up an "Activator" that will bring up the crafting menu. The crafting menu will subdivide all the crafting items by Survival supplies, Industrial supplies and Weapons.
This piece of code goes within your fn_selfActions.sqf,
you'll also want to add at the end where you'll see a large list of similar actions.
Note: You'll need to add the global variable crafting_menu_open = false;, i.e. within your init.sqf
The above code will first check if the player is looking into a flame, the player is close to the flame, and the menu has not yet been opened.
Step 2: The player activated the Crafting Menu!
so we'll need to place all the menu and "oven" files.
First create a folder in the root of your mission folder called "crafting".
within it, create the files:
craftmenu.sqf
closemenu.sqf
industrial.sqf
survival.sqf
weapons..sqf
craftmenu.sqf:
The above code executes when the player actives the crafting menu. It will then add mouse scroll options to access the submenus for Industrial, Survival or Weapon crafting. You can also close the crafting menu all together.
Here are examples of the submenus for survival, industrial and weapons. These are the files you will need to edit to create new items for crafting as well as their input/output requirements for the crafting procedure. You should have some basic understanding of arrays within the Arma engine to make life a lot easier on you.
industrial.sqf:
You can see the format of the passed parameters per menu item that is being sent to the "oven" for crafting.
From the above code, we can create a Wire Kit, we can see the output is [0,"ItemWire",1] meaning a magazine, ItemWire, and qty1. Now for the requirements to craft this item: [0,"ItemTrashRazor",8],[0,"ItemTankTrap",2] so we need 8 razors and 2 tank trap kits to convert into a wire kit. You can easily modify the produced and required arrays with as many items that fit into the main inventory.
survival.sqf:
Hello, long time viewer, but here is my first contribution back to the community. I initially did these modifications to Manatees server, so many of the variables are named as such.
First off, special thanks to the original crafting system that was posted on these forums, sorry I can no longer find the name - but thanks to them for the crafting idea.
So if you used the crafting system, you'll find it very hard to add more combinations or items and easily customize it - I use the crafting system concept but make it so that the server admin can customize it much easier.
I'm going to assume that you already have a custom fn_selfActions.sqf file set up within your mission - if not, please view Krixes self blood on the initial setup for a custom fn_selfActions.sqf.
Step 1: Set up an "Activator" that will bring up the crafting menu. The crafting menu will subdivide all the crafting items by Survival supplies, Industrial supplies and Weapons.
This piece of code goes within your fn_selfActions.sqf,
Code:
// custom crafting menu system
if ((inflamed cursorTarget && cursorTarget distance player < 10) && _canDo && !crafting_menu_open) then {
if (s_player_smeltItems < 0) then {
s_player_smeltItems = player addaction[("<t color=""#FFC726"">" + ("Crafting Menu") +"</t>"),"crafting\craftmenu.sqf","",10,true,true,"", ""];
};
} else {
player removeAction s_player_smeltItems;
s_player_smeltItems = -1;
};
Code:
player removeAction s_player_smeltItems;
s_player_smeltItems = -1;
Note: You'll need to add the global variable crafting_menu_open = false;, i.e. within your init.sqf
The above code will first check if the player is looking into a flame, the player is close to the flame, and the menu has not yet been opened.
Step 2: The player activated the Crafting Menu!
so we'll need to place all the menu and "oven" files.
First create a folder in the root of your mission folder called "crafting".
within it, create the files:
craftmenu.sqf
closemenu.sqf
industrial.sqf
survival.sqf
weapons..sqf
craftmenu.sqf:
Code:
{
player removeAction _x
} forEach manatee_craft_menu;
manatee_craft_menu = [];
crafting_menu_open = true;
show_industrial = false;
show_survival = false;
show_weapons = false;
sleep 1;
cutText ["Opened Crafting Menu. Scroll your mouse to access it.","PLAIN",2];
sleep 1;
_restriction = "count ((position player) nearObjects ['Land_fire', 10]) > 0";
manatee_craft_menu = [];
manatee_craft_menu set [count manatee_craft_menu, player addaction [("<t color=""#0074E8"">" + ("Crafting Menu") +"</t>"),"","",99,false,false,"",_restriction]];
manatee_craft_menu set [count manatee_craft_menu, player addaction [("<t color=""#FF7300"">" + (" Close Menu") +"</t>"),"crafting\closemenu.sqf","",98,false,true,"",_restriction]];
manatee_craft_menu set [count manatee_craft_menu, player addaction [("<t color=""#4AC925"">" + (" Industrial Parts") +"</t>"),"crafting\industrial.sqf","",97,false,false,"",_restriction]];
manatee_craft_menu set [count manatee_craft_menu, player addaction [("<t color=""#4AC925"">" + (" Survival Gear") +"</t>"),"crafting\survival.sqf","",95,false,false,"",_restriction]];
manatee_craft_menu set [count manatee_craft_menu, player addaction [("<t color=""#4AC925"">" + (" Weapons Crafting") +"</t>"),"crafting\weapons.sqf","",93,false,false,"",_restriction]];
manatee_craft_menu set [count manatee_craft_menu, player addaction [("<t color=""#0074E8"">" + ("-----------------------------") +"</t>"),"","",91,false,false,"",_restriction]];
The above code executes when the player actives the crafting menu. It will then add mouse scroll options to access the submenus for Industrial, Survival or Weapon crafting. You can also close the crafting menu all together.
Here are examples of the submenus for survival, industrial and weapons. These are the files you will need to edit to create new items for crafting as well as their input/output requirements for the crafting procedure. You should have some basic understanding of arrays within the Arma engine to make life a lot easier on you.
industrial.sqf:
Code:
// parameter format, array of:
// output item, array of input items and how many of each item. Treat each input item as an array
// that includes the class name and the number required.
// PARAMETER STRUCTURE VERY IMPORTANT
// type = 0 for magazine, 1 for weapon/toolbelt
// [ [ type, "Finished Readable Item Name","FinishedItemClassName","FinishedQty" ] , [ [type, "RequiredClassName","RequiredQty"] , [type, "RequiredClassName2","RequiredQty"] ... ]]
sleep 1;
if (!show_industrial) then {
show_industrial = true;
_restriction = "count ((position player) nearObjects ['Land_fire', 10]) > 0";
manatee_craft_menu_ind = [];
manatee_craft_menu_ind set [count manatee_craft_menu_ind, player addaction [("<t color=""#FFC726"">" + (" Scrap Metal") +"</t>"),"crafting\oven.sqf",[[0,"Scrap Metal","PartGeneric",1],[[0,"TrashTinCan",6]]],96,false,false,"",_restriction]];
manatee_craft_menu_ind set [count manatee_craft_menu_ind, player addaction [("<t color=""#FFC726"">" + (" Tank Trap") +"</t>"),"crafting\oven.sqf",[[0,"Tank Trap","ItemTankTrap",1],[[0,"PartGeneric",4]]],96,false,false,"",_restriction]];
manatee_craft_menu_ind set [count manatee_craft_menu_ind, player addaction [("<t color=""#FFC726"">" + (" Wire Kit") +"</t>"),"crafting\oven.sqf",[[0,"Wire Kit","ItemWire",1],[[0,"ItemTrashRazor",8],[0,"ItemTankTrap",2]]],96,false,false,"",_restriction]];
manatee_craft_menu_ind set [count manatee_craft_menu_ind, player addaction [("<t color=""#FFC726"">" + (" Windscreen") +"</t>"),"crafting\oven.sqf",[[0,"Windscreen","PartGlass",1],[[0,"TrashJackDaniels",8],[0,"PartGeneric",1]]],96,false,false,"",_restriction]];
manatee_craft_menu_ind set [count manatee_craft_menu_ind, player addaction [("<t color=""#FFC726"">" + (" Empty Jerrycan") +"</t>"),"crafting\oven.sqf",[[0,"Empty Jerrycan","ItemJerrycanEmpty",1],[[0,"ItemWaterbottleUnfilled",4],[0,"PartGeneric",2]]],96,false,false,"",_restriction]];
} else {
show_industrial = false;
{player removeAction _x;} foreach manatee_craft_menu_ind; manatee_craft_menu_ind = [];
};
You can see the format of the passed parameters per menu item that is being sent to the "oven" for crafting.
From the above code, we can create a Wire Kit, we can see the output is [0,"ItemWire",1] meaning a magazine, ItemWire, and qty1. Now for the requirements to craft this item: [0,"ItemTrashRazor",8],[0,"ItemTankTrap",2] so we need 8 razors and 2 tank trap kits to convert into a wire kit. You can easily modify the produced and required arrays with as many items that fit into the main inventory.
survival.sqf:
Code:
// parameter format, array of:
// output item, array of input items and how many of each item. Treat each input item as an array
// that includes the class name and the number required.
// PARAMETER STRUCTURE VERY IMPORTANT
// type = 0 for magazine, 1 for weapon/toolbelt
// [ [ type, "Finished Readable Item Name","FinishedItemClassName","FinishedQty" ] , [ [type, "RequiredClassName","RequiredQty"] , [type, "RequiredClassName2","RequiredQty"] ... ]]
sleep 1;
if (!show_survival) then {
show_survival = true;
_restriction = "count ((position player) nearObjects ['Land_fire', 10]) > 0";
manatee_craft_menu_sur = [];
manatee_craft_menu_sur set [count manatee_craft_menu_sur, player addaction [("<t color=""#FFC726"">" + (" Bandage") +"</t>"),"crafting\oven.sqf",[[0,"Bandage","ItemBandage",1],[[0,"ItemTrashToiletpaper",4]]],94,false,false,"",_restriction]];
manatee_craft_menu_sur set [count manatee_craft_menu_sur, player addaction [("<t color=""#FFC726"">" + (" Splint (Morphine)") +"</t>"),"crafting\oven.sqf",[[0,"Splint (Morphine)","ItemMorphine",1],[[0,"ItemBandage",4],[0,"PartWoodPile",2]]],94,false,false,"",_restriction]];
manatee_craft_menu_sur set [count manatee_craft_menu_sur, player addaction [("<t color=""#FFC726"">" + (" Hatchet") +"</t>"),"crafting\oven.sqf",[[1,"Hatchet","ItemHatchet",1],[[0,"ItemTrashRazor",4],[0,"PartWoodPile",2]]],94,false,false,"",_restriction]];
manatee_craft_menu_sur set [count manatee_craft_menu_sur, player addaction [("<t color=""#FFC726"">" + (" Box of Matches") +"</t>"),"crafting\oven.sqf",[[1,"Box of Matches","ItemMatchbox",1],[[0,"ItemBandage",4],[0,"HandRoadFlare",1]]],94,false,false,"",_restriction]];
manatee_craft_menu_sur set [count manatee_craft_menu_sur, player addaction [("<t color=""#FFC726"">" + (" Hunting Knife") +"</t>"),"crafting\oven.sqf",[[1,"Hunting Knife","ItemKnife",1],[[0,"ItemTrashRazor",3],[0,"ItemMachete",1]]],94,false,false,"",_restriction]];
manatee_craft_menu_sur set [count manatee_craft_menu_sur, player addaction [("<t color=""#FFC726"">" + (" Old Camping Tent") +"</t>"),"crafting\oven.sqf",[[0,"Old Camping Tent","ItemTent",1],[[0,"ItemTankTrap",2],[0,"PartGeneric",1],[0,"Skin_Sniper3_DZC",2]]],94,false,false,"",_restriction]];
} else {
show_survival = false;
{player removeAction _x;} foreach manatee_craft_menu_sur; manatee_craft_menu_sur = [];
};