Arcurus 4 Posted February 24, 2013 I have a script that counts down a value and I'd like it to reset to 100 after a player dies and respawns. Here's what I have. if (not((_this select 0)==player)) exitwith {}; thirst=100; while {true} do { while {alive player && animationstate player!="ainjppnemstpsnonwrfldnon" && animationstate player!="ainjppnemstpsnonwnondnon_rolltofront" && animationstate player!="ainjppnemstpsnonwnondnon_rolltoback" && animationstate player!="ainjppnemstpsnonwrfldnon_rolltofront" && animationstate player!="ainjppnemstpsnonwrfldnon_rolltoback" } do { if (thirst>=100) then {thirst = 100}; if (thirst>0) then {sleep 180}; thirst=thirst-10; if (thirst>=100) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 100</t>",12];}; if (thirst == 90) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 90</t>",12];}; if (thirst == 80) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 80</t>",12];}; if (thirst == 70) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 70</t>",12];}; if (thirst == 60) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 60</t>",12];}; if (thirst == 50) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 50</t>",12];}; if (thirst == 40) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 40</t>",12];}; if (thirst == 30) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 30</t>",12];}; if (thirst == 20) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 20</t>",12];}; if (thirst == 10) then {hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Your thirst is at 10</t>",12];}; if (thirst<=0 && alive player && animationstate player!="ainjppnemstpsnonwrfldnon" && animationstate player!="ainjppnemstpsnonwnondnon_rolltofront" && animationstate player!="ainjppnemstpsnonwnondnon_rolltoback" && animationstate player!="ainjppnemstpsnonwrfldnon_rolltofront" && animationstate player!="ainjppnemstpsnonwrfldnon_rolltoback" ) then { thirst = 0; while {thirst<=0 && alive player && animationstate player!="ainjppnemstpsnonwrfldnon" && animationstate player!="ainjppnemstpsnonwnondnon_rolltofront" && animationstate player!="ainjppnemstpsnonwnondnon_rolltoback" && animationstate player!="ainjppnemstpsnonwrfldnon_rolltofront" && animationstate player!="ainjppnemstpsnonwrfldnon_rolltoback" } do { (hint parseText format["<t valign='bottom' size='1.2' color='#0F81EB'>Thirst is at 0%, Health loss because of dehydration! Find something to drink!</t>",12]); titleText ["Thirst is at 0%, Health loss cause of dehydration! Find something to drink!", "PLAIN"]; player setdammage (getdammage player) + .1; wps1 = (floor(random 2)); // generates random number from 1 to 1" if (wps1 == 0) then { Playsound "pain1"; }; if(wps1 == 1) then { Playsound "pain2"; }; if(wps1 == 2) then { Playsound "pain3"; }: sleep 12; }; }; }; sleep 1; }; Share this post Link to post Share on other sites
lifted86 10 Posted February 24, 2013 this will execute on respawn player addEventHandler ["Respawn", {thirst = 100}]; Share this post Link to post Share on other sites
Arcurus 4 Posted February 24, 2013 Where should I put this line? in the unit's Init field or in a script? Share this post Link to post Share on other sites
lifted86 10 Posted February 24, 2013 You can put it in that script after thirst=100; or in the units init field. but you'll have to change it to this addEventHandler ["Respawn", {thirst = 100}]; Share this post Link to post Share on other sites
Arcurus 4 Posted February 24, 2013 It's working. Thank you. Share this post Link to post Share on other sites