|
1 | | -mf-tow |
| 1 | +MF-Tow |
2 | 2 | ====== |
| 3 | +*MF-Tow (a towing script for DayZ Epoch mod)* |
3 | 4 |
|
4 | | -MF-Tow (a towing script for DayZ Epoch mod) |
| 5 | +## Introduction ## |
| 6 | + |
| 7 | +MF-Tow enables vehicles to be towed by others. It has been designed to be highly configureable, allowing server admins to define which vehicles can tow, and what types of vehicles they can tow. |
| 8 | + |
| 9 | +This script builds upon the ideas laid down by the built-in tow system in DayZ Epoch, but with more features and a better configurable ease of use. |
| 10 | + |
| 11 | +MF-Tow was inspired by the great work done by the R3F team on their '[R3F] Artillery and Logistic' addon, and serves as an alternative tow script for admins who just want to add towing functionality to their DayZ Epoch server. |
| 12 | + |
| 13 | +MF-Tow is also fully compatible with the popular '=BTC=_Logistic (DayZ Epoch Version)'. |
| 14 | + |
| 15 | +## Features ## |
| 16 | +- Define exactly what vehicles can tow. |
| 17 | +- Define what types of vehicles can be towed (ie: "Motorcycle", "Car", "Truck", "Wheeled_APC", "Tracked_APC", "Air" etc..) |
| 18 | +- Disable towing of locked vehicles (optional) |
| 19 | +- Requires a player to have a toolbox in their inventory in order to be able to attach a tow. |
| 20 | + |
| 21 | +## Configuring Tow Vehicles ## |
| 22 | + |
| 23 | +[Download](https://github.com/matt-d-rat/mf-tow/archive/master.zip) and extract the zip file to a folder called ```mf-tow```, inside you will find a file called ```init.sqf```, open this file up ina text editor. |
| 24 | + |
| 25 | +There are two things you need to configure to set which vehicles can tow, and what type of vehicles they can tow: |
| 26 | + |
| 27 | +Lets start with the tow vehicles array, add the [class names](https://docs.google.com/spreadsheet/ccc?key=0AjNSjNkQ9qIVdHpCU0pXZVdfZmNZZFlpNHEwQUp2bVE&usp=sharing#gid=0) of the vehicles you wish to allow to tow other vehicles to this array (be careful not to have a trailing comma after the last entry in the array!): |
| 28 | +```sqf |
| 29 | +MF_Tow_Vehicles = [ |
| 30 | + "ATV_CZ_EP1", |
| 31 | + "ATV_US_EP1", |
| 32 | + "hilux1_civil_3_open", |
| 33 | + "hilux1_civil_3_open_EP1", |
| 34 | + "ArmoredSUV_PMC", |
| 35 | + "ArmoredSUV_PMC_DZ", |
| 36 | + "ArmoredSUV_PMC_DZE", |
| 37 | + "HMMWV_M1151_M2_CZ_DES_EP1_DZE", |
| 38 | + "HMMWV_M1151_M2_CZ_DES_EP1", |
| 39 | + "tractor", |
| 40 | + "TowingTractor" |
| 41 | +]; |
| 42 | +``` |
| 43 | + |
| 44 | +Next we need to configure what types of vehicles can be towed by each of the vehicles defined above, add them to the MF_Tow_Towable_Array function as seen below: |
| 45 | + |
| 46 | +```sqf |
| 47 | +MF_Tow_Towable_Array = |
| 48 | +{ |
| 49 | + private ["_array","_towTruck"]; |
| 50 | + _towTruck = _this select 0; |
| 51 | + _array = []; |
| 52 | + |
| 53 | + switch (typeOf _towTruck) do |
| 54 | + { |
| 55 | + case "ATV_CZ_EP1": {_array = ["Motorcycle"];}; |
| 56 | + case "ATV_US_EP1": {_array = ["Motorcycle"];}; |
| 57 | + case "hilux1_civil_3_open": {_array = ["Motorcycle","Car"];}; |
| 58 | + case "hilux1_civil_3_open_EP1": {_array = ["Motorcycle","Car"];}; |
| 59 | + case "ArmoredSUV_PMC": {_array = ["Motorcycle","Car"];}; |
| 60 | + case "ArmoredSUV_PMC_DZ": {_array = ["Motorcycle","Car"];}; |
| 61 | + case "ArmoredSUV_PMC_DZE": {_array = ["Motorcycle","Car"];}; |
| 62 | + case "HMMWV_M1151_M2_CZ_DES_EP1_DZE": {_array = ["Motorcycle","Car","Truck"];}; |
| 63 | + case "HMMWV_M1151_M2_CZ_DES_EP1": {_array = ["Motorcycle","Car","Truck"];}; |
| 64 | + case "tractor": {_array = ["Motorcycle","Car","Truck"];}; |
| 65 | + case "TowingTractor": {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];}; |
| 66 | + }; |
| 67 | + |
| 68 | + _array |
| 69 | +}; |
| 70 | +``` |
| 71 | + |
| 72 | +So for example, we can see that the code above permits the ```ArmoredSUV_PMC``` to tow vehicles which are of either a type of ```Motorcycle``` or ```Car```. Nothing else. |
| 73 | + |
| 74 | +## Installation Guide ## |
| 75 | + |
| 76 | +- __Download__: https://github.com/matt-d-rat/mf-tow/archive/master.zip |
| 77 | +- __Difficulty__: Intermediate |
| 78 | +- __Install time__: 10-15 minutes |
| 79 | +- __Requirements__: |
| 80 | + - Text editor |
| 81 | + - PBO extrator |
| 82 | + - Coffee or beer |
| 83 | + |
| 84 | +__Step 1:__ [Download](https://github.com/matt-d-rat/mf-tow/archive/master.zip) and extract the zip file to a folder called ```mf-tow```. |
| 85 | + |
| 86 | +__Step 2:__ In your ```MPMissions``` folder (eg, DayZ_Epoch_11.Chernarus), create a folder called ```addons``` if one doesn't exist already. |
| 87 | + |
| 88 | +__Step 3:__ Copy the ```mf-tow``` folder into the ```addons``` folder. |
| 89 | + |
| 90 | +Next, we need to add the call to the MF-Tow's ```init.sqf``` script to the ```fn_selfActions.sqf``` which involves overriding the default DayZ Epoch ```compiles.sqf``` and ```fn_selfActions.sqf``` files. If you haven't created a custom ```compiles.sqf``` before proceed to __step 4__, otherwise skip ahead to __step 8__. |
| 91 | + |
| 92 | +__Step 4:__ Locate your ```@dayz_epoch``` folder, this is normally found in your Arma2 Operation Arrowhead folder (depending on how you installed the game). |
| 93 | + |
| 94 | +Steam users For example will find it installed here: |
| 95 | +``` |
| 96 | +C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 Operation Arrowhead\ |
| 97 | +``` |
| 98 | + |
| 99 | +Locate the ```dayz_code.pbo``` file inside your ```@dayz_epoch\addons\``` folder and copy it to your desktop. |
| 100 | + |
| 101 | +__Step 5:__ Extract the contents of the ```dayz_code.pbo``` file you copied to your desktop using a PBO tool. I recommend [PBOManager](http://www.armaholic.com/page.php?id=16369). Open the folder you extracted the contents to and grab a copy of ```compiles.sqf``` located in ```dayz_code\init\```. |
| 102 | + |
| 103 | +__Step 6:__ Paste the ```compiles.sqf``` to the root of your ```MPMissions``` folder (eg, DayZ_Epoch_11.Chernarus). |
| 104 | + |
| 105 | + |
| 106 | +__Step 7:__ Now we need to update our MPMission to load our custom ```compiles.sqf```, so open up ```init.sqf``` located in the root of your MPMission folder in a text editing program. I recommend [Notepad++](http://notepad-plus-plus.org/). |
| 107 | + |
| 108 | +Around __line 54__ look for the following: |
| 109 | + |
| 110 | +```sqf |
| 111 | +call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; |
| 112 | +``` |
| 113 | + |
| 114 | +and change it to this: |
| 115 | + |
| 116 | +```sqf |
| 117 | +call compile preprocessFileLineNumbers "compiles.sqf"; |
| 118 | +``` |
| 119 | + |
| 120 | +Our server will now load our custom ```compiles.sqf``` file instead. |
| 121 | + |
| 122 | +__Step 8:__ In your ```MPMissions``` folder (eg, DayZ_Epoch_11.Chernarus), create a folder called ```compile```. This is where we will put our custom compile files to keep them nice and organised (this also massively helps when it comes to upgrading versions of DayZ Epoch Server). |
| 123 | + |
| 124 | +__Step 9:__ Grab a copy of ```fn_selfActions.sqf``` from ```@dayz_code\compile``` and paste it into the ```compile``` folder you created in Step 8. |
| 125 | + |
| 126 | +__Step 10:__ Open your custom ```compiles.sqf``` located at the root of your ```MPMissions``` folder in a text editor. Around __line 14__ look for this: |
| 127 | + |
| 128 | +```sqf |
| 129 | +fnc_usec_selfActions = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selfActions.sqf"; |
| 130 | +``` |
| 131 | +and change it to this: |
| 132 | + |
| 133 | +```sqf |
| 134 | +fnc_usec_selfActions = compile preprocessFileLineNumbers "compile\fn_selfActions.sqf"; |
| 135 | +``` |
| 136 | +Our server will now load our custom ```fn_selfActions.sqf``` file instead. |
| 137 | + |
| 138 | +__Step 11:__ Finally, open your custom ```fn_selfActions.sqf`` in a text editor. Around line __711-725__ you should see this: |
| 139 | + |
| 140 | +```sqf |
| 141 | + //Towing with tow truck |
| 142 | + /* |
| 143 | + if(_typeOfCursorTarget == "TOW_DZE") then { |
| 144 | + if (s_player_towing < 0) then { |
| 145 | + if(!(_cursorTarget getVariable ["DZEinTow", false])) then { |
| 146 | + s_player_towing = player addAction [localize "STR_EPOCH_ACTIONS_ATTACH" "\z\addons\dayz_code\actions\tow_AttachStraps.sqf",_cursorTarget, 0, false, true, "",""]; |
| 147 | + } else { |
| 148 | + s_player_towing = player addAction [localize "STR_EPOCH_ACTIONS_DETACH", "\z\addons\dayz_code\actions\tow_DetachStraps.sqf",_cursorTarget, 0, false, true, "",""]; |
| 149 | + }; |
| 150 | + }; |
| 151 | + } else { |
| 152 | + player removeAction s_player_towing; |
| 153 | + s_player_towing = -1; |
| 154 | + }; |
| 155 | + */ |
| 156 | +``` |
| 157 | + |
| 158 | +This is the built in DayZ Epoch towing call, ensure that it is commented out so that it doesn't interfear with MF-Tow. Below this block of code, add the following line to initiate the MF-Tow script. |
| 159 | + |
| 160 | +```sqf |
| 161 | +// MF-Tow Script by Matt Fairbrass (matt_d_rat) |
| 162 | +call compile preprocessFileLineNumbers 'addons\mf-tow\init.sqf'; |
| 163 | +``` |
| 164 | + |
| 165 | +### Disable towing of locked vehicles (optional) ### |
| 166 | + |
| 167 | +If you want to disable towing of vehicles that are locked to stop those pesky bandits from trolling people follow the optional steps below: |
| 168 | + |
| 169 | +__Step 12:__ Unpack the following files: |
| 170 | + |
| 171 | +- ```dayz_code.pbo``` located in your ```@dayz_epoch``` folder. |
| 172 | +- ```dayz_server.pbo``` |
| 173 | + |
| 174 | +__Step 13:__ Grab a copy of the ```local_lockUnlock.sqf``` file from ```dayz_code\compile\``` and paste them into your ```compiles``` folder located in the root of your MPMission folder. |
| 175 | + |
| 176 | +__Step 14:__ Open up your copy of ```local_lockUnlock.sqf``` in a text editor. Around __line 5__ locate the following code: |
| 177 | + |
| 178 | +```sqf |
| 179 | +if (local _vehicle) then { |
| 180 | + if(_status) then { |
| 181 | + _vehicle setVehicleLock "LOCKED"; |
| 182 | + } else { |
| 183 | + _vehicle setVehicleLock "UNLOCKED"; |
| 184 | + }; |
| 185 | +}; |
| 186 | +``` |
| 187 | + |
| 188 | +and change it to: |
| 189 | + |
| 190 | +```sqf |
| 191 | +if (local _vehicle) then { |
| 192 | + if(_status) then { |
| 193 | + _vehicle setVehicleLock "LOCKED"; |
| 194 | + _vehicle setVariable ["MF_Tow_Cannot_Tow",true,true]; |
| 195 | + } else { |
| 196 | + _vehicle setVehicleLock "UNLOCKED"; |
| 197 | + _vehicle setVariable ["MF_Tow_Cannot_Tow",false,true]; |
| 198 | + }; |
| 199 | +}; |
| 200 | +``` |
| 201 | + |
| 202 | +__Step 15:__ Open your custom ```compiles.sqf``` file located in the root of your MPMissions folder in a text editor. Around __line 512__ located the following line: |
| 203 | + |
| 204 | +```sqf |
| 205 | +local_lockUnlock = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_lockUnlock.sqf"; |
| 206 | +``` |
| 207 | + |
| 208 | +and change it to: |
| 209 | + |
| 210 | +```sqf |
| 211 | +local_lockUnlock = compile preprocessFileLineNumbers "compile\local_lockUnlock.sqf"; |
| 212 | +``` |
| 213 | + |
| 214 | +__Step 16:__ Open ```server_publishVehicle2.sqf``` located in the ```dayz_server\compile\``` folder in a text editor. Around __line 4__ locate the following code: |
| 215 | + |
| 216 | +```sqf |
| 217 | +if(!_donotusekey) then { |
| 218 | + // Lock vehicle |
| 219 | + _object setvehiclelock "locked"; |
| 220 | +}; |
| 221 | +``` |
| 222 | + |
| 223 | +and change it to: |
| 224 | + |
| 225 | +```sqf |
| 226 | +if(!_donotusekey) then { |
| 227 | + // Lock vehicle |
| 228 | + _object setvehiclelock "locked"; |
| 229 | + _vehicle setVariable ["MF_Tow_Cannot_Tow",true,true]; |
| 230 | +}; |
| 231 | +``` |
| 232 | + |
| 233 | +__Step 17:__ Open ```server_monitor.sqf``` located in the ```dayz_server\system\``` folder in a text editor. Locate the following code: |
| 234 | + |
| 235 | +```sqf |
| 236 | +if(_ownerID != "0" and !(_object isKindOf "Bicycle")) then { |
| 237 | + _object setvehiclelock "locked"; |
| 238 | +}; |
| 239 | +``` |
| 240 | + |
| 241 | +and change it to: |
| 242 | + |
| 243 | +```sqf |
| 244 | +if(_ownerID != "0" and !(_object isKindOf "Bicycle")) then { |
| 245 | + _object setvehiclelock "locked"; |
| 246 | + _vehicle setVariable ["MF_Tow_Cannot_Tow",true,true]; |
| 247 | +}; |
| 248 | +``` |
| 249 | + |
| 250 | +__Step 18: Repack ```dayz_server.pbo``` and upload it to your server. |
| 251 | + |
| 252 | +### Known Issues ### |
| 253 | +1. Vehicles which have been towed and detached must be entered at least once in order for the server to update the vehicles world postion, ensuring the vehicle remain at that position on server restart. |
| 254 | + |
| 255 | +### Change Log ### |
| 256 | + |
| 257 | +#### v1.0.0 ### |
| 258 | +- Initial release. |
| 259 | +- Added the requirement for the player to have a toolbox in their inventory. |
| 260 | +- Added feature to prevent the towing of locked vehicles. |
| 261 | +- Configurable array of tow vehicles and which types of vehicles they can tow. |
| 262 | +- Added install guide. |
0 commit comments