daily pastebin goal
74%
SHARE
TWEET

DayZ: find item in player inventory

a guest Jan 24th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     bool CheckItem(PlayerBase player, string itemClass)
  2.     {
  3.         EntityAI attachment, subattachment; //attachments variables
  4.         int AttCount, SubAttCount; //attachments count variables
  5.         ItemBase subItem; //Item variable
  6.         string className; //Item class name variable
  7.         bool itemFound = false; // Result / default is false
  8.        
  9.         AttCount = player.GetInventory().AttachmentCount(); //Player Attachments (items on player, like clothes, backpack etc.) count for cycle
  10.         for ( int i = 0; i < AttCount; i++ ) //Check Attachments cycle
  11.         {
  12.             attachment = player.GetInventory().GetAttachmentFromIndex(i); // Get player attachment
  13.  
  14.             SubAttCount = attachment.GetInventory().AttachmentCount(); //How many subattachments in player attachment - count for cycle
  15.             for ( int a = 0; a < SubAttCount; a++ )
  16.             {
  17.                 subattachment = attachment.GetInventory().GetAttachmentFromIndex(a); // Get subattachment in attachment
  18.                 subItem = ItemBase.Cast(subattachment); //Cast subattachment to item
  19.                 className = subItem.GetType(); //Get class name of subattachment
  20.                 if ( className == itemClass ) //Check class of item (subattachment)
  21.                 {
  22.                      itemFound = true; //Item found!
  23.                      break; //break 2nd cycle
  24.                 }
  25.             }
  26.             if (mapFound) break; //break 1st cycle
  27.         }
  28.         return itemFound; //return result
  29.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top