sabot10.5mm 47 Posted May 25, 2016 i have a script to regen the players health in a mission shown below, once the player dies and respawns using a script. the regen health script stops working, i have an idea how to make it work but pretty new to coding. something along the lines of having a (waituntil) player dead command then start the loop over? is this the right track? private ["_newDamage","_t"]; while {alive player} do { _t = time; waitUntil {time - _t > 1}; if (damage player > 0) then { _newDamage = (damage player) - 0.2; player setdamage _newDamage; //hintSilent format["Current Damage %1",_newdamage]; }; sleep 0.50; }; Share this post Link to post Share on other sites
jshock 513 Posted May 25, 2016 Use a respawn event handler: //in your initPlayerLocal.sqf player addEventHandler [ "Respawn", {[] execVM "yourScript.sqf";}];EDIT: Can you post the script you use for respawn? Share this post Link to post Share on other sites
sabot10.5mm 47 Posted May 25, 2016 Use a respawn event handler: //in your initPlayerLocal.sqfplayer addEventHandler [ "Respawn", {[] execVM "yourScript.sqf";}];EDIT: Can you post the script you use for respawn? /* A script for SP Respawn. By Twirly - 6th July 2011 */ private ["_plyr","_kilr","_type","_group","_dist","_camera","_found","_rand","_unit"]; _plyr = _this select 0; _kilr = _this select 1; _mrkr = if (count _this >2) then {_this select 2}; if (isNil "_kilr") then {_kilr = objNull}; //grab some stuff we need later _type = typeOf _plyr; _group = group _plyr; _dist = _plyr distance _kilr; if (count _this > 2) then { //if (not (isNil _mrkr)) then { //create the new unit.... same group _unit = _group createUnit [_type, (getMarkerPos _mrkr), [], 1, "COLONEL"]; sleep 2; addSwitchableUnit _unit; selectPlayer _unit; _unit setUnitRank "COLONEL"; waitUntil {_unit == player}; _found = true; _oldUnit = _this select 1; _oldGroup = group _oldUnit; //We dont care if he was not the leader if (leader _oldGroup == _oldUnit) then { h = [_oldUnit, _oldGroup] spawn { _oldUnit = _this select 0; _oldGroup = _this select 1; _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]]; _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil]; //Wait for a new leader to be assigned waitUntil { leader _oldGroup != _oldUnit }; _leader = leader _oldGroup; if ((count _oldProviders) > 0) then { { _providerModule = _x; { if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then { [_leader, _x, _providerModule] call BIS_fnc_addSupportLink; }; }forEach synchronizedObjects _providerModule; }forEach _oldProviders; }; { _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0]; _leader setVariable [format ["BIS_SUPP_used_%1", _x], _used, true] } forEach [ "Artillery", "CAS_Heli", "CAS_Bombing", "UAV", "Drop", "Transport" ]; _leader setVariable ["BIS_SUPP_transmitting", false]; _leader kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}]; if (!(isNil "_HQ")) then { _leader setVariable ["BIS_SUPP_HQ", _HQ]; }; }; }; execVM "light.sqf"; } else { //try to find a random playable unit while {(not (_found)) and ((count switchableunits) >=1)} do { _unit = switchableunits select (floor (random (count switchableunits))); if (alive _unit) then { _found = true; selectplayer _unit; }; sleep 1; }; }; private ["_newDamage","_t"]; while {alive player} do { _t = time; waitUntil {time - _t > 1}; if (damage player > 0) then { _newDamage = (damage player) - 0.2; player setdamage _newDamage; //hintSilent format["Current Damage %1",_newdamage]; }; sleep 0.50; }; 2 Share this post Link to post Share on other sites
sabot10.5mm 47 Posted May 27, 2016 i have a script to regen the players health in a mission shown below, once the player dies and respawns using a script. the regen health script stops working, i have an idea how to make it work but pretty new to coding. something along the lines of having a (waituntil) player dead command then start the loop over? is this the right track? private ["_newDamage","_t"]; while {alive player} do { _t = time; waitUntil {time - _t > 1}; if (damage player > 0) then { _newDamage = (damage player) - 0.2; player setdamage _newDamage; //hintSilent format["Current Damage %1",_newdamage]; }; sleep 0.50; }; waituntil wont work since the script stops until its met {blah}. so i just terminate the regen script on player death and exe on player spawn Share this post Link to post Share on other sites
serena 151 Posted May 27, 2016 // time required to full healing, hours #define HEALFULLTIME 24 // critical damage blocking background healing #define HEALBLOCKLVL 0.75 Fn_BackgroundHealing = { private _now = dateToNumber date; { if (alive _x) then { private _dmg = damage _x; if (_dmg > 0 and _dmg < HEALBLOCKLVL) then { private _hpr = _now - (_x getVariable ["BackgroundHealingState", _now]); private _dmn = _dmg - _hpr / 0.00273973 * 24 / HEALFULLTIME; _x setDamage _dmn; _x setVariable ["BackgroundHealingState", if (_dmn > 0) then {_now} else {nil}]; } } } forEach allUnits }; Fn_GameMainLoop = { while {true} do { sleep 1; call Fn_BackgroundHealing; // do something else } }; 1 Share this post Link to post Share on other sites
sabot10.5mm 47 Posted May 29, 2016 // time required to full healing, hours #define HEALFULLTIME 24 // critical damage blocking background healing #define HEALBLOCKLVL 0.75 Fn_BackgroundHealing = { private _now = dateToNumber date; { if (alive _x) then { private _dmg = damage _x; if (_dmg > 0 and _dmg < HEALBLOCKLVL) then { private _hpr = _now - (_x getVariable ["BackgroundHealingState", _now]); private _dmn = _dmg - _hpr / 0.00273973 * 24 / HEALFULLTIME; _x setDamage _dmn; _x setVariable ["BackgroundHealingState", if (_dmn > 0) then {_now} else {nil}]; } } } forEach allUnits }; Fn_GameMainLoop = { while {true} do { sleep 1; call Fn_BackgroundHealing; // do something else } }; thats a very nice script, but a little problem i see is - it takes 24 hours to heal fully? i really want the script to work only for blufor and to take around 10 seconds to heal from 0.99 to 0. dont get me wrong thanks for this script. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted May 30, 2016 private ["_newDamage","_t"]; while {true} do { if (alive player) then { _t = time; waitUntil {time - _t > 1}; if (damage player > 0) then { _newDamage = (damage player) - 0.2; player setdamage _newDamage; //hintSilent format["Current Damage %1",_newdamage]; }; }; sleep 0.50; }; I think ur own script is doin the job well and u should just modify it in the way that it doesnt stop if player is dead... Share this post Link to post Share on other sites