Jump to content
Sign in to follow this  
Phantom Six

Reactivate Script After Respawn

Recommended Posts

I need help with a script I'm working on for a mission for if your unit dies, I would like the script to reactivate for that unit when it respawns.

The first is some health regeneration script I found somewhere

    while {alive player} do
   {
   _t = time;
   waitUntil {time - _t > 1};

   if (damage player > 0) then 
   {
   _newDamage = (damage player) - 0.05;
   player setdamage _newDamage;
   };
   sleep 0.05;
   };

The second is to make unit take lesser damage from shots which I added to the unit's init. (My guy and my AI guy)

this addEventHandler ["HIT",{(_this select 0) setDamage (0 * damage (_this select 0));}];

I've been trying to test it out and if the unit dies, they won't have the ability of the script that initiate with it after spawn.

Does anyone know how to make the scripts or commands reactivate after respawn? Thanks.

Edited by Phantom Six

Share this post


Link to post
Share on other sites

regen_health.sqf

private ["_newDamage","_t"];
hint "Regen Script Started";
while {alive player} do 
{
_t = time;
waitUntil {time - _t > 1};
if (damage player > 0) then 
	{
	_newDamage = (damage player) - 0.05;
	player setdamage _newDamage;
	hintSilent format["Current Damage %1",_newdamage];
	};
sleep 0.05;
};

waitUntil{alive player};
sleep 0.5;
[player] execVM "regen_health.sqf";

Hints added to check script is functioning

Share this post


Link to post
Share on other sites

Thanks, so if I see regen script started each time after respawn I guess this should work I assume, thanks for the help.

---------- Post added at 23:26 ---------- Previous post was at 23:01 ----------

Will this work for the armor one?

while {alive player} do 
{
player addEventHandler ["HIT",{(_this select 0) setDamage (0 * damage (_this select 0));}];
};

waitUntil{alive player};
sleep 0.5;
[player] execVM "armor.sqf";

Comp kind of freeze and lags everytime I nade myself for a while though, maybe just having a bad day, but seems to repeat itself so I guess that should work.

Edited by Phantom Six

Share this post


Link to post
Share on other sites

Don't eventhandlers remain through respawn now? Seem to remember something like that.

Share this post


Link to post
Share on other sites

Oh yes, it does work, thanks.

Edited by Phantom Six

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  

×