Announcement

Collapse
No announcement yet.

Looking For Vehicle Repair / Respawn Script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking For Vehicle Repair / Respawn Script

    Looking for a script (or for someone to make me a script) that does the following...


    For the sake of example, we have two vehicles. One is named Repair, the other is named Car.
    1. Checks if one vehicle is within range of the other. Range being ~10m.
    2. Checks if Car is destroyed.
    3. Puts a scrollwheel addaction on Car.
    4. Waits a set time, probably around 5 minutes. (Preferably giving local silent hints / text on direct giving ETA on timer finishing.)
    5. If Repair goes out of range of Car during this time, the timer / script will stop, and you'll need to start again.
    6. Either prevents further scrollwheel interractions with the wreck (or gives a player-only hint saying, "This is already being repaired") while Car is being repaired.
    7. Despawns Car and replaces it with a non-wreck version in the exact same location, preferably with the same vehicle name. (Or just magically reverts vehicle to un-wrecked state, but that's probably harder.)


    Script Purpose: Vehicles lost are not lost forever. However, Repair does not respawn (or has very limited respawns), so you need to make sure the area is completely secure before you bring in Repair to get a vehicle back again. The idea is to make it so you look after assets, but the mission doesn't instantly become impossible if an essential vehicle is lost early on.

    Pepper

    "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

  • #2
    Re: Looking For Vehicle Repair / Respawn Script

    file repair1.sqf
    Code:
    if (isServer) then {
    	_car = _this select 0;
    	_rt = _this select 1;
    	_time = _this select 2;
    	_type = typeOf _car;
    	if (alive _rt) then {
    		while {alive _car && alive _rt} do {
    			while {(damage _car) == 0 && alive _car && alive _rt} do {sleep 5};
    			while {(damage _car) > 0 && alive _car && (_car distance _rt) > 10 && alive _rt} do {sleep 5};
    			_pos = getPos _car;
    			_dir = getDir _car;
    			if ((_car distance _rt) < 11 && alive _car && alive _rt) then {
    				_val =_car addAction ["Repair","repair2.sqf",[_rt, _time]];
    				while {(damage _car) > 0 && alive _car && alive _rt && (_car distance _rt) < 11} do {sleep 5};
    				_car removeAction _val;
    			};
    		};
    		if (!alive _rt) exitWith {};
    		sleep 300;
    		deletevehicle _car;
    		_car = _type createVehicle _pos;
    		_car setdir _dir;
    		_car setpos _pos;
    		[_car,_rt,_time] execVM "repair1.sqf";
    	};
    };
    sleep 300 - how many seconds destroyed vehicle will burn be4 respawn


    file repair2.sqf
    Code:
    if (isServer) then {
    	_car = _this select 0;
    	_pl = _this select 1;
    	_id = _this select 2;
    	_rt = (_this select 3) select 0;
    	_time = ((_this select 3) select 1) - 1;
    	_car removeAction _id;
    	for "_i" from 0 to _time do {
    		if ((_car distance _rt) < 11 && alive _car && alive _rt && (damage _car) > 0) then {
    			for "_z" from 0 to 3 do {
    				hint "Repairing vehicle..";
    				sleep 20; //hint time
    			};
    		};
    	};
    	if ((_car distance _rt) < 11 && alive _car && alive _rt && (damage _car) > 0) then {
    		_car setDamage 0;
    		hint "Repair complete";
    	} else {
    		hint "Repair aborted..";
    	};
    };
    sleep 20 - each 20 seconds player will c hint that vehicle repairing if truck close and all vehicles alive. better dont change it coz have to change _z too, but u able to change hint strings. To let everybody know that u repair this car u can change hint to player groupChat or player sideChat.


    in initialization of each vehicle that should have repair action add this string
    Code:
    call {[this, RT, 5] execVM "repair1.sqf"};
    where RT - name of repair truck, 5 - how many minutes will take repairing this vehicle (able to change time 4 each vehicle ex UAZ - 2, BMP - 10 (hint: faster get in truck and repair by standart action))


    P.S. why u cant repair veh by standart action of repair truck? BTW with this script u can use any veh as repair truck, need only name of this veh
    P.P.S. again sry 4 my English :)
    Last edited by Chichco; 04-28-2012, 08:04 PM.

    Comment


    • #3
      Re: Looking For Vehicle Repair / Respawn Script

      Thank you! Putting it in and running tests now.

      P.S. why u cant repair veh by standart action of repair truck? BTW with this script u can use any veh as repair truck, need only name of this veh
      P.P.S. again sry 4 my English :)
      So then people need to wait for secondaries to stop before going near the vehicle.

      Pepper

      "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

      Comment


      • #4
        Re: Looking For Vehicle Repair / Respawn Script

        Not working in testing. No script errors, but there's no addaction either.

        Edit: Removed the if:Server thing to get it to run on single player, still doesn't work. Again, no script errors.
        Last edited by Athanasa; 04-29-2012, 01:26 PM.

        Pepper

        "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

        Comment


        • #5
          Re: Looking For Vehicle Repair / Respawn Script

          Strange, it's working 4 me.. 2morrow i'll be at evening, find me in TS and poke, will test it 2gether..

          p.s. 1) do u damage car be4 trying repair it? 2) "Repair" should be in damaged car, not in repair vehicle menu and only if car damaged and repair vehicle in distance <=10 meters 3) respawn dead veh workin? (300 sec = 5 min) 4) dont remove isServer, should be run once
          Last edited by Chichco; 04-29-2012, 04:58 PM.

          Comment


          • #6
            Re: Looking For Vehicle Repair / Respawn Script

            1) I completely destroyed the car (actually a tank, changed variable name to "tank", but doubt that will have affected anything.)
            2) Put repair in both vehicles, just to make sure. Changed distance to make sure it wasn't broken from that either.
            3) Changed timer to see if it would work a few times. Still no addaction.
            4) Tried both with isServer and without - shouldn't make a difference. Also, as it wasn't a server (single player), assumed that would be what broke it?



            Been able to magically repair the tank by making a simple addaction that sets damage to 0, but I've found no way to make that trigger off proximity to RT, or time. Very new to scripting; I just made an .sqf that said, "tank setdamage 0".

            Pepper

            "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

            Comment


            • #7
              Re: Looking For Vehicle Repair / Respawn Script

              Edit: Realised I don't have to destroy the vehicle and respawn it. I can just repair it. However, there's the issue of the wreck tending to dissapear after 5 minutes.

              Pepper

              "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

              Comment


              • #8
                Re: Looking For Vehicle Repair / Respawn Script

                file repair1.sqf
                Code:
                if (isServer) then {
                	_car = _this select 0;
                	_rt = _this select 1;
                	_time = _this select 2;
                	_type = typeOf _car;
                	_pos = getPos _car;
                	_dir = getDir _car;
                	if (alive _rt) then {
                		while {alive _car && alive _rt} do {
                			while {(damage _car) == 0 && alive _car && alive _rt} do {sleep 5};
                			while {(damage _car) > 0 && alive _car && (_car distance _rt) > 10 && alive _rt} do {sleep 5};
                			_pos = getPos _car;
                			_dir = getDir _car;
                			if ((_car distance _rt) < 11 && alive _car && alive _rt) then {
                				_val =_car addAction ["Repair","repair2.sqf",[_rt, _time]];
                				while {(damage _car) > 0 && alive _car && alive _rt && (_car distance _rt) < 11} do {sleep 5};
                				_car removeAction _val;
                			};
                		};
                		if (!alive _rt) exitWith {};
                		sleep 300;
                		deleteVehicle _car;
                		_car = _type createVehicle _pos;
                		_car setdir _dir;
                		_car setpos _pos;
                		[_car,_rt,_time] execVM "repair1.sqf";
                	};
                };
                file repair2.sqf
                Code:
                if (isServer) then {
                	_car = _this select 0;
                	_pl = _this select 1;
                	_id = _this select 2;
                	_rt = (_this select 3) select 0;
                	_time = ((_this select 3) select 1) - 1;
                	_car removeAction _id;
                	ScopeName "Repair";
                	if ((_car distance _rt) < 11 && alive _car && alive _rt && (damage _car) > 0) then {
                		for "_i" from 0 to _time do {
                			for "_z" from 0 to 5 do {
                				if (!((_car distance _rt) < 11 && alive _car && alive _rt && (damage _car) > 0)) then {breakTo "Repair"};
                				hint "Repairing vehicle..";
                				sleep 10;
                			};
                		};
                	};
                	if ((_car distance _rt) < 11 && alive _car && alive _rt && (damage _car) > 0) then {
                		_car setDamage 0;
                		hint "Repair complete";
                	} else {
                		hint "Repair aborted..";
                	};
                };
                Repair only when repair car close. Respawn only when repair car alive. Respawn time = 0, Repair time = 60 sec.
                Last edited by Chichco; 04-30-2012, 05:03 PM. Reason: added video

                Comment

                Connect

                Collapse

                TeamSpeak 3 Server

                Collapse

                Advertisement

                Collapse

                Twitter Feed

                Collapse

                Working...
                X