wiggum2 31 Posted February 26, 2010 ;===============================; alarm sqs ;=============================== player sideChat "UAV meldet flüchtende Zielperson, Mission gescheitert..."; nul = [10] execVM "countdown.sqf": _enemies = _this select 0 exit;[/Quote] Hi, how can i stop this script if Unit X is not alive are X is true ? It must be put in this script so it just dont shows the sideChat and dont execute the "countdown.sqf"...but only if someone is not alive or something is true like (!alive ZP) or noalarm = true. And it Must be in the alarm.sqs (the script above) ! Dont get it work, drives me crazy... I tried many things like "if (noalarm) exitWith {};" at the beginning but shows the massage sideChat and starts the "countdown.sqf" anyhow. Share this post Link to post Share on other sites
Deadfast 43 Posted February 26, 2010 It's an SQS script, you're trying to use SQF condition. if (alive unitX && conditionX) then { player sideChat "UAV meldet flüchtende Zielperson, Mission gescheitert..."; [10] execVM "countdown.sqf": }; Share this post Link to post Share on other sites
wiggum2 31 Posted February 26, 2010 Sorry, dont works for me... Now it looks like: ;===============================; alarm sqs ;=============================== if (alive Zielperson) then { player sideChat "UAV meldet flüchtende Zielperson, Mission gescheitert..."; [10] execVM "countdown.sqf"; _enemies = _this select 0 }; But if "Zielperson" is dead it still shows the sideChat... Share this post Link to post Share on other sites
MichaelGER 10 Posted February 26, 2010 Try this ;=============================== ; alarm sqs ;=============================== if !(alive Zielperson) exitWith {}; player sideChat "UAV meldet flüchtende Zielperson, Mission gescheitert..."; nul = [10] execVM "countdown.sqf"; _enemies = _this select 0; exit; btw: does exitWith work in sqs? Im using only sqf, so im not sure. But if it doesnt work you could try this: ;=============================== ; alarm sqs ;=============================== if !(alive Zielperson) then {exit}; player sideChat "UAV meldet flüchtende Zielperson, Mission gescheitert..."; nul = [10] execVM "countdown.sqf"; _enemies = _this select 0; exit; Share this post Link to post Share on other sites
wiggum2 31 Posted February 26, 2010 Got it work with this code: ;=============================== ; alarm sqs ;=============================== [b]? (!(alive Zielperson)) : goto "Ende";[/b] player sideChat "UAV meldet flüchtende Zielperson, Mission gescheitert..."; [10] execVM "countdown.sqf"; _enemies = _this select 0 [b]#Ende[/b] exit; Share this post Link to post Share on other sites
Deadfast 43 Posted February 26, 2010 As I said, you were using SQS syntax with SQF conditions, the code I wrote was in SQF. Share this post Link to post Share on other sites
galzohar 31 Posted February 26, 2010 Yes, just use SQF and your life will be much easier. Share this post Link to post Share on other sites
wiggum2 31 Posted February 27, 2010 Yeah, me again... Now i have this script: RelaxexAI.sqf ////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: (AEF)Wolffy.au [2CAV] /////////////////////////////////////////////////////////////////// if (!isServer) exitWith{}; _grp = _this select 0; _dist = _this select 1; if (isNil "_dist") then {_dist = (count units _grp) * 2;}; fRandBldgPos = { ////////////////////////////////////////////////////////////////// // The following code is an extract from Random Building Position Script v1.0 by Tophe of ?stg?ta Ops ////////////////////////////////////////////////////////////////// _bldgs = _this select 0; _bldgpos = []; _i = 0; { _y = _x buildingPos _i; while {format["%1", _y] != "[0,0,0]"} do { _bldgpos = _bldgpos + [_y]; _i = _i + 1; _y = _x buildingPos _i; }; _i = 0; } forEach _bldgs; _bldgpos = _bldgpos select floor(random(count _bldgpos)); _bldgpos; ////////////////////////////////////////////////////////////////// }; { sleep random 2; [_x, _dist] spawn { private ["_action","_sleep"]; _unit = _this select 0; _dist = _this select 1; _startpos = position leader _unit; _change = 90; _unit setBehaviour "CARELESS"; _unit setSpeedMode "LIMITED"; _sactions = [ "AmovPsitMstpSlowWrflDnon", "AmovPsitMstpSlowWrflDnon_Smoking", "AmovPsitMstpSlowWrflDnon_WeaponCheck1", "AmovPsitMstpSlowWrflDnon_WeaponCheck2" ]; _actions = [ "AmovPercMstpSlowWrflDnon", "AmovPercMstpSlowWrflDnon_seeWatch", // "AmovPercMstpSlowWrflDnon_talking", "AmovPercMstpSlowWrflDnon_turnL", "AmovPercMstpSlowWrflDnon_turnR", "AmovPercMstpSnonWnonDnon_Ease", "AmovPercMstpSnonWnonDnon_seeWatch", // "AmovPercMstpSnonWnonDnon_talking", "AmovPercMwlkSnonWnonDf" ]; _actions = _actions + [ "ActsPercMstpSlowWrflDnon_Listening", "ActsPercMstpSlowWrflDnon_Lolling", "ActsPercMstpSlowWrflDnon_Talking1" ]; scopeName "main"; while {alive _unit && behaviour _unit == "CARELESS"} do { _action = floor(random 4); //player sideChat format["%1 of 3", _action]; // random move action switch (_action) do { case 0: { // move to building _pos = position _unit; _camps = nearestObjects [_pos, ["Camp","Buildings"], _dist * 2]; _bldgpos = [_camps] call fRandBldgPos; _unit doMove _bldgpos; }; case 1: { // move to startpos _pos = position _unit; _newpos = _startpos; if (format["%1", _newpos] != "[0,0,0]") then { _gap = 1 + (random 3); _i = random 360; _xg = (_gap * (sin _i)); _yg = (_gap * (cos _i)); _x_rot = (_newpos select 0) + _xg; _y_rot = (_newpos select 1) + _yg; _newpos = [ _x_rot, _y_rot]; _unit doMove _newpos; }; }; case 2: { // move randomly if (leader _unit != _unit) then { _pos = position _unit; _newpos = _pos; _gap = random _dist; _i = random 360; _xg = (_gap * (sin _i)); _yg = (_gap * (cos _i)); _x_rot = (_newpos select 0) + _xg; _y_rot = (_newpos select 1) + _yg; _newpos = [ _x_rot, _y_rot]; _unit doMove _newpos; }; }; case 3: { // move to another unit if (leader _unit != _unit) then { _grp = group _unit; _meet select floor(random count units _grp); _unit doMove position _meet; }; }; }; waitUntil{unitReady _unit || moveToCompleted _unit || moveToFailed _unit}; _action = floor(random 2); // player globalChat format["%1 of 1", _action]; // random animation _sleep = (_change / 3) + random (_change * 2 / 3); switch (_action) do { case 0: { // play random sitting action _unit playMove (_sactions select floor(random count _sactions)); _sleep = (_change * 2 / 3) + random (_change / 3); }; case 1: { // play random standing action _unit playMove (_actions select floor(random count _actions)); }; }; for "_i" from 1 to _sleep do { if (behaviour _unit == "CARELESS") then { sleep 1; } else { breakTo "main"; }; }; }; //hint format["%1", behaviour _unit]; if (alive _unit) then {group _unit setBehaviour "AWARE";}; _unit playMove "null"; }; } forEach units group _grp; The script should start at the beginning of the mission, no problem i just put _scriptHandle = [leaderName, maxDistance] execVM "RelaxedAI.sqf"; in the Init of a Unit. But now i want to quit the script if "enemynear" goes true (with a Trigger). The Soldiers should fall back to there normal behavior and attack the enemy. I dont get it to work that way... Share this post Link to post Share on other sites
Reimann 10 Posted February 28, 2010 Terminating a script: http://forums.bistudio.com/showthread.php?t=95816 Share this post Link to post Share on other sites
wiggum2 31 Posted February 28, 2010 Thanks ! I tied that one: // TestExecute.sqf; //main of TestExecute.sqf private["_handle"]; //Initialice _handle to null _handle = 0 spawn {}; enemynear = false; _handle = [] execVM "RelaxedAI.sqf"; //we wait until my_condition_to_exit_var or scritpdone. waitUntil {scriptDone _handle || enemynear}; if (enemynear && !scriptDone _handle) then { Terminate _handle; }; And in the Init of Unit ZP i put: _scriptHandle = [ZP, 6] execVM "RelaxedAI.sqf"; Then i ingame walk into a trigger that makes "enemynear" true but the RelaxedAI.sqf is still going... Help please... Share this post Link to post Share on other sites
ProfTournesol 956 Posted February 28, 2010 And in the Init of Unit ZP i put: _scriptHandle = [ZP, 6] execVM "RelaxedAI.sqf"; This line in the init of a soldier isn't good, it should be placed in the previous script that checks the handle, like this : // TestExecute.sqf; //main of TestExecute.sqf private["_handle"]; //Initialice _handle to null _handle = 0 spawn {}; enemynear = false; //_handle = [] execVM "RelaxedAI.sqf"; [b]let's get rid of this one[/b] [b]_handle = [ZP, 6] execVM "RelaxedAI.sqf";[/b] //we wait until my_condition_to_exit_var or scritpdone. waitUntil {scriptDone _handle || enemynear}; if (enemynear && !scriptDone _handle) then { Terminate _handle; }; Share this post Link to post Share on other sites
wiggum2 31 Posted February 28, 2010 Thaks, got it work ! Share this post Link to post Share on other sites