CarlGustaffa 4 Posted July 22, 2008 Hi I have this little snippet I intened to use in a medical firstaid-kit script for Domination. When I try in singleplayer, it works fine. But when I try in multiplayer, the hint returns 'scalar' on both parts. I guess it's the _med1-3 that doesn't get set properly so the adding up doesn't work. But why? Note that I have also tried isPlayer, but also then I'm ending up with an error. I was not testing with a medic at the time, but as long as one fails, I guess the whole maths fails, so it really shouldn't matter. I should note that the script is run local to the player from an automatic action generation, no fuzz. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Â Â Â Â _med1 = isNull alpha_10; Â Â Â Â _med1 = if (_med1) then {1} else {0}; Â Â Â Â _med2 = isNull bravo_3; Â Â Â Â _med2 = if (_med2) then {1} else {0}; Â Â Â Â _med3 = isNull charlie_3; Â Â Â Â _med3 = if (_med3) then {1} else {0}; Â Â Â Â _meds = _med1 + _med2 + _med3; Â Â Â Â _fact = 0.3-(_meds*0.05); Â Â Â Â _gain = _fact * (0.8+(random 0.2)); Â Â Â Â hint format ["Factor = %1\nGain = %2",_fact,_gain]; Â Â Â Â player setDamage ((damage player)-_gain); And a side question, is it good practice to change variable contents as I do in the if statement(from bool to number), in order to reduce number of variables used? Or is it better to increase the variable count and maybe readability? Edit: For clarity: I'm testing this as only player on a dedi server with all tested slots being empty. I really only want a change to kick in if the tested slot has a human player, regardless if he is alive or not. Share this post Link to post Share on other sites
dr_eyeball 16 Posted July 22, 2008 Sounds like you need to do isNil checks instead. They'll probably never be null anyway, even if dead, but will probably be nil if not occupied. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_med1 = if (isNil "alpha_10") then {0} else {1}; Share this post Link to post Share on other sites
CarlGustaffa 4 Posted July 22, 2008 isNil seems to have done the trick. Thanks. Can't believe I didn't bother to try it, but the Biki on isNil at the time in this respect didn't make sense, so I discarted it. Now it doesn't. Share this post Link to post Share on other sites