Jump to content
Harkness

(UPDATE)MF-Tow 1.0.6.2

Recommended Posts

From what see this was made by user matt-d-rat about 6 years ago. All i did was light up a few smokes and update all the old variable names to get it running on our 1062 server from which we use a lot of scripts from here so here is a contribution back from me. I only added Epoch Vehicles in there.

Original Instructions

Original Thread

All you need to do is follow matt-d-rats Original Instructions above, But instead of using the old files he made use my edited versions below

mf-tow\init.sqf

Spoiler

/**
 * mf-tow/init.sqf
 * The main script for initalising towing functionality. 
 *
 * Created by Matt Fairbrass (matt_d_rat)
 * Version: 1.1.2
 * MIT Licence
 **/

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

// Public variables
MF_Tow_Base_Path        = "addons\mf-tow";         // The base path to the MF-Tow Folder.
MF_Tow_Distance            = 10;                    // Minimum distance (in meters) away from vehicle the tow truck must be to tow.
MF_Tow_Multi_Towing         = false;                // Allow a vehicle which is towing another vehicle already to be towed by another tow. Disabled by default.

// Functions

/**
 * Returns an array of towable objects which can be pulled by the tow truck.
 * Configure this as required to set which vehicles can pull which types of other vehicles.
 **/
MF_Tow_Towable_Array =
{
    private ["_array","_towTruck"];
    _towTruck = _this select 0;
    _array = [];
    
    switch (typeOf _towTruck) do
{
    // ATVs
        case "ATV_CZ_EP1":                         {_array = ["Motorcycle"];};
        case "ATV_US_EP1":                         {_array = ["Motorcycle"];};
    // Cars
        case "car_hatchback":                    {_array = ["Motorcycle","Car"];};
        case "car_sedan":                        {_array = ["Motorcycle","Car"];};
        case "GLT_M300_LT":                        {_array = ["Motorcycle","Car"];};
        case "GLT_M300_ST":                        {_array = ["Motorcycle","Car"];};
        case "Lada1":                            {_array = ["Motorcycle","Car"];};
        case "Lada1_TK_CIV_EP1":                {_array = ["Motorcycle","Car"];};
        case "Lada2":                            {_array = ["Motorcycle","Car"];};
        case "Lada2_TK_CIV_EP1":                {_array = ["Motorcycle","Car"];};
        case "LadaLM":                            {_array = ["Motorcycle","Car"];};
        case "UAZ_CDF":                            {_array = ["Motorcycle","Car"];};
        case "UAZ_INS":                            {_array = ["Motorcycle","Car"];};
        case "UAZ_MG_TK_EP1_DZE":                {_array = ["Motorcycle","Car"];};
        case "UAZ_RU":                            {_array = ["Motorcycle","Car"];};
        case "UAZ_Unarmed_TK_CIV_EP1":            {_array = ["Motorcycle","Car"];};
        case "UAZ_Unarmed_TK_EP1":                {_array = ["Motorcycle","Car"];};
        case "UAZ_Unarmed_UN_EP1":                {_array = ["Motorcycle","Car"];};
        case "VWGolf":                            {_array = ["Motorcycle","Car"];};
        case "Skoda":                            {_array = ["Motorcycle","Car"];};
        case "SkodaBlue":                        {_array = ["Motorcycle","Car"];};
        case "SkodaGreen":                        {_array = ["Motorcycle","Car"];};
        case "SkodaRed":                        {_array = ["Motorcycle","Car"];};
        case "VolhaLimo_TK_CIV_EP1":            {_array = ["Motorcycle","Car"];};
        case "Volha_1_TK_CIV_EP1":                {_array = ["Motorcycle","Car"];};
        case "Volha_2_TK_CIV_EP1":                {_array = ["Motorcycle","Car"];};
        case "S1203_ambulance_EP1":                {_array = ["Motorcycle","Car"];};
        case "S1203_TK_CIV_EP1":                {_array = ["Motorcycle","Car"];};
        case "LandRover_CZ_EP1":                {_array = ["Motorcycle","Car"];};
        case "LandRover_MG_TK_EP1_DZE":            {_array = ["Motorcycle","Car"];};
        case "LandRover_Special_CZ_EP1_DZE":    {_array = ["Motorcycle","Car"];};
        case "LandRover_TK_CIV_EP1":            {_array = ["Motorcycle","Car"];};
        case "datsun1_civil_1_open_DZE":        {_array = ["Motorcycle","Car"];};
        case "datsun1_civil_2_covered_DZE":        {_array = ["Motorcycle","Car"];};
        case "datsun1_civil_3_open_DZE":        {_array = ["Motorcycle","Car"];};
        case "hilux1_civil_1_open_DZE":            {_array = ["Motorcycle","Car"];};
        case "hilux1_civil_2_covered_DZE":        {_array = ["Motorcycle","Car"];};
        case "hilux1_civil_3_open_DZE":            {_array = ["Motorcycle","Car"];};
        case "Offroad_DSHKM_Gue_DZE":            {_array = ["Motorcycle","Car"];};
        case "Pickup_PK_GUE_DZE":                {_array = ["Motorcycle","Car"];};
        case "Pickup_PK_INS_DZE":                {_array = ["Motorcycle","Car"];};
        case "Pickup_PK_TK_GUE_EP1_DZE":        {_array = ["Motorcycle","Car"];};
        case "HMMWV_Ambulance":                    {_array = ["Motorcycle","Car"];};
        case "HMMWV_Ambulance_CZ_DES_EP1":        {_array = ["Motorcycle","Car"];};
        case "HMMWV_DES_EP1":                    {_array = ["Motorcycle","Car"];};
        case "HMMWV_DZ":                        {_array = ["Motorcycle","Car"];};
        case "HMMWV_M1035_DES_EP1":                {_array = ["Motorcycle","Car"];};
        case "HMMWV_M1151_M2_CZ_DES_EP1_DZE":    {_array = ["Motorcycle","Car"];};
        case "HMMWV_M998A2_SOV_DES_EP1_DZE":    {_array = ["Motorcycle","Car"];};
        case "ArmoredSUV_PMC_DZE":                {_array = ["Motorcycle","Car"];};
        case "SUV_Blue":                        {_array = ["Motorcycle","Car"];};
        case "SUV_Camo":                        {_array = ["Motorcycle","Car"];};
        case "SUV_Charcoal":                    {_array = ["Motorcycle","Car"];};
        case "SUV_Green":                        {_array = ["Motorcycle","Car"];};
        case "SUV_Orange":                        {_array = ["Motorcycle","Car"];};
        case "SUV_Pink":                        {_array = ["Motorcycle","Car"];};
        case "SUV_Red":                            {_array = ["Motorcycle","Car"];};
        case "SUV_Silver":                        {_array = ["Motorcycle","Car"];};
        case "SUV_TK_CIV_EP1":                    {_array = ["Motorcycle","Car"];};
        case "SUV_White":                        {_array = ["Motorcycle","Car"];};
        case "SUV_Yellow":                        {_array = ["Motorcycle","Car"];};
    // Trucks
        case "Kamaz_DZE":                        {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "KamazRefuel_DZ":                    {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "UralRefuel_TK_EP1_DZ":            {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "Ural_CDF":                        {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "Ural_TK_CIV_EP1":                    {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "Ural_UN_EP1":                        {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "V3S_Open_TK_CIV_EP1":                {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "V3S_Open_TK_EP1":                    {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "V3S_Refuel_TK_GUE_EP1_DZ":        {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "MtvrRefuel_DES_EP1_DZ":            {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "MTVR_DES_EP1":                    {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
    // Tractors
        case "tractor":                         {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
        case "TowingTractor":                     {_array = ["Motorcycle","Car","Truck","Wheeled_APC","Tracked_APC","Air"];};
    };    
    _array
};

/**
 * Animate the player in a towing action, whilst attaching them to the tow vehicle to ensure safety.
 **/
MF_Tow_Animate_Player_Tow_Action =
{
    private ["_towTruck","_offsetZ"];
    _towTruck = _this select 0;
    _offsetZ = 0.1;
    
    // Bounding box on UAZ is screwed, offset z-axis correctly
    if(_towTruck isKindOf "UAZ_Base") then {
        _offsetZ = 1.8;
    };
    
    [player,20,true,(getPosATL player)] spawn player_alertZombies; // Alert nearby zombies
    ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; // Use some hunger and thirst to perform the action
    
    // Attach the player to the tow truck temporarily for safety so that they aren't accidentally hit by the vehicle when it gets attached
    player attachTo [_towTruck, 
        [
            (boundingBox _towTruck select 1 select 0),
            (boundingBox _towTruck select 0 select 1) + 1,
            (boundingBox _towTruck select 0 select 2) - (boundingBox player select 0 select 2) + _offsetZ
        ]
    ];

    player setDir 270;
    player setPos (getPos player);
    player playActionNow "Medic"; // Force the animation
};

MF_Tow_Get_Vehicle_Name =
{
    private ["_vehicle", "_configVeh", "_vehicleName"];
    _vehicle = _this select 0;
    
    _configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle);
    _vehicleName = getText(_configVeh >> "displayName");
    
    _vehicleName
};

// Initialise script
_cursorTarget = cursorTarget;
_towableVehicles = [_cursorTarget] call MF_Tow_Towable_Array;
_towableVehiclesTotal = count (_towableVehicles);

// Add the action to the players scroll wheel menu if the cursor target is a vehicle which can tow.
if(_towableVehiclesTotal > 0) then {
    if (s_player_towing < 0) then {
        if(!(_cursorTarget getVariable ["MFTowIsTowing", false])) then {
            s_player_towing = player addAction ["Attach Tow", format["%1\tow_AttachTow.sqf", MF_Tow_Base_Path], _cursorTarget, 0, false, true, "",""];                
        } else {
            s_player_towing = player addAction ["Detach Tow", format["%1\tow_DetachTow.sqf", MF_Tow_Base_Path], _cursorTarget, 0, false, true, "",""];            
        };
    };

else {
    player removeAction s_player_towing;
    s_player_towing = -1;
};

mf-tow\tow_AttachTow.sqf

Spoiler

/**
 * mf-tow/tow_AttachTow.sqf
 * The action for attaching the tow to another vehicle. 
 *
 * Created by Matt Fairbrass (matt_d_rat)
 * Version: 1.1.2
 * MIT Licence
 **/

private ["_vehicle","_started","_finished","_animState","_isMedic","_abort","_vehicleNameText","_towTruckNameText","_findNearestVehicles","_findNearestVehicle","_IsNearVehicle","_towTruck","_towableVehicles","_towableVehiclesTotal","_vehicleOffsetY","_towTruckOffsetY","_offsetZ","_hasToolbox"];

if(dayz_actionInProgress) exitWith { cutText [(localize "str_epoch_player_96") , "PLAIN DOWN"] };
dayz_actionInProgress = true;

player removeAction s_player_towing;
s_player_towing = 1;

// Tow Truck
_towTruck = _this select 3;
_towableVehicles = [_towTruck] call MF_Tow_Towable_Array;
_towableVehiclesTotal = count (_towableVehicles);
_towTruckNameText = [_towTruck] call MF_Tow_Get_Vehicle_Name;

// Get all nearby vehicles that can be towed by the towTruck within the minimum tow distance
_findNearestVehicles = nearestObjects [_towTruck, _towableVehicles, MF_Tow_Distance];
_findNearestVehicle = [];
{
    if (alive _x && _towTruck != _x) then {
        _findNearestVehicle set [(count _findNearestVehicle),_x];
    };
} foreach _findNearestVehicles;
        
_IsNearVehicle = count (_findNearestVehicle);

if(_IsNearVehicle > 0) then {
    // select the nearest one
    _vehicle = _findNearestVehicle select 0;
    _vehicleNameText = [_vehicle] call MF_Tow_Get_Vehicle_Name;
    _hasToolbox = "ItemToolbox" in (items player);
    
    // Check the player has a toolbox
    if(!_hasToolbox) exitWith {
        cutText ["Cannot attach tow without a toolbox.", "PLAIN DOWN"];
    };
    
    // Check if the vehicle we want to tow is locked
    if((_vehicle getVariable ["MF_Tow_Cannot_Tow", false])) exitWith {
        cutText [format["Cannot tow %1 because it is locked.", _vehicleNameText], "PLAIN DOWN"];
    };
    
    // Check that the vehicle we want to tow is not already being towed by something else.
    if((_vehicle getVariable ["MFTowInTow", false])) exitWith {
        cutText [format["Cannot tow %1 because it is already being towed by another vehicle.", _vehicleNameText], "PLAIN DOWN"];
    };
    
    // Check that the vehicle we want to tow is not already towing something else
    if(!MF_Tow_Multi_Towing && (_vehicle getVariable ["MFTowIsTowing", false])) exitWith {
        cutText [format["Cannot tow %1 because it is already towing another vehicle.", _vehicleNameText], "PLAIN DOWN"];
    };
    
    // Check if the vehicle has anyone in it
    if ((count (crew _vehicle)) != 0) exitWith {
        cutText [format["Cannot tow %1 because it has people in it.", _vehicleNameText], "PLAIN DOWN"];
    };
    
    _finished = false;
    
    [_towTruck] call MF_Tow_Animate_Player_Tow_Action;
    
    r_interrupt = false;
    _animState = animationState player;
    r_doLoop = true;
    _started = false;

    while {r_doLoop} do {
        _animState = animationState player;
        _isMedic = ["medic",_animState] call fnc_inString;
        if (_isMedic) then {
            _started = true;
        };
        
        if (_started and !_isMedic) then {
            r_doLoop = false;
            _finished = true;
        };
        
        // Check if anyone enters the vehicle while we are attaching the tow and stop the action
        if ((count (crew _vehicle)) != 0) then {
            cutText [format["Towing aborted because the %1 was entered by another player.", _vehicleNameText], "PLAIN DOWN"];
            r_interrupt = true;
        };
        
        if (r_interrupt) then {
            detach player;
            r_doLoop = false;
        };
        
        sleep 0.1;
    };
    r_doLoop = false;

    if(!_finished) then {
        r_interrupt = false;
            
        if (vehicle player == player) then {
            [objNull, player, rSwitchMove,""] call RE;
            player playActionNow "stop";
        };
        _abort = true;
    };

    if (_finished) then {
        if(((vectorUp _vehicle) select 2) > 0.5) then {
            if( _towableVehiclesTotal > 0 ) then {
                _towTruckOffsetY = 0.8;
                _vehicleOffsetY = 0.8;
                _offsetZ = 0.1;
                
                // Calculate the offset positions depending on the kind of tow truck                
                switch(true) do {
                    case (_towTruck isKindOf "ArmoredSUV_Base_PMC");
                    case (_towTruck isKindOf "SUV_Base_EP1") : {
                        _towTruckOffsetY = 0.9;
                    };
                    case (_towTruck isKindOf "UAZ_Base" && !(_vehicle isKindOf "UAZ_Base")) : {
                        _offsetZ = 1.8;
                    };
                };
                
                // Calculate the offset positions depending on the kind of vehicle
                switch(true) do {
                    case (_vehicle isKindOf "Truck" && !(_towTruck isKindOf "Truck")) : {
                        _vehicleOffsetY = 0.9;
                    };
                    case (_vehicle isKindOf "UAZ_Base" && !(_towTruck isKindOf "UAZ_Base")) : {
                        _offsetZ = -1.8;
                    };
                };
                    
                // Attach the vehicle to the tow truck
                _vehicle attachTo [ _towTruck,
                    [
                        0,
                        (boundingBox _towTruck select 0 select 1) * _towTruckOffsetY + (boundingBox _vehicle select 0 select 1) * _vehicleOffsetY,
                        (boundingBox _towTruck select 0 select 2) - (boundingBox _vehicle select 0 select 2) + _offsetZ
                    ]
                ];
                
                detach player;
                _vehicle lock true; // Disable entering the vehicle while it is in tow.
                
                _vehicle setVariable ["MFTowInTow", true, true];
                _towTruck setVariable ["MFTowIsTowing", true, true];
                _towTruck setVariable ["MFTowVehicleInTow", _vehicle, true];
                
                cutText [format["%1 has been attached to %2.", _vehicleNameText, _towTruckNameText], "PLAIN DOWN"];
            };    
        } else {
            cutText [format["Failed to attach %1 to %2.", _vehicleNameText, _towTruckNameText], "PLAIN DOWN"];
        };
    };
} else {
    cutText [format["No vehicles nearby to tow. Move within %1m of a vehicle.", MF_Tow_Distance], "PLAIN DOWN"];
};
dayz_actionInProgress = false;
s_player_towing = -1;

mf-tow\tow_DetachTow.sqf

Spoiler

/**
 * mf-tow/tow_DetachTow.sqf
 * The action for detaching the tow from another vehicle. 
 *
 * Created by Matt Fairbrass (matt_d_rat)
 * Version: 1.1.2
 * MIT Licence
 **/
 
private ["_vehicle","_started","_finished","_animState","_isMedic","_vehicleNameText","_towTruckNameText","_towTruck","_isTowing","_hasToolbox"];

if(dayz_actionInProgress) exitWith { cutText [(localize "str_epoch_player_96") , "PLAIN DOWN"] };
dayz_actionInProgress = true;

player removeAction s_player_towing;
s_player_towing = 1;

// Tow Truck
_towTruck = _this select 3;
_towTruckNameText = [_towTruck] call MF_Tow_Get_Vehicle_Name;

// exit if no vehicle is in tow.
_isTowing = _towTruck getVariable ["MFTowIsTowing", false];

if(_isTowing) then {

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

    if(!(isNull _vehicle)) then {
        _vehicleNameText = [_vehicle] call MF_Tow_Get_Vehicle_Name;
        _finished = false;        
        _hasToolbox = "ItemToolbox" in (items player);
        
        // Check the player has a toolbox
        if(!_hasToolbox) exitWith {
            cutText ["Cannot dettach tow without a toolbox.", "PLAIN DOWN"];
        };
        
        [_towTruck] call MF_Tow_Animate_Player_Tow_Action;

        r_interrupt = false;
        _animState = animationState player;
        r_doLoop = true;
        _started = false;

        while {r_doLoop} do {
            _animState = animationState player;
            _isMedic = ["medic",_animState] call fnc_inString;
            if (_isMedic) then {
                _started = true;
            };
            if (_started and !_isMedic) then {
                r_doLoop = false;
                _finished = true;
            };
            if (r_interrupt) then {
                detach player;
                r_doLoop = false;
            };
            sleep 0.1;
        };
        r_doLoop = false;

        if(!_finished) then {
            r_interrupt = false;
            
            if (vehicle player == player) then {
                [objNull, player, rSwitchMove,""] call RE;
                player playActionNow "stop";
            };
        };

        if (_finished) then {
            detach _vehicle;
            detach player;
            _vehicle lock false; // Enable players to re-enter the vehicle now it has been detached.
                        
            _vehicle setVariable ["MFTowInTow", false, true];
            _towTruck setVariable ["MFTowIsTowing", false, true];
            _towTruck setVariable ["MFTowVehicleInTow", objNull, true];
            cutText [format["%1 has been detached from %2. Start engine to save new possition", _vehicleNameText, _towTruckNameText], "PLAIN DOWN"];
            
            _vehicle setvelocity [0,0,1];
        };
    } else {
        _towTruck setVariable ["MFTowIsTowing", false, true];
        _towTruck setVariable ["MFTowVehicleInTow", objNull, true];    
    };
} else {
    cutText ["No vehicles in tow.", "PLAIN DOWN"];
};
dayz_actionInProgress = false;
s_player_towing = -1;

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Similar Content

    • By Harkness
      Client Mods;
      @Expansion / @Trader / @Trader Wallet / @No-Vehicle-Damage / @Fast Travel / @Dmns_Vehicles
      Added Mods/Features:
      DayZ Vehicles / Arma Vehicles / Expansion Vehicles
      Survivor Missions Stories
      Fast Travel
      No Vehicle Damage
      Trader
      Money Wallet
      DayZ Expansion Mods/Features;
      Global, Admin, Party and Transport Chat
      Airdrops
      Notification System
      Territories System
      Auto-run System
      No Stamina System
      Safezone System
      Mission System
      Book (Server Info, Rules, player stats, party management , territory management) System
      Skin System
      Map UI and 2D/3D Markers System
      KillFeed System
      Towing System
      Player Attachement
      Custom mapping in many cities of Chernarus
      Custom trader locations
      Custom lighting
      Custom interiors
      Custom ocean
      Working Street lights
      Builderitems
      Gravecross
      KillFeed
      Notifications
      Gravecross
      Horn
      Autorun
      No stamina
      MoreGuns
      Street lights
      Car Keys
      CodeLock
      Map UI and 2D/3D Markers
      Global/Transport/Party Chat
      Extras;
      Address: 86.31.253.6   Port: 2402
      Visit Time2Kill.co.uk for more info
      Discord Invite Link
    • By THAC0_Gewch
      Many years ago, I made a Humanity Loadout script for 1.0.5.x. The script is basic, it checks your players' humanity and grants a pre-set loadout when they spawn depending on their humanity level.
      I've now updated and optimized this script for 1.0.6.x:
      https://github.com/OlofTheBald/DayZ-Humanity-Loadout-Granter
       
       
    • By stephen21k
      Dose anyone know where to find Updated/Working files for DayZ OverPochIns Taviana?
    • By Cyrus
      I know of some questions in the forums regarding custom loot crates with available missions systems. I have managed to create a custom loot crate thanks to @DAmNRelentless help, that randomizes items and weapons from user customizable arrays and integrate this with the mission system. This for the time being works for DZAI on Epoch 1.0.6.2. 
      Following is my custom lootcrate.sqf , all the classnames used is from the official epoch 1.0.6.2 github repo with thanks to @salival found >here<
      From here I have added the following script to my custom DZAI spawns found in \z\addons\dayz_server\DZAI\init\world_spawn_configs\custom_spawns\cust_spawns_panthera2.sqf. Obviously you will use the sqf appropriate to your map etc.
      ["staticspawn",10,2,true] call DZAI_spawn_units; if {DZAI_spawn_units && DZAI_despawnWait == true} then { execVM "\z\addons\dayz_server\custom\lootcrate.sqf"; }; This method might need some tweaking and someone else might have a more effective way of doing this, but for me this works perfectly. Fully tested with random loot spawns after new AI group spawned.
    • By Cyrus
      Can anyone familiar with DZAI help me with a way to time my custom crates to respawn with DZAI custom static AI. I have the randomized crate spawn at server startup, and essentially will be looted once the base has been cleared from all AI. Currently it will "refill" the crate based on a sleep timer. I would like to have the crate refill once the next round of AI spawns based on these values set:
      DZAI_respawnTimeMin = 300; DZAI_respawnTimeMax = 600; Any help will be appreciated. This is my current loot crate configuration. Thanks for @DAmNRelentless who guided me in creating this script.
       
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...