Hello, this is my first tutorial and hopefully not last one here.
In this tutorial we are going to create an inventory item that you can unpack in to a bike. You can also pack the bike againg when you are done riding it..
DISCLAIMER: You do need to edit your dayz_code.pbo for this and you need to rmod or unban the mountain bike from dayz_anim.pbo. This means you need to also give your players the modified dayz files!
So lets start shall we?
First download thease 2 files.
- https://www.dropbox.com/s/36fzu2t5tbat1w6/player_unpackBike.sqf
- https://www.dropbox.com/s/1t9upbj20c3faq5/player_packBike.sqf
Place these files inside dayz_code/actions folder.
Then open up deployable.hpp inside configs/cfgMagazines and place this code at the bottom, i have commented out what each line does.
Next open up compiles.sqf, it is located inside the init folder (note some of you might be using scripts wich you place the compiles.sqf inside mission file, if so open that instead)
find this line: player_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_build.sqf";
And under it add this:
Next, open up variables.sqf inside the init folder. Locate this: s_player_deleteBuild = -1;
Under it add this line:
Then open your fn_selfActions.sqf located inside compiles folder. on the top add this piece of code inside the private: "_isBike"
Then locate this piece of code: _isDestructable = cursorTarget isKindOf "BuiltItems";
And under it add this line:
now locate this piece of code:
And under it add this:
now find this line of code: s_player_deleteBuild = -1;
And under it place this:
Save your files, back your pbo and test it out. You now have foldable bike. You can either give your players one when they spawn, add it to loottables or however you want to distribute them. Keep in mind, the bike does not save in to database when it is deployed, so it works great for things like rare supermarket loot. Or if you want you can ignore the fn_selfactions.sqf steps and now you have one time use bike that you can deploy anytime you want and it will disappear after server restart.
Comments and improvement ideas are welcome
In this tutorial we are going to create an inventory item that you can unpack in to a bike. You can also pack the bike againg when you are done riding it..
DISCLAIMER: You do need to edit your dayz_code.pbo for this and you need to rmod or unban the mountain bike from dayz_anim.pbo. This means you need to also give your players the modified dayz files!
So lets start shall we?
First download thease 2 files.
- https://www.dropbox.com/s/36fzu2t5tbat1w6/player_unpackBike.sqf
- https://www.dropbox.com/s/1t9upbj20c3faq5/player_packBike.sqf
Place these files inside dayz_code/actions folder.
Then open up deployable.hpp inside configs/cfgMagazines and place this code at the bottom, i have commented out what each line does.
Code:
class ItemBike: CA_Magazine //deployable bike by jukki
{
count = 1;
type = (256 * 10);//this defines how many slots the bike will take, 10 is default
scope = public;
displayName = "Deployable bike"; //this is the name of the item
descriptionShort = "Deployable bike"; //description of the item
picture = "\ca\weapons_e\data\icons\staticX_CA.paa";//picture of the item
icon = "\ca\weapons_e\data\icons\mapIcon_backpack_CA.paa"; //icon of the item
model = "\ca\weapons_e\AmmoBoxes\StaticX.p3d"; //model of the item
class ItemActions {//this defines the right click so we can use our deploy the bike
class Build {
text = "Unpack Bike"; //this is the text that is in the box you click
script = "spawn player_unPackBike; r_action_count = r_action_count + 1;";//here we define what the action will do
require = "ItemToolbox";//by default you require a toolbox in order to deploy the bike
create = "MMT_Civ";//and here is the output, the mountain bike.
};
};
};
Next open up compiles.sqf, it is located inside the init folder (note some of you might be using scripts wich you place the compiles.sqf inside mission file, if so open that instead)
find this line: player_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_build.sqf";
And under it add this:
Code:
player_unPackBike = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_unPackBike.sqf"; //Jukki, deployable bike
Next, open up variables.sqf inside the init folder. Locate this: s_player_deleteBuild = -1;
Under it add this line:
Code:
s_player_packbike = -1;
Then open your fn_selfActions.sqf located inside compiles folder. on the top add this piece of code inside the private: "_isBike"
Then locate this piece of code: _isDestructable = cursorTarget isKindOf "BuiltItems";
And under it add this line:
Code:
_isBike = cursorTarget isKindOf "MMT_Civ"; //Jukki, we check if the target is packable bike
now locate this piece of code:
Code:
//Allow player to delete objects
if(_isDestructable and _hasToolbox and _canDo) then {
if (s_player_deleteBuild < 0) then {
s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",cursorTarget, 1, true, true, "", ""];
};
} else {
player removeAction 6;
s_player_deleteBuild = -1;
};
And under it add this:
Code:
//Jukki, Allow player to pack their bike.
if(_isBike and _hasToolbox and _canDo) then {
if (s_player_packbike < 0) then {
s_player_packbike = player addAction [format[localize "str_actions_pack",_text], "\z\addons\dayz_code\actions\player_packBike.sqf",cursorTarget, 1, true, true, "", ""];
};
} else {
player removeAction s_player_packbike;
s_player_packbike = -1;
};
now find this line of code: s_player_deleteBuild = -1;
And under it place this:
Code:
player removeAction s_player_packbike;
s_player_packbike = -1;
Save your files, back your pbo and test it out. You now have foldable bike. You can either give your players one when they spawn, add it to loottables or however you want to distribute them. Keep in mind, the bike does not save in to database when it is deployed, so it works great for things like rare supermarket loot. Or if you want you can ignore the fn_selfactions.sqf steps and now you have one time use bike that you can deploy anytime you want and it will disappear after server restart.
Comments and improvement ideas are welcome