quantum69 0 Posted March 7, 2003 before you ask: Â ?(!search me):goto "boboville" Ok, I've looked through hoardes of docs and checked numerous threads in the forums, here and OFPEC to name a couple. What good is the objNull and the function isNull? In my script I try to test it using the various functions that deal with objNull; ?(_obj == objNull): ?(isNull _obj): ?(!alive _obj): Â Â ..... I need to know if _obj exists at all on the map. Â So if for an artillery script _obj = arty1 but arty1 has not been placed yet, I want to skip that part of the script so it doesn't do the infinite loop (which is noticeable). What is the proper way to test for the existance of an object, or more to the point, the absence of an object? </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _src = tbone <here the check for object existance, exit if it doesn't> _pw = weapons _src _pwc = count _pw ?(_pwc == 0):goto "myexit" <span id='postcolor'> After _src = tbone I've tried the various methods above. Of course, getting a count of 0 doesn't catch the problem because "weapons _src" on a nonexistant object returns thanks gang,any help is appreciated. Quantum69 Share this post Link to post Share on other sites
bn880 5 Posted March 7, 2003 if(_obj == _obj) then {exists} else {doesn't exist}; ?(_obj == _obj): goto "EXISTS" exit; #EXISTS but, what is _obj suppost to be, it helps to know. Share this post Link to post Share on other sites
quantum69 0 Posted March 7, 2003 _obj in my usage is any object.  Whether it's a helo, plane..etc I need to know before the script section runs if the object actually exists.  In this particular case, it's a reference to a helo. The section before this needs to check if _obj exists first, if it does then it'll run the rest of the sections, if not, just exit out.  Here's one section that uses this; </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #m2s9 qSubMenu = 21 _src = tbone ; -- need to add _src object existence check -- ; -- need to ask the big boys at OFP forum :) -- _pw = weapons _src _pwc = count _pw ?(_pwc == 0):goto "myexit" _srcnm = format["Name: %1\n",_src] _twpns = format["Total Wpns: %1\n",_pwc] _schold = 0 _wpnstr = "" _mgstr = "" #loophere1 _ares = _pw select _schold _wpnno = format["No %1:",_schold + 1] _wpnnm = format["%1\n",_ares] _wpnstr = _wpnstr + _wpnno + _wpnnm _schold = _schold + 1 ?(_schold >= _pwc):goto "noloop1" goto "loophere1" #noloop1 _pw = magazines _src _pwc = count _pw _tmags = format["Total Mags: %1\n",_pwc] _schold = 0 #loophere2 _ares = _pw select _schold _mgno = format["No %1:",_schold + 1] _mgnm = format["%1\n",_ares] _mgstr = _mgstr + _mgno + _mgnm _schold = _schold + 1 ?(_schold >= _pwc):goto "noloop2" goto "loophere2" #noloop2 _fullstr = format["%1%2%3%4%5",_srcnm,_twpns,_wpnstr,_tmags,_mgstr] hint _fullstr goto "myexit" <span id='postcolor'> As you can see, it'll generate an error right off  because doing "weapons <null object>" isn't a nice thing to do.  Since this fragment belongs to a huge menu system, I need to ensure that the object exists. Thanks for the clip, _obj == _obj, nice and simple.  Now why didn't I think of that?  Oh yeah, I'm still learning  (winks hard) Quantum69 -DELTA- Just implemented the change and here's the way it works, </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #m2s9 qSubMenu = 21 _src = tbone if (_src == _src) then {[_src,0] exec "vehicleinfo.sqs"} else {goto "myexit"} goto "myexit" <span id='postcolor'> whip a charm baby! thanks Share this post Link to post Share on other sites