Advertisement
Guest User

Untitled

a guest
May 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. _mode = _this select 0;
  2. //1 : Add Inventory
  3. //2 : Del Inventory
  4. //3 : Check Item
  5. //4 : Check Weight
  6. //5 : Change Item
  7. //6 : Change Weight
  8. //7 : Show Inventory
  9. //8 : Show Item
  10. //9 : Show Weight
  11. //10: Update Item
  12. //11: Update Inventory
  13.  
  14. switch(_mode) do {
  15. case 1 : {
  16. _Item = _this select 1;
  17. _Nbr = _this select 2;
  18. //3
  19. if (_Ok)
  20. then {
  21. Inventaire pushback [__item,_Nbr]//finir poids
  22. true;
  23. } else {
  24. false;
  25. };
  26. };
  27. case 2 : {
  28. _Item = _this select 1;
  29. _Nbr = _this select 2
  30. //3
  31. if (_Ok)
  32. then {
  33. {
  34. if ((_x select 0) isEqualto _Item)
  35. then {
  36. Inventaire - _x;
  37. true;
  38. };
  39. } forEach Inventaire
  40. } else {
  41. false;
  42. };
  43. };
  44. case 3:{
  45. _Item =_this select 1;
  46. _Nbr =_this select 2;
  47. if (_Item in Inventaire)
  48. then {
  49. _a = Inventaire find _Item;
  50. if ((a select 1) >= _Nbr)
  51. then {
  52. true;
  53. } else {
  54. false;
  55. };
  56. } else {
  57. false;
  58. };
  59. };
  60. case 4 : {
  61. _Weight =_this select 1;
  62. if (_Weight + ((Inventaire select 0) select 0)) <= ((Inventaire select 0) select 1)) && (((Inventaire select 0) select 0) + _Weight >= 0))
  63. then {
  64. true;
  65. } else {
  66. false;
  67. };
  68. };
  69. case 5 : {
  70. _Item = _this select 1;
  71. _Nbr = _this select 2;
  72. //3
  73. if (_Ok)
  74. then {
  75. _index = Inventaire find _Item;
  76. _a = Inventaire select _index;
  77. if ((_a select 1) + _Nbr >= 0)
  78. then {
  79. if ((_a select 1) + _Nbr isEqualto 0)
  80. then {
  81. //2
  82. } else {
  83. _a set[1,(_a select 1) + _Nbr];
  84. Inventaire set [_index,_a];
  85. true;
  86. };
  87. } else {
  88. false ;
  89. };
  90. } else {
  91. false;
  92. };
  93. };
  94. case 6 :{
  95. _Weight = _this select 1;
  96. //4
  97. if (_Ok)
  98. then {
  99. Inventaire set [0,[((Inventaire select 0)select 0) + _Nbr,((Inventaire select 0)select 1)]];
  100. true;
  101. } else {
  102. false;
  103. };
  104. };
  105. case 7 :{
  106. _return = Iventaire - (Inventaire select 0);
  107. _return;
  108. };
  109. case 8 :{
  110. _Item = _this select 1;
  111. //3
  112. if (_Ok)
  113. then {
  114. _index = Inventaire find _Item;
  115. _a = Inventaire select _index;
  116. _a;
  117. } else {
  118. false;
  119. };
  120. };
  121. case 9 :{
  122. _Weight = Inventaire select 0;
  123. _Weight;
  124. };
  125. case 10:{
  126. _Item =_this select 1;
  127. //Val
  128. (_Val select 0) ;
  129. };
  130. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement