Vehicle repair script

Mattz

Member
This adds a repair station to NWAF

5xTQejG.jpg



Find it heree:
https://github.com/MattzFiber/DayZ-Repair-Script

Very similar to my past works, enjoy!Post here with comments and feedback
 
My pleasure mate :)
This was placed down the runway so that its not right there at the aammo thing, so not to be OP :p
 
I asked mattz to add this because I noticed he didnt have it. He asked if I wanted it to be just for us, or for public so I said he should make it public. Glad he did. I did notice though that when I added it, I didn't see it anywhere on the airfield at first, then I noticed it was right next to the industrial area next to the north barracks. I also noticed when looking at the part where you add the building in the mission.sqm, that it was not linked to the script to start the repairs. After tweaking it a bit, I decided to edit the script for the rearming station with a bit of mattz help and overlook, and we came up with this. It will take a bit longer for repairs and rearming now, but it will also fully refuel your helicopter as well, or any other vehicle you drive onto the heli pad for that matter. Here is the coding:

Code:
//Edited by =82nd=Dlcoates1 for Mattz for DayZ
private ["_config","_count","_i","_magazines","_object","_type","_type_name","_OldFuel"];
_object = _this select 0;
_type = typeof _object;
_OldFuel = fuel _object;
if (_object isKindOf "ParachuteBase") exitWith {};
if (!alive _object) exitWith {};
_object setVehicleAmmo 1;    // Reload turrets / drivers magazine
_type_name = typeOf _object;
_object vehicleChat format ["Reloading, Repairing, and Refueling %1... Please stand by...", _type];
sleep 6;
_object setFuel 0;
sleep 6;
_object vehicleChat format ["This does take time... Please stand by...", _type];
sleep 6;
_magazines = getArray(configFile >> "CfgVehicles" >> _type >> "magazines");
if (count _magazines > 0) then {
    _removed = [];
    {
        if (!(_x in _removed)) then {
            _object removeMagazines _x;
            sleep 12;
            _removed set [count _removed, _x];
        };
    } forEach _magazines;
    {
        _object vehicleChat format ["Reloading %1", _x];
        sleep 13;
        if (!alive _object) exitWith {};
        _object addMagazine _x;
    } forEach _magazines;
};
_count = count (configFile >> "CfgVehicles" >> _type >> "Turrets");
if (_count > 0) then {
    for "_i" from 0 to (_count - 1) do {
        scopeName "xx_reload2_xx";
        _config = (configFile >> "CfgVehicles" >> _type >> "Turrets") select _i;
        _magazines = getArray(_config >> "magazines");
        _removed = [];
        {
            if (!(_x in _removed)) then {
                _object removeMagazines _x;
                _removed set [count _removed, _x];
            };
        } forEach _magazines;
        {
            _object vehicleChat format ["Reloading %1", _x];
            sleep 15;
            if (!alive _object) then {breakOut "xx_reload2_xx"};
            _object addMagazine _x;
            sleep 14;
            if (!alive _object) then {breakOut "xx_reload2_xx"};
        } forEach _magazines;
        _count_other = count (_config >> "Turrets");
        if (_count_other > 0) then {
            for "_i" from 0 to (_count_other - 1) do {
                _config2 = (_config >> "Turrets") select _i;
                _magazines = getArray(_config2 >> "magazines");
                _removed = [];
                {
                    if (!(_x in _removed)) then {
                        _object removeMagazines _x;
                        _removed set [count _removed, _x];
                    };
                } forEach _magazines;
                {
                    _object vehicleChat format ["Reloading %1", _x];
                    sleep 15;
                    if (!alive _object) then {breakOut "xx_reload2_xx"};
                    _object addMagazine _x;
                    sleep 15;
                    if (!alive _object) then {breakOut "xx_reload2_xx"};
                } forEach _magazines;
            };
        };
    };
};
_object setVehicleAmmo 1;
_object vehicleChat format ["Your vehicle has been rearmed... Beginning repairs...  Please stand by...", _type];
sleep 6;
_object vehicleChat format ["Repairing %1... Please stand by...", _type];
sleep 20;
_object setDamage 0;    // Fix Vehicle
_object vehicleChat format ["Your vehicle has been repaired... Beginning refueling process...", _type];
sleep 6;
_object vehicleChat format ["Refueling %1... Please stand by...", _type];
sleep 20;
_object setFuel 1;
if (!alive _object) exitWith {};
_object vehicleChat format ["Your vehicle has been repaired, rearmed, and refueled... It is now safe to take off...", _type];
if (true) exitWith {};

