Jump to content
Sign in to follow this  
infection

Loop refuses to call function

Recommended Posts

I have a loop that checks their script inventory and weapon inventories to then call a function to make it save to the server, however one of these functions refuses to be called and I'm completly unaware why.

The one that dosen't work is

previnventory = [];

/*
INV_Inventararray is: [["schluesselbund",1],["handy",3],["Mishy",1.11196e+006],["lockpick",10],["Gold",10],["lighter",10]]
*/
Loop start
if(!([previnventory, INV_InventarArray] call BIS_fnc_areEqual))then{
diag_log format ["PREVIOUS INVENTORY IS: %1 WITH: %2", previnventory, INV_InventarArray];
[player, [["inventory", INV_InventarArray]]] call LinLib_fnc_ClientUpdate;
previnventory = INV_InventarArray;
diag_log format ["PREVIOUS INVENTORY IS NOW: %1 WITH: %2", previnventory, INV_InventarArray];
};

Here's where the problem occurs tho, it does enter the IF statement and sets previnventory = INV_InventarArray; however it dosn't do any of the other code such as the diag_log or call LinLib_Fnc_clientupdate.

I've tried most things, I've checked to make sure previnventory does change and it does and there is nowhere else it gets changed. I've even tried the function manually and it works, nothing shows up in the RPT log about the loop or the function.

and I even have a similar loop for weapons however it dosen't contain nested arrays and it works.

_prevweapons = weapons player;
Loop start
if(!([_prevweapons, weapons player] call BIS_fnc_areEqual))then{
[player, [["weapons", weapons player]]] call LinLib_fnc_ClientUpdate;
_prevweapons = weapons player;
};

I logged the startup of the client and this is the loop working:

"Updated with: [Civ3,[["bank",2.39392e+007]]]"
"Updated with: [Civ3,[["inventory",[["schluesselbund",1],["handy",3],["Mishy",1.11196e+006],["lockpick",10],["Gold",10],["lighter",10]]]]]"
"Updated with: [Civ3,[["weapons",["ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","AA12_PMC"]]]]"

After this the inventory one stops working (after doing 1 loop).

However, if I add a new array to INV_InventarArray then it calls the function even tho if I only change one of the variables inside one of the nested arrays BIS_fnc_areEqual returns false according to my testing (and it actually does enter the loop and change previnventory).

I tried KillzoneKid's array comparison function, I found another one here on the forums. but I don't think that's the problem since it actually does change the previnventory variable.

I'm not quite sure what to do. If anyone would be able to help me that'd be great.

Basically,

BIS_fnc_areEqual makes loop enter if statement, however it dosn't call the function even if array is not equal but it does change the previnventory variable.

The only time it actually calls that function is when a completly new nested is added to INV_InventarArray. (It even enters the if statement if a current element is changed but dosn't call the function).

I hope I made it clear enough, I'm very confused of this issue.

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  

×