Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. -- 1 - inventory 1, 2 - inventory 2, 3 - weapon, 4 - medic, 5 - ammo
  2. function IsInventorySlotFree( iType, pInputItem )
  3.     if iType == 1 then
  4.         return IsInventoryHasFreeItemSlot( pInputItem, 1 ); -- Есть ли свободное место в инвентаре 1?
  5.     elseif iType == 2 then
  6.         return IsInventoryHasFreeItemSlot( pInputItem, 2 ); -- Есть ли свободное место в инвентаре 1?
  7.     end
  8.    
  9.     local iMax;
  10.     local iStart, iEnd;
  11.    
  12.     if iType == 3 then
  13.         iMax                = 4; -- TODO: Получаем кол-во свободных слотов оружейных с учетом навыков..
  14.         iStart              = 9;
  15.         iEnd                = 12;
  16.     elseif iType == 4 then
  17.         iMax                = 4; -- TODO: Получаем кол-во свободных слотов медицинских с учетом навыков.
  18.         iStart              = 13;
  19.         iEnd                = 16;
  20.     elseif iType == 5 then
  21.         iMax                = 5; -- TODO: Получаем кол-во свободных слотов патронташа с учетом навыков..
  22.         iStart              = 17;
  23.         iEnd                = 21;
  24.     end
  25.    
  26.     local bResult = true;
  27.     local iCount = 0;
  28.     local iFree = iStart;
  29.    
  30.     for iInventoryType, aInventory in ipairs( g_aInventoryItems ) do
  31.         for _, DrawData in ipairs( aInventory ) do
  32.             local pItem = DrawData[ 1 ];
  33.  
  34.             local iRow = pItem.y;
  35.            
  36.            
  37.             if iRow >= iStart and iRow <= iEnd then
  38.                 if iInventoryType == 1 then
  39.                     iFree = iFree + 1;
  40.                 end
  41.                
  42.                 iCount = iCount + 1;
  43.                
  44.                 if iCount == iMax then
  45.                     bResult = false;
  46.                 end
  47.             end
  48.            
  49.            
  50.         end
  51.     end
  52.    
  53.     return bResult, iFree;
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement