Skip to content

Commit 8ff819b

Browse files
committed
Release v1.0.0
- Initial release. - Added the requirement for the player to have a toolbox in their inventory. - Added feature to prevent the towing of locked vehicles. - Configurable array of tow vehicles and which types of vehicles then can tow. - Added install guide.
1 parent af25489 commit 8ff819b

File tree

4 files changed

+594
-2
lines changed

4 files changed

+594
-2
lines changed

README.md

Lines changed: 260 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,262 @@
1-
mf-tow
1+
MF-Tow
22
======
3+
*MF-Tow (a towing script for DayZ Epoch mod)*
34

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.

init.sqf

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* mf-tow/init.sqf
3+
* The main script for initalising towing functionality.
4+
*
5+
* Created by Matt Fairbrass (matt_d_rat)
6+
* Version: 1.0.0
7+
* MIT Licence
8+
**/
9+
10+
private ["_cursorTarget", "_typeOfCursorTarget"];
11+
12+
// Public variables
13+
MF_Tow_Base_Path = "addons\mf-tow"; // The base path to the MF-Tow Folder.
14+
MF_Tow_Distance = 10; // Minimum distance (in meters) away from vehicle the tow truck must be to tow.
15+
16+
// The vehicles which can tow
17+
MF_Tow_Vehicles = [
18+
"ATV_CZ_EP1",
19+
"ATV_US_EP1",
20+
"hilux1_civil_3_open",
21+
"hilux1_civil_3_open_EP1",
22+
"ArmoredSUV_PMC",
23+
"ArmoredSUV_PMC_DZ",
24+
"ArmoredSUV_PMC_DZE",
25+
"HMMWV_M1151_M2_CZ_DES_EP1_DZE",
26+
"HMMWV_M1151_M2_CZ_DES_EP1",
27+
"tractor",
28+
"TowingTractor"
29+
];
30+
31+
// Functions
32+
33+
/**
34+
* Returns an array of towable objects which can be pulled by the tow truck.
35+
* Configure this as required to set which vehicles can pull which types of other vehicles.
36+
**/
37+
MF_Tow_Towable_Array =
38+
{
39+
private ["_array","_towTruck"];
40+
_towTruck = _this select 0;
41+
_array = [];
42+
43+
switch (typeOf _towTruck) do
44+
{
45+
case "ATV_CZ_EP1": {_array = ["Motorcycle"];};
46+
case "ATV_US_EP1": {_array = ["Motorcycle"];};
47+
case "hilux1_civil_3_open": {_array = ["Motorcycle","Car"];};
48+
case "hilux1_civil_3_open_EP1": {_array = ["Motorcycle","Car"];};
49+
case "ArmoredSUV_PMC": {_array = ["Motorcycle","Car"];};
50+
case "ArmoredSUV_PMC_DZ": {_array = ["Motorcycle","Car"];};
51+
case "ArmoredSUV_PMC_DZE": {_array = ["Motorcycle","Car"];};
52+
case "HMMWV_M1151_M2_CZ_DES_EP1_DZE": {_array = ["Motorcycle","Car","Truck"];};
53+
case "HMMWV_M1151_M2_CZ_DES_EP1": {_array = ["Motorcycle","Car","Truck"];};
54+
case "tractor": {_array = ["Motorcycle","Car","Truck"];};
55+
case "TowingTractor": {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
56+
};
57+
58+
_array
59+
};
60+
61+
/**
62+
* Animate the player in a towing action, whilst attaching them to the tow vehicle to ensure safety.
63+
**/
64+
MF_Tow_Animate_Player_Tow_Action =
65+
{
66+
private ["_towTruck"];
67+
_towTruck = _this select 0;
68+
69+
[player,20,true,(getPosATL player)] spawn player_alertZombies; // Alert nearby zombies
70+
[1,1] call dayz_HungerThirst; // Use some hunger and thirst to perform the action
71+
72+
// Attach the player to the tow truck temporarily for safety so that they aren't accidentally hit by the vehicle when it gets attached
73+
player attachTo [_towTruck,
74+
[
75+
(boundingBox _towTruck select 1 select 0),
76+
(boundingBox _towTruck select 0 select 1) + 1,
77+
(boundingBox _towTruck select 0 select 2) - (boundingBox player select 0 select 2)
78+
]
79+
];
80+
81+
player setDir 270;
82+
player setPos (getPos player);
83+
player playActionNow "Medic"; // Force the animation
84+
};
85+
86+
MF_Tow_Get_Vehicle_Name =
87+
{
88+
private ["_vehicle", "_configVeh", "_vehicleName"];
89+
_vehicle = _this select 0;
90+
91+
_configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle);
92+
_vehicleName = getText(_configVeh >> "displayName");
93+
94+
_vehicleName
95+
};
96+
97+
// Initialise script
98+
_cursorTarget = cursorTarget;
99+
_typeOfCursorTarget = typeOf _cursorTarget;
100+
101+
// Add the action to the players scroll wheel menu if the cursor target is a vehicle which can tow.
102+
if(_typeOfCursorTarget in MF_Tow_Vehicles) then {
103+
if (s_player_towing < 0) then {
104+
if(!(_cursorTarget getVariable ["MFTowInTow", false])) then {
105+
s_player_towing = player addAction ["Attach Tow", format["%1\tow_AttachTow.sqf", MF_Tow_Base_Path], _cursorTarget, 0, false, true, "",""];
106+
} else {
107+
s_player_towing = player addAction ["Detach Tow", format["%1\tow_DetachTow.sqf", MF_Tow_Base_Path], _cursorTarget, 0, false, true, "",""];
108+
};
109+
};
110+
}
111+
else {
112+
player removeAction s_player_towing;
113+
s_player_towing = -1;
114+
};

0 commit comments

Comments
 (0)