SmokeyMeadow
Well-Known Member
Big thanks to Freaking Fred for this. I had the idea a while back and had been searching for a way to implement it. By adapting the anti zombie emitter script, I found I was able to craft all sorts of items, and even modify weapons to include things like removable silencers and scopes.
So far, I've added the option to craft baseball bats and arrows from piles of wood if you are carrying a knife. Also made it so gathering a tin can, scrap metal and a wire fence kit allows you to build a crossbow. As for modding weapons, I've made the M9 convertible to an M9SD. Also did this for the USP and Makarov from the rh pistol pack, but this won't be of interest to you unless you run rmod.
Pretty easy to do, you will need to use a custom fn_selfactions.sqf if you aren't using one already. If you already have this set up, skip ahead while I explain to the rest how that is done.
Extract both the "complies.sqf" and "fn_selfactions.sqf" from dayzcode.pbo. Place both in your mission folder. Alter your mission's init.sqf so that this line is commented out (place a // at the beginning)
Now beneath it, add this:
Now your init will look for the special code we're adding instead of just the vanilla code from the dayzcode.pbo. Open up compiles.sqf and find this line and place a // at the start of it:
Now, add this in directly below:
Now for the fun part, editing the fn_selfaction.sqf to allow the new actions we want. Open it up and add this at the very bottom to allow players to craft bats and arrows:
Then create a folder inside your mission folder called Scripts. Place this file and this file in it.
Your players will now be able to craft a baseball bat or an arrow if they are carrying wood and a hunting knife (Thanks, Mamu1234 for helping on this).
Add this to the fn_selfactions to allow players to build their own crossbows:
Then add this file into your scripts folder. Now by gathering a tin can, scrap metal, a wire kit and a toolbox, players will be able to make a hand built crossbow.
Add this to allow players to clear brush with a hatchet:
And add this into the scripts folder. Players carrying a hatchet or machete will be able to clear the surrounding area of brush.
This code will allow the player to add and remove the silencer from the standard Day Z M9 pistol.
Now add this file and also this file into the scripts folder.
Please note the following issues:
*If you log in and have the necessary items to craft in your inventory, but don't see the option on the scroll menu, try dropping them and picking them back up. I will address this issue as soon as I figure out what causes it.
*Swapping the silencer off and on sometimes requires you to cycle weapons in order for the weapon to fire again.
*Adding a silencer will not actually silence the gun unless you also have sd magazines.
*The effects of Battleye on this are UNKNOWN. Repeat: I do not run BE on my server, so I have no idea if it will kick you for some kind of restriction. If this becomes an issue we'll just have to add exceptions. Someone who is less n00bish than me might have a better idea of how that is done.
I hope this is of use to some of you. I'm making this topic so people can share their ideas for possible future combinations and crafted items. Once again, big thanks to Freaking Fred for providing the code that made this idea possible.
So far, I've added the option to craft baseball bats and arrows from piles of wood if you are carrying a knife. Also made it so gathering a tin can, scrap metal and a wire fence kit allows you to build a crossbow. As for modding weapons, I've made the M9 convertible to an M9SD. Also did this for the USP and Makarov from the rh pistol pack, but this won't be of interest to you unless you run rmod.
Pretty easy to do, you will need to use a custom fn_selfactions.sqf if you aren't using one already. If you already have this set up, skip ahead while I explain to the rest how that is done.
Extract both the "complies.sqf" and "fn_selfactions.sqf" from dayzcode.pbo. Place both in your mission folder. Alter your mission's init.sqf so that this line is commented out (place a // at the beginning)
Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions
Now beneath it, add this:
Code:
call compile preprocessFileLineNumbers "compiles.sqf"; //Compile regular functions
Now your init will look for the special code we're adding instead of just the vanilla code from the dayzcode.pbo. Open up compiles.sqf and find this line and place a // at the start of it:
Code:
fnc_usec_selfActions = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selfActions.sqf"; //Checks which actions for self
Now, add this in directly below:
Code:
fnc_usec_selfActions = compile preprocessFileLineNumbers "fn_selfActions.sqf";
Now for the fun part, editing the fn_selfaction.sqf to allow the new actions we want. Open it up and add this at the very bottom to allow players to craft bats and arrows:
Code:
// MAKE A BAT START
if (("PartWoodPile" in magazines player) && ("ItemKnife" in items player)) then {
hasBatParts = true;
} else {
hasBatParts = false;
};
if (hasBatParts) then {
if (makeBat < 0) then {
makeBat = player addAction [("<t color=""#00c362"">" + ("Craft Baseball Bat") +"</t>"),"scripts\makebat.sqf","",5,false,true,"",""];
};
} else {
player removeAction makeBat;
makeBat = -1;
};
// MAKE A BAT END
// MAKE ARROW START
if (("PartWoodPile" in magazines player) && ("ItemKnife" in items player)) then {
hasArrowParts = true;
} else {
hasArrowParts = false;
};
if (hasArrowParts) then {
if (makeArrows < 0) then {
makeArrows = player addAction [("<t color=""#00c362"">" + ("Craft an Arrow") +"</t>"),"scripts\makearrow.sqf","",5,false,true,"",""];
};
} else {
player removeAction makeArrows;
makeArrows = -1;
};
// MAKE ARROW END
Then create a folder inside your mission folder called Scripts. Place this file and this file in it.
Your players will now be able to craft a baseball bat or an arrow if they are carrying wood and a hunting knife (Thanks, Mamu1234 for helping on this).
Add this to the fn_selfactions to allow players to build their own crossbows:
Code:
// MAKE CROSSBOW START
if (("TrashTinCan" in magazines player) && ("ItemWire" in magazines player) && ("PartGeneric" in magazines player) && ("ItemKnife" in items player) && ("ItemToolbox" in items player)) then {
hasBowparts = true;
} else {
hasBowparts = false;
};
if (hasBowparts) then {
if (makeBow < 0) then {
makeBow = player addAction [("<t color=""#00c362"">" + ("Construct Crossbow") +"</t>"),"scripts\makebow.sqf","",5,false,true,"",""];
};
} else {
player removeAction makeBow;
makeBow = -1;
};
// MAKE CROSSBOW END
Then add this file into your scripts folder. Now by gathering a tin can, scrap metal, a wire kit and a toolbox, players will be able to make a hand built crossbow.
Add this to allow players to clear brush with a hatchet:
Code:
// CLEAR BRUSH START
if (("MeleeHatchet" in weapons player)) then {
hasbrushclear = true;
} else {
hasbrushclear = false;
};
if (hasbrushclear) then {
if (clearBrush < 0) then {
clearBrush = player addAction [("<t color=""#00c362"">" + ("Clear Brush") +"</t>"),"scripts\clearbrush.sqf","",5,false,true,"",""];
};
} else {
player removeAction clearBrush;
clearBrush = -1;
};
// CLEAR BRUSH END
// CLEAR BRUSH MACHETE START
if (("MeleeMachete" in weapons player)) then {
hasbrushclear = true;
} else {
hasbrushclear = false;
};
if (hasbrushclear) then {
if (clearBrushMachete < 0) then {
clearBrushMachete = player addAction [("<t color=""#00c362"">" + ("Clear Brush") +"</t>"),"scripts\clearbrush.sqf","",5,false,true,"",""];
};
} else {
player removeAction clearBrushMachete;
clearBrushMachete = -1;
};
// CLEAR BRUSH MACHETE END
And add this into the scripts folder. Players carrying a hatchet or machete will be able to clear the surrounding area of brush.
This code will allow the player to add and remove the silencer from the standard Day Z M9 pistol.
Code:
// M9 SILENCER ADD START
if (("M9" in weapons player)) then {
hasM9 = true;
} else {
hasM9 = false;
};
if (hasM9) then {
if (addM9sil < 0) then {
addM9sil = player addAction [("<t color=""#00c362"">" + ("Add Silencer to M9") +"</t>"),"scripts\m9addsil.sqf","",5,false,true,"",""];
};
} else {
player removeAction addM9sil;
addM9sil = -1;
};
// M9 SILENCER ADD END
// M9 SILENCER REMOVE START
if (("M9SD" in weapons player)) then {
hasM9SD = true;
} else {
hasM9SD = false;
};
if (hasM9SD) then {
if (remM9sil < 0) then {
remM9sil = player addAction [("<t color=""#00c362"">" + ("Remove M9 Silencer") +"</t>"),"scripts\m9remsil.sqf","",5,false,true,"",""];
};
} else {
player removeAction remM9sil;
remM9sil = -1;
};
// M9 SILENCER REMOVE END
Now add this file and also this file into the scripts folder.
Please note the following issues:
*If you log in and have the necessary items to craft in your inventory, but don't see the option on the scroll menu, try dropping them and picking them back up. I will address this issue as soon as I figure out what causes it.
*Swapping the silencer off and on sometimes requires you to cycle weapons in order for the weapon to fire again.
*Adding a silencer will not actually silence the gun unless you also have sd magazines.
*The effects of Battleye on this are UNKNOWN. Repeat: I do not run BE on my server, so I have no idea if it will kick you for some kind of restriction. If this becomes an issue we'll just have to add exceptions. Someone who is less n00bish than me might have a better idea of how that is done.
I hope this is of use to some of you. I'm making this topic so people can share their ideas for possible future combinations and crafted items. Once again, big thanks to Freaking Fred for providing the code that made this idea possible.