ADuke 1 Posted December 3, 2008 Howdy, I am trying to end this script when the dammage of "cc" is equal to 0 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #loop cc switchmove "ActsPpneMstpSnonWnonDnon_Injured1" ~30 goto "loop" if !((getdammage cc >= 0)) exit Any help is appreciated Thanks Share this post Link to post Share on other sites
Namikaze 0 Posted December 3, 2008 I don't really know SQS too well, but it looks like it will never get beyond the loop because you have no way to exit it within the loop. Â Try this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #loop cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1" ~30 if !((getDammage cc >= 0)) exit goto "loop" If you wanted to use SQF, you'd do it like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> while{getDammage cc >= 0}do { cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1"; sleep 30; }; Share this post Link to post Share on other sites
Aqu 0 Posted December 3, 2008 I don't like sqs scripts, but what I have seen them I think it could be be put like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #loop cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1" ~30 ?( damage cc > 0 ) : goto "loop" You had also a logical error in it. The test !(damage >= 0) is always false ,because damage returns a value between 0 and 1. That works if don't have anything after that code. If you do you have to set the test like ?( damage cc == 0 ): exit Share this post Link to post Share on other sites
ADuke 1 Posted December 3, 2008 Thank you all for your replies, the following code successfully exits the script when CC's damage is at 0... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #loop cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1" cc say "wounded" ~30 if !((getDammage cc >= 0)): exit goto "loop" But, it does generate an error message in game.... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> 'if !((getDammage cc >= 0)) # : exit' Error :: Type if, expected switch Thanks again fro any help with this EDIT====================== I changed the script to this... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #loop cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1" cc say "wounded" ~30 ?((getDammage cc >= 0)): exit goto "loop" and there was no error message, all is well. Share this post Link to post Share on other sites
Rommel 2 Posted December 3, 2008 SQF is far superior and easier to use if you just spend 5minutes with it. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> while{damage cc > 0} do { cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1"; cc say "wounded"; sleep 30; }; Share this post Link to post Share on other sites
squeeze 22 Posted December 4, 2008 Since Damage 0 is healthy and Damage 1 is dead ?((getDammage cc >= 0)): exit will always be true..... ?((getDammage cc == 0)): exit would be better as it only exits when the unit is repaired. this way you can change ~30 to maybe a shorter time.....depending on the length on the switchMove animation. Share this post Link to post Share on other sites
Deadfast 43 Posted December 5, 2008 You could also use alive: SQF (recommended): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> while {alive cc} do { cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1"; cc say "wounded"; sleep 30; }; SQS: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #loop cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1" cc say "wounded" ~30 ?(not alive cc): exit goto "loop" Share this post Link to post Share on other sites
dachevs 1 Posted December 6, 2008 using alive will make the guy play the move all the time, becuz even if he is damaged or not he is alive. Share this post Link to post Share on other sites
ADuke 1 Posted December 6, 2008 Thanks for all of your replies, The script as it is now works for what I wanted it to do, it loops an injured animation (character writhing on the ground holding his stomach) I had to loop it because it ends after about 30 seconds. I also added an audio file using the say command, it makes him groan and grunt in pain. I set the parameters for exiting the script to when he is healed (healing is triggered by the player being in a trigger area). I would like to exit the script when he dies as well (using a boolean "or" statement) because as it is now, if he is killed by OPFOR his dead body continues animating, I would appreciate any suggestions on how to get that done. It may be better to exit the script when a variable is reached, that way he has to be healed by a medic when he exits the animation and sound, and is not healed automatically. Eager to hear suggestions, thanks again -ADuke Share this post Link to post Share on other sites
Deadfast 43 Posted December 8, 2008 using alive will make the guy play the move all the time, becuz even if he is damaged or not he is alive. Indeed, but that's what Duke wants in this case ADuke: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> CC_healed = false; //can be declared elsewhere while {(alive cc) && !(CC_healed)} do { cc switchMove "ActsPpneMstpSnonWnonDnon_Injured1"; cc say "wounded"; sleep 30; }; Once the unit is healed set CC_healed to true (can be done from anywhere - global var). Share this post Link to post Share on other sites