Jump to content
zealot111

Realistic repair script

Recommended Posts

Another small idea... or at least a request for guidance. Looking through the script I am unsure where I might put a line to add a small amount of fuel, say just enough to get back to base.

Share this post


Link to post
Share on other sites

I would like to use this for my server but is this multiplayer compatible? so all players have the option to repair?

Share this post


Link to post
Share on other sites
I would like to use this for my server but is this multiplayer compatible? so all players have the option to repair?

Works on our server no problem. Everyone can repair. Very useful script, especially for smaller groups.

Share this post


Link to post
Share on other sites
Works on our server no problem. Everyone can repair. Very useful script, especially for smaller groups.

Could you tell me how? Mine is not working.

Share this post


Link to post
Share on other sites
Could you tell me how? Mine is not working.

I didn't do anything special - just added the script as per the instructions.

The init.sqf contains this line:

[] execVM "zlt_fieldrepair.sqf";

And the root folder of the mission contains the file zlt_fieldrepair.sqf.

The only thing I did after we gave it a try was to adjust the repair times downwards a bit as we preferred to be waiting less to repair vehicles (we're a small group and I don't like brakes).

Share this post


Link to post
Share on other sites

Is there a way I can limit the repair script to certain units?

I want to use this on a dedicated server, but limit it so only some units (typically engineers) get the option.

It has to be done on unit level, and not group.

Guess it would need to be done after the script is initiated for it to kick at mission start, but before the "addAction"

Any help appreciated, would make a already great script perfect for my use! :D

Share this post


Link to post
Share on other sites
Is there a way I can limit the repair script to certain units?

I want to use this on a dedicated server, but limit it so only some units (typically engineers) get the option.

It has to be done on unit level, and not group.

Guess it would need to be done after the script is initiated for it to kick at mission start, but before the "addAction"

Any help appreciated, would make a already great script perfect for my use! :D

As mentioned in the first post, if you add engineers and repair specialists into the mission, they'll be able to use the game's own repair action which repairs everything in a flash.

But you can simulate them by adding an "allow repair" variable to some units, and use the editor's "Description" field to signify their role. For example, an Explosives Specialist with Description "Engineer" and this as it's init:

this setVariable ["allowRepair", TRUE, TRUE];

and in init.sqf:

if isServer then
{
 [] execVM "zlt_fieldrepair.sqf";
}
else
{
 [] spawn 
 {
   waitUntil {!isNull player};

   if (player getVariable ["allowRepair", FALSE]) then
   {
     [] execVM "zlt_fieldrepair.sqf";
   };
 };
};

It's not compatible with respawn (works with JIP though), and on a non-dedicated server the hosting player always gets the repair action. If this is enough for your needs then this should be the simplest method, otherwise zlt_fieldrepair.sqf needs modifying.

Share this post


Link to post
Share on other sites

You could just place what you have above for the init.sqf in the onPlayerRespawn.sqf file as well, which should solve the respawn issue with this script, I believe.

Share this post


Link to post
Share on other sites
You could just place what you have above for the init.sqf in the onPlayerRespawn.sqf file as well, which should solve the respawn issue with this script, I believe.

zlt_fieldrepair.sqf already has a respawn eventhandler without a variable check at the bottom, so the issue is more that if a player gets the action once, they'll get them for all units they subsequently respawn as too. But you're right, that'd guarantee that respawned units have it, and simply removing the last seven lines of zlt_fieldrepair.sqf shouldn't be too hard.

Share this post


Link to post
Share on other sites

Thanks guys, seems to be working great.

Also removed the Respawn part in zlt_fieldrepair and added the above code in the init and onPlayerRespawn.

Haven't had the chance to test it on a dedi yet, but no reason for it to not work as far as I can see.

Share this post


Link to post
Share on other sites

Cool script, but i think ACE3 removes repair trucks repairing ability so i guess thats why this script doesn't recognize that i'm near one? Would love to use this until they implement their own repair system. Any workarounds, maybe replace the "can repair" check with a classname check?

Share this post


Link to post
Share on other sites

If its realistic, why would the toolkit vanish after the repairs? They're tools, not parts. You're not a good mechanic if you lose your tools with every vehicle repair. That can get expensive.

Share this post


