snkman 351 Posted May 30, 2007 Hi all, well i just tryed to exec a script after a tank is nearer then 100 meters to the player <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _list = position player nearObjects ["Tank",100] i tryed to create a condition with it like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (position player nearObjects ["Tank",100]) then {exec "myScript.sqs"} But so far i was not able to create any condition with nearObjects... So how do i have to use it? Share this post Link to post Share on other sites
norrin 9 Posted May 31, 2007 I assuming this is in a trigger, if so there's at least a couple of ways you can do this (I think): If the distance is less than 50 meters you can put something in the expCond line like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">heli_pad distance (nearestObject [heli_pad, "Helicopter"]) < 7;(I use this as a condition in a chopper rearm/refuel script I have) or if using the nearest objects command try <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">count nearestObjects [player, ["Tank"], 100] >= 1 then in the expActiv line place something like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[] exec "myScript.sqs" If there is only one side you want to trigger the script you can also place 'this &&' as well as the above code - where the 'this' is BLUFOR present etc. Share this post Link to post Share on other sites
InqWiper 0 Posted May 31, 2007 Hi all,well i just tryed to exec a script after a tank is nearer then 100 meters to the player <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _list = position player nearObjects ["Tank",100] i tryed to create a condition with it like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (position player nearObjects ["Tank",100]) then {exec "myScript.sqs"} But so far i was not able to create any condition with nearObjects... So how do i have to use it? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">position player nearObjects ["Tank",100] Doesnt return true or false so you cant ask just "if". I belive this is what you are looking for: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (count (position player nearObjects ["Tank",100])>0) then {exec "myScript.sqs"} Since it returns an array you want to ask if the amount of objects in the array are greater than 0. Very nice command btw, didnt know about it before you posted it. Alot better than nearestObject in many situations  Share this post Link to post Share on other sites
snkman 351 Posted May 31, 2007 Thanks for the replay Guy's, InqWiper way is what i was looking for. IT WORKS! Share this post Link to post Share on other sites
snkman 351 Posted May 31, 2007 Just another question plz. I have 6 tanks on a map and if a tank is nearer then 100 meters the script will run but it's still running after the tank was destroyed... How can i do this to stop the script after a tank was destroyed and start it again after the next tank is nearer then 100 meters? If i just put some more in the condition like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if ((damage "Tank") < 0.8 && (position player nearObjects ["Tank",100])) then {exec "myScript.sqs"} but i don't know how to tell this to the class. Share this post Link to post Share on other sites
Taurus 20 Posted May 31, 2007 Just another question plz.I have 6 tanks on a map and if a tank is nearer then 100 meters the script will run but it's still running after the tank was destroyed... How can i do this to stop the script after a tank was destroyed and start it again after the next tank is nearer then 100 meters? If i just put some more in the condition like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if ((damage "Tank") < 0.8 && (position player nearObjects ["Tank",100])) then {exec "myScript.sqs"} but i don't know how to tell this to the class. To be overinformative name your tank(s) e.g. myTank1 myTank2 etc etc And You need to think of the tank as a object not a class in the "check damage"-case. like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if(((damage myTank1) < 0.8) && (position player nearObjects ["Tank",100]))then{ exec "myScript.sqs"; }; Share this post Link to post Share on other sites
mr.peanut 1 Posted May 31, 2007 There is no way to create a trigger condition the way you want using nearObjects and checking for object damage. I would suggest a trigger of 100m radius that is scripted to follow the player. Set trigger to enemy side present repeatedly with condition: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x isKindOf "Tank" && damage _x < 1} forEach thisList Suppose you have named the trigger myTrigger Then either in your init.sqs or player init put the following: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul = [player,myTrigger] execVM "triggerfollow.sqf" triggerfollow.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0; _trigger = _this select 1; while {TRUE} do { _trigger setPos (getPos _unit); sleep 2; }; Share this post Link to post Share on other sites
snkman 351 Posted June 1, 2007 Well pretty good idea Mr.Peanut I will try it. Share this post Link to post Share on other sites
mr.peanut 1 Posted June 7, 2007 Hmmm... Have to recant somewhat on my previous post. If trigger is to be stationary then: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({damage _x < 1} count (position player nearObjects ["Tank",100])) > 0 should work. Share this post Link to post Share on other sites
VictorFarbau 0 Posted June 7, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_t = (position player nearObjects ["Tank",100]); IF (EAST countSide _t > 0) THEN {hint "Help!"} ELSE {hint "No threat."}; You can replace EAST with WEST or GUER if needed. Dead units don't have a side anymore, that should do the trick. Cheers, Victor Share this post Link to post Share on other sites
Taurus 20 Posted June 7, 2007 Dead units don't have a side anymore, that should do the trick. Actually, for some obscure reason they become civilian when dead Until the game removes them and they are members of null Share this post Link to post Share on other sites
snkman 351 Posted June 7, 2007 Hey Victor You da man It works pretty well! @The_Taurus Well that's not a problem becouse the script i like to use it in didn't check for civilians. Share this post Link to post Share on other sites