Jigsor 176 Posted May 10, 2013 So I'm trying to compare values in position arrays. I'd like to set a variable to nil if 2 position arrays are not equal. Maybe setting a variable to nil in this case here is not possible? I'm thinking it is. An if nil will be used for a while loop until 2 matching arrays are found after the following code: Maybe I'm just using improper sytax for the not equal to? _marker = object1; _current_rnd = random_number; _pos = [ getPos _marker select 0, (getPos _marker select 1)]; _posAO1 = [ getMarkerPos "task1mkr" select 0, (getMarkerPos "task1mkr" select 1)]; _posAO2 = [ getMarkerPos "task3mkr" select 0, (getMarkerPos "task3mkr" select 1)]; _posAO3 = [ getMarkerPos "movingtrain" select 0, (getMarkerPos "movingtrain" select 1)]; _posAO4 = [ getMarkerPos "task7mkr" select 0, (getMarkerPos "task7mkr" select 1)]; if (_current_rnd == 2) then {if (_pos != _posAO1) then {isnil _current_rnd};}; if (_current_rnd == 3) then {if (_pos != _posAO2) then {isnil _current_rnd};}; if (_current_rnd == 4) then {if (_pos != _posAO3) then {isnil _current_rnd};}; if (_current_rnd == 5) then {if (_pos != _posAO4) then {isnil _current_rnd};}; if (_current_rnd == 4) then {if (_pos != _posAO3) then {isnil _current_rnd};}; RPT returns Error in expression <; if (_current_rnd == 3) then {if (_pos != _posAO2) then {isnil _current_rnd};};> Error position: <!= _posAO2) then {isnil _current_rnd};};> Error !=: Type Array, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Team member,Task,Location Share this post Link to post Share on other sites
killzone_kid 1333 Posted May 10, 2013 you can always check if position is the same by checking distance if (pos1 distance pos2 == 0) also i suggest you visit wiki and look up isNil command for the syntax and usage Share this post Link to post Share on other sites
Jigsor 176 Posted May 10, 2013 Thanks Killzone_Kid I'll try that. Need to rethink whole script now. Doesn't make sence that server can check if variable a is undefined with isNil and return true or false, but you can't declare a variable as isNil It would make my while loop much easier to write. Share this post Link to post Share on other sites
xxanimusxx 2 Posted May 10, 2013 Why shouldn't you be able to nil a variable? _myVariable = nil; if (isNil "_myVariable") then { // Works fine }; Share this post Link to post Share on other sites
Jigsor 176 Posted May 11, 2013 (edited) Thanks guys, I've got a working script now. This bit now looks like this statement. if (_current_rnd == 3) then { if (_pos distance _posAO2 == 0) then { _invhelipad setPos getMarkerPos "task3mkr"; } else { _current_rnd = nil; }; }; isNil isNo good for this sort of thing. Edited May 11, 2013 by Jigsor Share this post Link to post Share on other sites