Jump to content
Sign in to follow this  
Fogazi

Repair Script

Recommended Posts

Hello, I want to use a repair script that is executed by a player. Not by driving a vehicle onto a pad/repair bay.

I am currently using this script which is very basic, but effective.

//
// Call repair.sqf with:	this addAction["Repair Vehicle","repair.sqf"];
//


_vehicle = (nearestObjects [player, ["O_Ifrit_F","B_Hunter_F"], 5]); 
//Checks if Ifrit or Hunter are within 5m 

_veh = _vehicle select 0; 
// selects the nearest vehicle and puts it in '_veh'

_vehDamage = getDammage _veh;
//Puts the damage of '_vehicle' in the variable '_veh'

IF (count _vehicle == 1)
// If there is one vehicle within 5m

THEN {_vehDamage = _veh setDamage 0;} 
// Then set the damage to 0%

ELSE {hint "You are too far away from the vehicle";};
// Else show "You are too far ...."

exit;

Now this works fine but I would like to have an animation or at least a delay while the "player" is "repairing" the vehicle to add more realism to the action.

I also want to make it so that the script is not available when inside the vehicle.

And one more, I would like this script only to execute if the player is holding a toolbox in his inventory.

I have only just started scripting with Arma so take it easy on me.

Alternatively if there is a better script out there that works better could you please direct me to it.

Thank you

Share this post


Link to post
Share on other sites

Thank you, where in the code should i place these lines? Before the {_vehDamage = _veh setDamage 0;}?

That way the animation and pause should happen first and then the vehicle is repaired after?

Share this post


Link to post
Share on other sites

I can get the sleep command to work a no problems. But I cannot work out how to get an animation to work at all..

---------- Post added at 12:11 ---------- Previous post was at 11:07 ----------

Ok nearly got it all sorted by myself. With a few creases to iron out.

What I have now is:

//
// Call repair.sqf with:	this addAction["Repair Vehicle","repair.sqf"];
//


_vehicle = (nearestObjects [player, ["B_Hunter_F"], 5]); 
//Checks if Ifrit or Hunter are within 5m 

_veh = _vehicle select 0; 
// selects the nearest vehicle and puts it in '_veh'

_vehDamage = getDammage _veh;
//Puts the damage of '_vehicle' in the variable '_veh'

IF (count _vehicle == 1)
// If there is one vehicle within 5m

THEN {

IF (vehicle player == player)
//If player is not inside vehicle

THEN {player playActionNow "medicStart";
sleep 10;
_vehDamage = _veh setDamage 0;
player playActionNow "medicStop";}	
// Start repair animation with a 10 second delay then set the damage to 0%

ELSE {hint "You cannot repair from inside the vehicle";}}

ELSE {hint "You are too far away from the vehicle";};
// Else show "You are too far ...."

exit;

This now uses and animation with a 10 sec delay. It also doesn't allow you to repair from inside the vehicle.

One more thing I need to work out is how to make the player require a toolbox in their pack.

I'm sure it is simple but I am just figuring out the commands.

---------- Post added at 13:52 ---------- Previous post was at 12:11 ----------

I now have this:

IF ("Toolkit" in (itemCargo player))
	//Check if player has a Toolkit

	THEN {player playActionNow "medicStart";
		sleep 10;
		_vehDamage = _veh setDamage 0;
		player playActionNow "medicStop";}

	ELSE {hint "You need a Toolkit to repair a vehicle";}

However even though I have a Toolkit in my inventory it still does not work. I have also tried (items player) without success.

Any ideas? I have searched without much success for code to check players for items...

Share this post


Link to post
Share on other sites

Could player hasWeapon "Toolkit" work, since it's classified as a weapon in config?

Share this post


Link to post
Share on other sites

Nope, I can get it to work with other items but can't seem to get it to work with a Toolkit..

Share this post


Link to post
Share on other sites

What about:

if ("Toolkit" in uniformItems  player || "Toolkit" in vestItems player ||
   "Toolkit" in backpackItems player)

Edit: As a side note, if you put

_unit = _this select 1;

in the beginning of the script, and then replace instances of "player" with "_unit", it would make the script work even if you order an AI to do it. In case you're unfamiliar with what arguments addAction passes to the script, the wiki has some info: https://community.bistudio.com/wiki/addAction

Edited by Magirot

Share this post


Link to post
Share on other sites

Ok, got the _unit code sorted.

The Toolkit is still not getting picked up/recognised???

It works if I substitute the toolkit with a firstaid kit. And use backpackItems

Edited by Fogazi

Share this post


Link to post
Share on other sites

"ToolKit" Capital K in toolkit and you only need to check the backpack as a toolkit wont fit anywhere else.

Share this post


Link to post
Share on other sites

... I wasn't aware capitalisation was so important. Thank you that worked.

Now does anyone have a good animation they can recommend?

Share this post


Link to post
Share on other sites

you can take a look into to the animation viewer...

put a trigger on the map, On Act. condition : [] call BIS_fnc_animViewer

and you can choice of a big number of animation.

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  

×