Jump to content

Recommended Posts

Hello, i'm creating a COOP mission.

I have this script in the initLocalPlayer.sqf, basically I want a specific number of AI's to immediately die (setDamage 1;) when they loose health. (get shot by players)

 

Quote

{

    if ((damage _x)>0.1) then 

    {

        _x setDamage 1;

        sleep 1;

    };

} forEach [test1, test2];


I've tried damaged and hit eventhandlers but it doesn't work, any help?

Share this post


Link to post
Share on other sites

I'm assuming you want this check to run every time the units get damaged and not just when the server starts so:

{
	_x addEventHandler ["HandleDamage", { 
		params ["", "", "_damage"]; 
		if (_damage > 0.1} then {
			_damage = 1;
		}; 
		_damage
	}];
} forEach [test1, test2];

Untested

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
14 hours ago, stanhope said:

I'm assuming you want this check to run every time the units get damaged and not just when the server starts so:


{
	_x addEventHandler ["HandleDamage", { 
		params ["", "", "_damage"]; 
		if (_damage > 0.1} then {
			_damage = 1;
		}; 
		_damage
	}];
} forEach [test1, test2];
 

Untested


Works wonderfully, just a tiny bracket mistake in your part where you have } instead of ) next to > 0.1.

Other than that it works! Thank you!

Share this post


Link to post
Share on other sites

Well, I was in a meeting at work while writing that so It's surprising to me that that's the only mistake I made 😄

  • Haha 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

×