Chromium 10 Posted January 26, 2010 Well, after hammering away at script for a while, I've pinned down a problem I'm having with isNil. The following code does not return, ever: if (isNil _tmr) then { _tmr = (-120);} Take out the "if... {" and the "}" and _tmr gets a value set of -120. I have to assume I'm coding the if statement wrong, but I can't for the life of me see anything off. I've tried a few variations on the condition, but no use there. (isNil ("_tmr")) doesn't work either. The only method for testing this is a simple hint format ["%1",_tmr] but I don't think that it's the testing method that is flawed. Any help? Share this post Link to post Share on other sites
killswitch 19 Posted January 26, 2010 if (isNil "_tmr") then { _tmr = -120; }; Share this post Link to post Share on other sites
sickboy 13 Posted January 26, 2010 It's a Scope problem :) private ["_tmr"]; if (isNil "_tmr") then { _tmr = -120 }; Share this post Link to post Share on other sites
Chromium 10 Posted January 26, 2010 Well, while that gets my tests to return (:o) I still have an issue: they return as "any", indicating the variable is still nil. Full code of the SQF: private ["_tmr"]; if (isNil _tmr) then { _tmr = -120; }; if ((time - _tmr) >= 120) then { _tmr = time; player setCaptive 1; hint "Stealthed"; sleep 10; player setCaptive 0; hint "Exposed"; } else { hint format ["Cooldown not expired, %1 seconds left",(120-(time - _tmr))]; }; Thanks for your help so far! Share this post Link to post Share on other sites
Taurus 20 Posted January 26, 2010 Hello. Sorry for intervening. You mustn't forget the "" around the variable, as Sickboy suggested. if (isNil "_tmr") http://community.bistudio.com/wiki/isNil Share this post Link to post Share on other sites
Chromium 10 Posted January 26, 2010 Thanks guys! Hard to believe I packed that many problems into like 10 lines. :P Sorry for wasting time, but thanks for all the help! Share this post Link to post Share on other sites