Jump to content
Sign in to follow this  
rimblock

Pushback error (Error Type Number, expected Bool)

Recommended Posts

So I am having a strange pushback error I am having a problem trying to track down.

I am trying to add elements to an array.

If the array is empty I am using the following code which works fine

if ((count _newMagArray) isEqualTo 0) then {
	_newMagArray pushback [_magType, _shotsLeft, 1];

THe problem is that if there is already an element in the array, the same pushback command is throwing an error.

_newMagArray: [["20Rnd_762x51_Mag",20,2]]

New array element to add: [20Rnd_762x51_Mag, 10, 1]

Code Block

	if !(_magAdded) then {
	diag_log format["[%1] newMagArray: %2.",_scriptname, _newMagArray];
	diag_log format["[%1] No match found. Adding new mag to array: [%2, %3, %4].",_scriptname, _magType, _shotsLeft, 1];
	_newMagArray pushback [_magType, _shotsLeft, 1];
};

Result in the server RPT file

22:49:07 "[ds\addons\dominion_server\functions\playerLoad\fnc_consolidateMagArray.sqf] Mag Added: false."

22:49:07 "[ds\addons\dominion_server\functions\playerLoad\fnc_consolidateMagArray.sqf] newMagArray: [["20Rnd_762x51_Mag",20,2]]."

22:49:07 "[ds\addons\dominion_server\functions\playerLoad\fnc_consolidateMagArray.sqf] No match found. Adding new mag to array: [20Rnd_762x51_Mag, 10, 1]."

22:49:07 Error in expression < _magType, _shotsLeft, 1];

_newMagArray pushback [_magType, _shotsLeft, 1];

}; >

22:49:07 Error position: <pushback [_magType, _shotsLeft, 1];

}; >

22:49:07 Error Type Number, expected Bool

Banging my hear against the wall on this one. Any suggestions before I move back to Set for the time being ?.

Thanks

Share this post


Link to post
Share on other sites

Out of curiosity, does it still error if you use this:

if (_newMagArray isEqualTo []) then {
   _newMagArray pushback [_magType, _shotsLeft, 1];
};

=================

Edit: ignore that, I thought the error was coming from your first code snippet. Hmmm, this is a curious one. Could you post the whole script somewhere? It's hard to debug based solely on the above snippets.

Edited by SilentSpike

Share this post


Link to post
Share on other sites

"Error Type Number, expected Bool"

That error message might be the key. pushBack returns a number... try giving it something to return to.

_index = _newMagArray pushback [_magType, _shotsLeft, 1]; 

You shouldn't need it but try it anyway.

Share this post


Link to post
Share on other sites

Just hit midnight here so will try some other stuff tomorrow but when I changed it to set it errored saying the _newMagArray was not defined. I then put in another diag_log line between the matching 'count' loop and the if (not added) clause and no it is working.

I will try putting the pushback back in tomorrow. All other instances of using pushback are working as expected.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×