Jump to content
Sign in to follow this  
Gunnykat

Repair and service script

Recommended Posts

Ok I found a script but the only bad thing is it repairs every 10 seconds anywhere. What I need for realism is a script for repair for instance when I land on the LHD. I know they have stuff in the game that repairs your vehicle when you get near it . But it looks crazy to have a vehicle repair station on a LHD deck. So is there a script that is around already made that works off trigers. Thanks.

---------- Post added at 12:32 AM ---------- Previous post was at 12:27 AM ----------

I might have found one. If it works I will let you know.

Share this post


Link to post
Share on other sites

From Xeno's Scripts, if there is a better way of running this script please let me know, after two days of looking through Domination I finally got it to work right.

x_reload.sqf

private ["_config","_count","_i","_magazines","_object","_type","_type_name"];

_object = _this select 0;

_type = typeof _object;

if (_object isKindOf "ParachuteBase") exitWith {};

//if (!local _object) exitWith {};

if (!alive _object) exitWith {};
_object setFuel 0;
_object setVehicleAmmo 1;	// Reload turrets / drivers magazine

_type_name = typeOf _object;

_object vehicleChat format ["Servicing %1... Please stand by...", _type];

_magazines = getArray(configFile >> "CfgVehicles" >> _type >> "magazines");

if (count _magazines > 0) then {
_removed = [];
{
	if (!(_x in _removed)) then {
		_object removeMagazines _x;
		_removed = _removed + [_x];
	};
} forEach _magazines;
{
	_object vehicleChat format ["Reloading %1", _x];
	sleep 4;
	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 = _removed + [_x];
		};
	} forEach _magazines;
	{
		_object vehicleChat format ["Reloading %1", _x];
		sleep 4;
		if (!alive _object) then {breakOut "xx_reload2_xx"};
		_object addMagazine _x;
		sleep 4;
		if (!alive _object) then {breakOut "xx_reload2_xx"};
	} forEach _magazines;
	// check if the main turret has other turrets
	_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 = _removed + [_x];
				};
			} forEach _magazines;
			{
				_object vehicleChat format ["Reloading %1", _x]; 
				sleep 4;
				if (!alive _object) then {breakOut "xx_reload2_xx"};
				_object addMagazine _x;
				sleep 4;
				if (!alive _object) then {breakOut "xx_reload2_xx"};
			} forEach _magazines;
		};
	};
};
};
_object setVehicleAmmo 1;	// Reload turrets / drivers magazine

sleep 4;
if (!alive _object) exitWith {};
_object vehicleChat "Repairing...";
_object setDamage 0;
sleep 4;
if (!alive _object) exitWith {};
_object vehicleChat "Refueling...";
while {fuel _object < 0.99} do {
//_object setFuel ((fuel _vehicle + 0.1) min 1);
_object setFuel 1;
sleep 0.01;
};
sleep 4;
if (!alive _object) exitWith {};
_object vehicleChat format ["%1 is ready...", _type_name];

if (true) exitWith {};

Create a trigger (this is where your helicopter will land to be serviced)

Activation Anybody Present

Set to Repeat

Condition

("Helicopter" countType thislist  > 0) && ((getpos (thislist select 0)) select 2 < 1)

On activation

_xhandle= [(thislist select 0)] execVM "x_reload.sqf";

Create a trigger (this is where your land vehicles will be serviced)

Activation Anybody Present

Set to Repeat

Condition

("LandVehicle" countType thislist  > 0) && ((getpos (thislist select 0)) select 2 < 1)

On activation

_xhandle= [(thislist select 0)] execVM "x_reload.sqf";

Create a trigger (this is where your wing vehicles will be serviced)

Activation Anybody Present

Set to Repeat

Condition

("Plane" countType thislist  > 0) && ((getpos (thislist select 0)) select 2 < 1) && (speed (thislist select 0) < 10)

On activation

_xhandle= [(thislist select 0)] execVM "x_reload.sqf";

Edited by cobra4v320

Share this post


Link to post
Share on other sites

What does the middle part of the script do (well I see what it does, more like why it does that)? Just curious. I thought setVehicleAmmo covered the ammo and you'd count it up just like health and fuel.

Share this post


Link to post
Share on other sites

@ Murklor

This is Xeno's script, and its pretty awesome. When you land at the service point it shuts off the heli, removes all fuel, removes ammo, and then slowly starts to reload the heli (magazine by magazine), it repairs, then gives it fuel.

I have also modified the above script so it doesnt need all of that other information I originally posted.

Edited by cobra4v320

Share this post


Link to post
Share on other sites
This is Xeno's script, and its pretty awesome. When you land at the service point it shuts off the heli, removes all fuel, removes ammo, and then slowly starts to reload the heli (magazine by magazine), it repairs, then gives it fuel.

Ah yes, I noticed the getVehicleAmmo was VBS2 only so you cant count it up, lol.

Personally I'm all in favor of simplicity myself ;)

Share this post


Link to post
Share on other sites
@ Murklor

This is Xeno's script, and its pretty awesome. When you land at the service point it shuts off the heli, removes all fuel, removes ammo, and then slowly starts to reload the heli (magazine by magazine), it repairs, then gives it fuel.

I have also modified the above script so it doesnt need all of that other information I originally posted.

Thanks Cobra, just was I was looking for. And thanx Xeno!

Share this post


Link to post
Share on other sites

I think Xeno might have created the same scripting involving a wreck lifting helicopter capability and a wreck repair zone (which you would drop wrecked vehicles/aircraft on). Anybody know of where to get this script or maybe can post it here.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×