Link to post
Share on other sites

Wow dude... THANK YOU! I have been hunting literally all day long for a good repair script for my mission... God damn... I love you lol :D Its a really nice script too :)

 

EDIT: Just noticed all players can repair vehicles even if they do not have the ToolKit... weirdly my player that spawns with the MediKit is unable to repair.. any ideas?

Share this post


Link to post
Share on other sites

Hmm dude... Anyway to edit this for healing players using a MediKit? I am looking for something exactly like your repair script but to repair players instead... Is it do able?

Share this post


Link to post
Share on other sites

i wonder if it is intended or if it is a bug..

my mate tried to repair a vehicle... when he was finished the toolkit was gone but the vehicle not repaired...

he got another toolkit... jumped into the driverseat first (doesnt matter which seat you use) and then he tried again... and it worked...

is there any possibility to repair a vehicle without the need to jump in first?

 

 

 

Hmm dude... Anyway to edit this for healing players using a MediKit? I am looking for something exactly like your repair script but to repair players instead... Is it do able?

+1  i would take that one too =)

meanwhile we have set the players to combatmedics and let them repair their vehicles with this nice script =)

Share this post


Link to post
Share on other sites

I'm making good use of this repair script in my logistics addon.

While debugging some issues reported by my testers I found there is a locality issue in the repair script regarding setHitpointDamage.

You need to run this command on the client where the vehicle is local and that's not always where the repair script is running, for example the vehicle could be local to the dedicated server.

I fixed it for myself like this:

zlt_fnc_mpSetHitpointDamage = {
	private [
		"_vehicle",
		"_hitpoint",
		"_points"
	];
	
	_vehicle = [ _this, 0 ] call BIS_fnc_param;
	_hitpoint = [ _this, 1 ] call BIS_fnc_param;
	_points = [ _this, 2 ] call BIS_fnc_param;
	
	_vehicle setHitpointDamage [ _hitpoint, _points ];
};

zlt_fnc_partrepair = {
	private "_veh";
	_veh = [_this, 0] call BIS_fnc_param;
	if (isNil {_veh} ) exitWith {}; 
	{
		_dmg = (_veh getHitPointDamage _x);
		if (not isNil {_dmg}) then {
			if ( _dmg > 0.64 ) then {
				if (_x in zlt_hardRepairParts) then {
					[ _veh , _x, 0.64 ] remoteExec [ "zlt_fnc_mpSetHitpointDamage", _veh, false ];
				} else {
					[ _veh , _x, 0 ] remoteExec [ "zlt_fnc_mpSetHitpointDamage", _veh, false ];
				};
				_veh setPosATL [ (getPosATL _veh) select 0, (getPosATL _veh) select 1, 0 ];
			};
		};
	} foreach zlt_repair_hps; 
};

I'm using the new remoteExec function to have the setHitpointDamage function run on the client where the vehicle is local.

  • Like 1

Share this post


Link to post
Share on other sites

So I have no clue if anyone could help me with this any longer but oh well he goes. So I was using this script perfectly when it was in my init.sqf document but then when a different breaching script im using called for me to make an initServer.sqf and follow their instructions for their stuff which i did as it now works, but the vehcile repair script has stopped working ever since. Please help!

Share this post


Link to post
Share on other sites

INITSERVER.sqf is for  a MP game

INIT.sqf is for a SP game

 

you can just put your text from INITSERVER.sqf into your INIT.sqf if you are making a SP game.

 

Share this post


Link to post
Share on other sites
11 hours ago, Play3r said:

INITSERVER.sqf is for  a MP game

INIT.sqf is for a SP game

 

you can just put your text from INITSERVER.sqf into your INIT.sqf if you are making a SP game.

 

 

Coming from another thread, it's an MP scenario.

 

Either way, if used in an SP environment, initServer.sqf will still run as the client is still considered to be the server/host, kind of similar to a hosted MP setting I guess.

 

Edit:

More correctly though:

initServer.sqf - runs on the server only (which is also the player in a hosted MP or SP game).

initPlayerLocal.sqf - runs on all client machines.

init.sqf - runs on all machines.

 

This is ignoring headless clients though, I can't remember if there's any differences with them, but I think they also act like clients in this case.

  • Thanks 1

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

×