Advertisement
Xyberviri

ArmaKeyMap With checksum

Jan 21st, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private["_array","_key","_value","_needle"];
  2. _array=[[],[],0];                          
  3. _key = _this select 0;
  4. _value = _this select 1;
  5.  
  6. if((count _this) > 2) then {                //Update existing KeyMap
  7.     _array= (_this select 2);
  8. };
  9.  
  10.    _needle = ((_array select 0) find _key); //Search for existing key
  11. if(_needle > -1) then{                      //Key already exists, update value.
  12.   (_array select 1) set [_needle,_value];          
  13. } else{                                     //Create new Key and Value.
  14.   (_array select 1) set [count (_array select 0),_value];
  15.   (_array select 0) set [count (_array select 0),_key];
  16. };
  17.  
  18. _array set [2,(count (_array select 0))]; //Update Checksum
  19.  
  20. _array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement