Ramsen V 1 Posted August 28, 2023 Afternoon, Probably an easy fix but I cannot find the correct solution/syntax: _ammoClass = getArtilleryAmmo [_veh] select 0; // (_veh is a Zamak MRL with NO ammo left - so obviously no ammo class - this is purposely set for this fault test.) systemchat format ["%1",_ammoClass]: // Returns <null> as expected. if (isNull _ammoClass) then {_ammoClass = "null"}; // Do not know how to check the variable? Error: _ammoClass undefined variable of course! So how can I check that _ammoClass is <null>. I have tried, isNil, isNull and tried setting the variable _ammoClass to nill before the check, however, whatever I do getArtilleryAmmo just overwrites the variable regardless. So any help welcome. Thank you for reading! Cheers. Share this post Link to post Share on other sites
Harzach 2511 Posted August 28, 2023 You can check a variable with isNil. An undefined variable will return true: hint format ["%1", isNil "_ammoClass"]; //TRUE A defined but "empty" variable will return true: _ammoClass = getArtilleryAmmo [_veh] select 0; hint format ["%1", isNil "_ammoClass"]; //TRUE A defined variable will return false: _ammoClass = 3; hint format ["%1", isNil "_ammoClass"]; //FALSE 2 Share this post Link to post Share on other sites
Ramsen V 1 Posted August 28, 2023 (edited) Thank you for your reply @Harzach On 8/28/2023 at 5:31 PM, Harzach said: You can check a variable with isNil. That was exactly what I thought but then, after your post, I saw my mistake... if (isNil _ammoClass) should be if (isNil "_ammoClass") in quotes! ....I forgot the quotes! Anyway it is all working now ... interestingly the getArtilleryAmmo code also shows <null> if no gunner crew are present too. Cheers. SOLVED Edited September 1, 2023 by Ramsen V Corrected code and grammar. Crossed out erroneous information. Share this post Link to post Share on other sites
Harzach 2511 Posted August 28, 2023 1 hour ago, Ramsen V said: interestingly the getArtilleryAmmo code also shows <null> if no gunner crew are present too. I don't get this result. A fully loaded Scorcher with no crew still returns ammo (isnIl returns false). Share this post Link to post Share on other sites
Ramsen V 1 Posted September 1, 2023 On 8/28/2023 at 8:23 PM, Harzach said: I don't get this result. A fully loaded Scorcher with no crew still returns ammo (isnIl returns false). Many apologies, I was checking the same Zamak that had no ammunition which was why the <null> was showing. I have crossed out the erroneous observation so it should no longer confuse anyone. Anyhow, all is working with this now. Thank you again. Share this post Link to post Share on other sites