Skip to content

Commit 3d6ac42

Browse files
committed
Merge pull request #3 from matt-d-rat/story/disable-towed-vehichles-from-towing
Bug - Disable Multi-tow
2 parents 6fb28e9 + 864d407 commit 3d6ac42

File tree

4 files changed

+45
-15
lines changed

4 files changed

+45
-15
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ MF-Tow is also fully compatible with the popular '=BTC=_Logistic (DayZ Epoch Ver
1818
- Disable towing of locked vehicles (optional)
1919
- Requires a player to have a toolbox in their inventory in order to be able to attach a tow.
2020

21-
## Configuring Tow Vehicles ##
21+
## Configuration ##
22+
23+
### Configuring tow vehicles & towable vehicles ###
2224

2325
[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 in a text editor.
2426

@@ -54,9 +56,19 @@ So for example, we can see that the code above permits the ```ArmoredSUV_PMC```
5456
To add a new vehicle which can be used as a towing vehicle, add a new case to the switch statement and define an array of the types of vehicles which can be towed (be careful not to have a trailing comma after the last entry in the array!):
5557

5658
```sqf
57-
case "Pickup_PK_INS_DZE": {_array = ["Motorcycle","Car"];};
59+
case "Pickup_PK_INS_DZE": {_array = ["Motorcycle","Car"];};
60+
```
61+
62+
### Enabling Multi-tow ###
63+
64+
By default, towing vehicles which are currently towing another vehicle is disabled (patched in v1.1.1). To enable this functionality, set the ```MF_Tow_Multi_Towing``` variable in ```init.sqf``` to true.
65+
66+
```sqf
67+
MF_Tow_Multi_Towing = true; // Warning, this is not recommended!
5868
```
5969

70+
Although this may seem like a nice feature, in reality the only purpose it will probably serve is to allow people to troll one another. The choice is entirely yours though :-).
71+
6072
## Installation Guide ##
6173

6274
- __Download__: https://github.com/matt-d-rat/mf-tow/archive/master.zip
@@ -240,6 +252,10 @@ __Step 18: Repack ```dayz_server.pbo``` and upload it to your server.
240252

241253
### Change Log ###
242254

255+
#### v1.1.1 ###
256+
- Fixed exploit which allowed players to tow vehicles which were already being towed.
257+
- Fixed exploit which allowed players to tow vehicles which were already towing another vehicle. This functionality can be turned back on via the ```MF_Tow_Multi_Towing``` config param being set to true (default value is false). Be warned, turning this on produces "interesting" results and probably only serves as a means for trolling.
258+
243259
#### v1.1.0 ###
244260
- Non-breaking changes to the check for whether the cursor target is a towable vehicle.
245261
- Deprecated MF_Tow_Towable variable as it is no longer used as a check condition.

init.sqf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
* The main script for initalising towing functionality.
44
*
55
* Created by Matt Fairbrass (matt_d_rat)
6-
* Version: 1.1.0
6+
* Version: 1.1.1
77
* MIT Licence
88
**/
99

1010
private ["_cursorTarget", "_towableVehicles", "_towableVehiclesTotal"];
1111

1212
// 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.
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+
MF_Tow_Multi_Towing = false; // Allow a vehicle which is towing another vehicle already to be towed by another tow. Disabled by default.
1516

1617
// Functions
1718

