[TUTORIAL] Deployable bike. {1.7.7.1}

jukki

New Member
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.

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 :)
 
Is it just me or can i not extract my dayz epoch "dayz_code.pbo" im using cpbo.. this would make a nice addition to the list of things to add to my server
 
Surely there's a better way of doing this than having to create a new class in the Cfg?
So players don't have to download any files?

You could just use the self actions for this; add a requirement check (toolbox), a blank/unused item for the inventory and some cutText explanation.

You'd have to spawn the bike with createVehicle, and if you wanted it to save to the database you'd need to do some hive write commands from the server pbo; or you could just tell players to pack the bike up when they log off so they can keep the item in their inventory and respawn it when they next log in.

You won't be able to use the mountain bike as the type or have a custom inventory item and you'd always have the option to build the bike on your scroll menu while you have the blank/unused item in your main inventory, but it'd still be a functional method.

Just a concept, might code it for my Utes server some time unless someone else beats me to it.
 
The main reason i dont want the bike it self to save in database is to reduce the amount of vehicles the server has (on my server, the bike does spawn in supermarket with small change). Database would fill up fast if the bike would be saving.
 
The main reason i dont want the bike it self to save in database is to reduce the amount of vehicles the server has (on my server, the bike does spawn in supermarket with small change). Database would fill up fast if the bike would be saving.


I said 'if you wanted it to save' for that reason ;)
 
Well, you could also maybe add a bike to new players (not spawns) loadout so they can spawn it and ride places and have it not save to the database. Might be a cool addition to get some new players on your servers
 
Where are these actual files ? i cant find them in any .pbo:

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";

Nevermind....found them in :\Expansion\Addons\weapons_e.pbo
 
And how do you give the bike ?
I started up the server, but i dont have anything in my inventory to deploy.. How do we get it oO ?
 
And how do you give the bike ?
I started up the server, but i dont have anything in my inventory to deploy.. How do we get it oO ?
I havent tried this yet, but you probably have to find a bike and scroll on it to get the pack bike option, once its in your inventory tho you might beable to check what the item's class name is and add it to your inventory or other players inventory
 
I really enjoy rMod but for some reason players just won't fool with it,,, even the ones that are constantly complaining about wanting more guns/skins/and vehicles! This is an awesome script if anyone figures out a workaround for non-rMod servers plz share
 
I really enjoy rMod but for some reason players just won't fool with it,,, even the ones that are constantly complaining about wanting more guns/skins/and vehicles! This is an awesome script if anyone figures out a workaround for non-rMod servers plz share


I posted a workaround.
 
.\bike\deploy.sqf
if (dayz_combat == 1) then {
cutText [format["You are in Combat and cannot build a bike."'], "PLAIN DOWN"];
} else {
player removeAction s_player_deploybike;
player playActionNow "Medic"
r_interrupt = false;
player removeWeapon "ItemToolbox";
_dis=10;
_sfx = "repair'";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;

sleep 6;

_object = "'Old_bike_TK_INS_EP1'" createVehicle (position player)
_object setVariable ["ObjectID", "1", true];
_object setVariable ["ObjectUID", "1", true];

player reveal _object

cutText [format["You've used your toolbox to build a bike! How magical!"], "PLAIN DOWN"];

r_interrupt = false;
player switchMove "";
player playActionNow "stop";

sleep 10;

cutText [format["Warning: Spawned Bikes do Not Save after server restart!"], "PLAIN DOWN"];

};
//bike deploy script by Player2 - OpenDayz Release Coming Soon!
then this in fn_selfActions...
// PLAYER2 BIKE DEPLOY
if((speed player <= 1) && _hasToolbox && _canDo) then {
if (s_player_deploybike < 0) then {
s_player_deploybike = player addaction[('"<t color="'"#007ab7"'">" + ("Deploy Bike") +"</t>");,"bike\deploy.sqf","'",5,false,true,"", "'"]
};
} else {
player removeAction s_player_deploy;
s_player_deploybike = -1;
};
 
.\bike\deploy.sqf

then this in fn_selfActions...

where I add the // PLAYER2 BIKE DEPLOY into self? because whatever I add it, all others scripts there stop working (seflbloodbag etc)

also I added into the antihack and all others stuff, just cant figure out how to add into self without screw it out
 
this is awesome, but can make it work arrrgggggg! I doing something wrong into selfactions because the other stuff there stop working after I put the code.
 
Back
Top