As I said, it takes a while longer. Looking at the code, it takes about 1 - 2 minutes total, depending on the vehicle, the amount of ammo it holds, the fuel, and total damage to it. Comes in handy with R3F Logistics so you can tow vehicles to it, or even airlift them, as we have done on the server I run. If you wish to use this code, just edit the MZ_helo.sqf file and replace the current code with this. If you already have the auto rearming that is.
 
Cool stuff - I'll probably have one of these all in 1 types in the focal point of my map (Massive custom prison/town)

EDIT: Map is Celle, fellow admin of mine made it - It's actually freaking awesome and absolutely massive... And in the middle of that flat part with no trees, shrouded in permanent fog (thanks to that other thread!)... Excited to make it have its own loot table to attract players to come get some of the cooler custom guns Celle has to offer.
 
Say I wanted to increase the time it takes to complete all these tasks - Which parts would I manipulate? The various sleeps I assume?

And does this replace the need for all 3 MZ's?
 
Say I wanted to increase the time it takes to complete all these tasks - Which parts would I manipulate? The various sleeps I assume?

And does this replace the need for all 3 MZ's?

Correct, just modify the sleep times to make it faster or longer.

If you wish for it to replace all 3 of the MZ scripts, just rename it to MZ_reload and delete the old MZ_reload so that way all gas stations will rearm, repair, and refuel. Keep in mind that this is only optional.
 
The repair center is not what executes the script, but rather a trigger based on distance and location. Unfortunately, I don't know too much on how it works, so you will have to talk to someone like Axeman or Mattz about it.
 
This is what mine looks like, do not use mine as your own, it is only used as an example, using mine exactly how I have it may end up in an error on your side.

Code:
class Item17
 
{
 
position[]={4615.0078,339,9869.3428};
 
a=6;
 
b=6;
 
activationBy="ANY";
 
repeating=1;
 
interruptable=1;
 
age="UNKNOWN";
 
name="HeliReload";
 
expCond="this and ((getpos (thislist select 0)) select 2 < 1)";
 
expActiv="_xhandle= [(thislist select 0)] execVM ""scriptsMZ\MZ_repair.sqf"";";
 
class Effects
 
{
 
};
 
};
 
Where would I add this into the mission.sqm and what should I add in? Sorry but I'm a bit confused
 
Just tried on my server, it doesn't work :(

I placed the .gitattributes, .gitignore & ScriptsMZ inside the dayz_mission.pbo.
And then you wrote something "After the 99 survivor spawn points, but above class markers."
So then i put the rest of the code inside mission.sqm it in here:
Code:
        class Item1
        {
            side="LOGIC";
            class Vehicles
            {
                items=2;
                class Item0
                {
                    position[]={708.96582,35.858719,3533.1272};
                    id=50;
                    side="LOGIC";
                    vehicle="FunctionsManager";
                    leader=1;
                    lock="UNLOCKED";
                    skill=0.60000002;
                };
                class Item1
                {
                position[]={4236.9863,338.99933,10923.414};
                azimut=330;
                id=1;
                side="EMPTY";
                vehicle="Land_repair_center";
                leader=1;
                skill=0.60000002;
                };
            };   
            class Sensors
            {
                items=1;
                class Item0
                {
                    position[]={4238.939,339,10922.089};
                    a=10;
                    b=10;
                    interruptable=1;
                    age="UNKNOWN";
                    class Effects
                    {
                    };
                };
            };
        };
 
@Mortem Elholm

I believe the code he submitted is incomplete, as the sensor portion when added to the mission.sqm does not have the code to execute the actual repair. Either that, or I'm going to the wrong one. I need to test this, but I think the full code for the Class Sensor should be as such:

Code:
class ItemX
        {
            position[]={4238.939,339,10922.089};
            a=10;
            b=10;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            expCond="this and ((getpos (thislist select 0)) select 2 < 1)";
            expActiv="_xhandle= [(thislist select 0)] execVM ""scriptsMZ\MZ_repair.sqf"";";
            class Effects
            {
            };
        };
    };
    class Markers

ItemX - "X" stands for the next number in the sequence of class Items you have (mine is 17). Also, remember to count up all the class Items you do have at the top where it says

Code:
class Sensors
    {
        items=18;
        class Item0

Where I have 18 items in total, starting with class Item0.

Where I have a question is this, where do you get the position codes for various buildings in the map? I want to add the repair code to two pre-existing locations in Elektro and Cherno that look like repair shops, but I'm not sure how to get the codes for the getDir or getPos.

Also, there's an "vehicle" you can add via 3D editor mission.sqf files, that's called "USMC_WarfareBVehicleServicePoint", which does exactly what this script set out to do, but does repairs, refueling, and ammo all in the scroll when you're close enough to it. Does any one know how I can find the code that belongs to this object so I can manipulate it on the map and make it have a slower fill rate?
 
Back
Top