@@ -94,7 +95,7 @@ _towableVehiclesTotal = count (_towableVehicles);
9495
// Add the action to the players scroll wheel menu if the cursor target is a vehicle which can tow.
9596
if(_towableVehiclesTotal > 0) then {
9697
if (s_player_towing < 0) then {
97-
if(!(_cursorTarget getVariable ["MFTowInTow", false])) then {
98+
if(!(_cursorTarget getVariable ["MFTowIsTowing", false])) then {
9899
s_player_towing = player addAction ["Attach Tow", format["%1\tow_AttachTow.sqf", MF_Tow_Base_Path], _cursorTarget, 0, false, true, "",""];
99100
} else {
100101
s_player_towing = player addAction ["Detach Tow", format["%1\tow_DetachTow.sqf", MF_Tow_Base_Path], _cursorTarget, 0, false, true, "",""];

tow_AttachTow.sqf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* The action for attaching the tow to another vehicle.
44
*
55
* Created by Matt Fairbrass (matt_d_rat)
6-
* Version: 1.1.0
6+
* Version: 1.1.1
77
* MIT Licence
88
**/
99

@@ -48,6 +48,16 @@ if(_IsNearVehicle > 0) then {
4848
cutText [format["Cannot tow %1 because it is locked.", _vehicleNameText], "PLAIN DOWN"];
4949
};
5050

51+
// Check that the vehicle we want to tow is not already being towed by something else.
52+
if((_vehicle getVariable ["MFTowInTow", false])) exitWith {
53+
cutText [format["Cannot tow %1 because it is already being towed by another vehicle.", _vehicleNameText], "PLAIN DOWN"];
54+
};
55+
56+
// Check that the vehicle we want to tow is not already towing something else
57+
if(!MF_Tow_Multi_Towing && (_vehicle getVariable ["MFTowIsTowing", false])) exitWith {
58+
cutText [format["Cannot tow %1 because it is already towing another vehicle.", _vehicleNameText], "PLAIN DOWN"];
59+
};
60+
5161
_finished = false;
5262

5363
[_towTruck] call MF_Tow_Animate_Player_Tow_Action;
@@ -125,7 +135,8 @@ if(_IsNearVehicle > 0) then {
125135
// Detach the player from the tow truck
126136
detach player;
127137

128-
_towTruck setVariable ["MFTowInTow", true, true];
138+
_vehicle setVariable ["MFTowInTow", true, true];
139+
_towTruck setVariable ["MFTowIsTowing", true, true];
129140
_towTruck setVariable ["MFTowVehicleInTow", _vehicle, true];
130141

131142
cutText [format["%1 has been attached to %2.", _vehicleNameText, _towTruckNameText], "PLAIN DOWN"];

tow_DetachTow.sqf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* The action for detaching the tow from another vehicle.
44
*
55
* Created by Matt Fairbrass (matt_d_rat)
6-
* Version: 1.1.0
6+
* Version: 1.1.1
77
* MIT Licence
88
**/
99

10-
private ["_vehicle","_started","_finished","_animState","_isMedic","_vehicleNameText","_towTruckNameText","_towTruck","_inTow","_hasToolbox"];
10+
private ["_vehicle","_started","_finished","_animState","_isMedic","_vehicleNameText","_towTruckNameText","_towTruck","_isTowing","_hasToolbox"];
1111

1212
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_96") , "PLAIN DOWN"] };
1313
DZE_ActionInProgress = true;
@@ -20,14 +20,14 @@ _towTruck = _this select 3;
2020
_towTruckNameText = [_towTruck] call MF_Tow_Get_Vehicle_Name;
2121

2222
// exit if no vehicle is in tow.
23-
_inTow = _towTruck getVariable ["MFTowInTow", false];
23+
_isTowing = _towTruck getVariable ["MFTowIsTowing", false];
2424

25-
if(_inTow) then {
25+
if(_isTowing) then {
2626

2727
// Select the vehicle currently in tow
2828
_vehicle = _towTruck getVariable ["MFTowVehicleInTow", objNull];
2929

30-
if(!(isNull _towTruck)) then {
30+
if(!(isNull _vehicle)) then {
3131
_vehicleNameText = [_vehicle] call MF_Tow_Get_Vehicle_Name;
3232
_finished = false;
3333
_hasToolbox = "ItemToolbox" in (items player);
@@ -75,14 +75,16 @@ if(_inTow) then {
7575

7676
detach _vehicle;
7777
detach player;
78-
_towTruck setVariable ["MFTowInTow", false, true];
78+
79+
_vehicle setVariable ["MFTowInTow", false, true];
80+
_towTruck setVariable ["MFTowIsTowing", false, true];
7981
_towTruck setVariable ["MFTowVehicleInTow", objNull, true];
8082
cutText [format["%1 has been detached from %2.", _vehicleNameText, _towTruckNameText], "PLAIN DOWN"];
8183

8284
_vehicle setvelocity [0,0,1];
8385
};
8486
} else {
85-
_towTruck setVariable ["MFTowInTow", false, true];
87+
_towTruck setVariable ["MFTowIsTowing", false, true];
8688
_towTruck setVariable ["MFTowVehicleInTow", objNull, true];
8789
};
8890
} else {

0 commit comments

Comments
 (0)