BLSmith2112 0 Posted November 13, 2006 My First Script: A unit walks within 100 meters of an object. Once he is in the perimeter (100m) of that object, a simple text warning would appear, and continue to appear until the unit is gone from the area. However, if that unit were to die, his brand new toy (his chopper) would explode The script: Quote[/b] ]_Object = _this select 0_CenterObject = _this select 1 _radius = _this select 2 _freq = _this select 3 _script = _this select 4 _vektor = _this select 5 _life = _this select 6 _Killchopper = this select 7 setdammage 1.0 = _die #Update ~_freq ? (_Object Distance _CenterObject) <= _radius : goto "InZone" goto "Update" #InZone _vektor exec _script ? (_life == "LOOP") : goto "Update" ! (alive _Object) : goto "KillChopper" ; _script is only a text propt (print.sqs) that says "In Zone!" #KillChopper _Killchopper _die exit ; Init field: ; [Player, CenterObject, 100, 1, "print.sqs", ["In Zone!"], "LOOP", DeadChopper] exec "inzone.sqs" Questions: 1. Once the unit is within 100m of the center object, the warning will go off, however it will continue to go off even if the unit is dead inside the parimeter. How do I fix this? 2. The chopper doesn't explode when "_Object" is dead, why? Share this post Link to post Share on other sites
ProfTournesol 956 Posted November 13, 2006 Quote[/b] ]1. Once the unit is within 100m of the center object, the warning will go off, however it will continue to go off even if the unit is dead inside the parimeter. How do I fix this? Because : Quote[/b] ]? (_life == "LOOP") : goto "Update" is tested before : Quote[/b] ]! (alive _Object) : goto "KillChopper" If _life == "loop", the alive condition is never reached by the script. Moreover, !(alive _object) isn't a condition if you don't write the question mark at the beginning of the line. You should write : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#InZone _vektor exec _script ? !(alive _Object) : goto "KillChopper" ? (_life == "LOOP") : goto "Update" Quote[/b] ]2. The chopper doesn't explode when "_Object" is dead, why? Same reasons, plus Quote[/b] ]setdammage 1.0 = _die doesn't work. Write : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#KillChopper _Killchopper setdammage 1 instead. Share this post Link to post Share on other sites
Metal Heart 0 Posted November 13, 2006 You can have macro-like commands in scripts with call. Like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_kill = {_this setdammage 1.0;} chop call _kill or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_hypotenuse = {sqrt((_this select 0)^2 + (_this select 1)^2)} _a = 3 _b = 4 _c = [_a, _b] call _hypotenuse hint format ["c=%1", _c] Share this post Link to post Share on other sites
BLSmith2112 0 Posted November 13, 2006 Wow thanks guys. I'll do a test on this tonight. (New mission scripter, thanks for your patience too). But what metal said was quite interesting. I haven't made it to that advanced type scripting yet; but what is: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_hypotenuse = {sqrt((_this select 0)^2 + (_this select 1)^2)} _a = 3 _b = 4 _c = [_a, _b] call _hypotenuse hint format ["c=%1", _c] That looks interesting. Anyways, I'll give this script I'm working on - a little test later today. Thanks Share this post Link to post Share on other sites