Beispiel #1
0
        /// <summary>
        /// Sends every modified weapon to the player.
        /// Steps:
        /// Change every weapon to default values.
        /// Stores the index of every modified weapon, and stores the index as the max index.
        /// Fill the player's inventory with a placeholder item up to the max index.
        /// Removes every item that was modified serverside with the list of indexes.
        /// Starts to drop the modified items.
        /// </summary>
        public static void SendCustomItems(PvPPlayer player)
        {
            RefreshInventory(player);
            List <int>       itemIndex = new List <int>();
            InventoryIndexer indexer   = new InventoryIndexer();

            for (byte loop = 0; loop < indexer.MaxInventoryCycle; loop++)
            {
                int index = indexer.NextIndex();

                Item item = player.TPlayer.inventory[index];

                var custwep = GetCustomWeapon(player, item.type, item.prefix, (short)item.stack);
                if (IsModifiedItem(custwep.ItemNetId))
                {
                    indexer.StoreMaxIndex(index);
                    itemIndex.Add(index);
                    player.InvTracker.AddItem(custwep);
                }
            }

            if (itemIndex.Count != 0)
            {
                SSCUtils.FillInventoryToIndex(player, Constants.EmptyItem, Constants.JunkItem, indexer.MaxIndex);
                foreach (int num in itemIndex)
                {
                    SSCUtils.SetItem(player, (byte)num, Constants.EmptyItem);
                }
                player.InvTracker.StartDroppingItems();
            }
            else
            {
                player.InvTracker.CheckFinishedModifications(0);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Changes every item in a player's inventory to be the default values.
 /// </summary>
 public static void RefreshInventory(PvPPlayer player)
 {
     player.InvTracker.OnPvPInventoryChecked = false;
     for (byte index = 0; index < 58; index++)
     {
         SSCUtils.SetItem(player, index, player.TPlayer.inventory[index]);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Changes every item in a player's inventory that matches the item ID to the default values.
 /// </summary>
 /// <param name="itemID">Numerical ID of item to be reset.</param>
 public static void RefreshItem(PvPPlayer player, int itemID)
 {
     for (byte index = 0; index <= 58; index++)
     {
         if (player.TPlayer.inventory[index].netID == itemID)
         {
             SSCUtils.SetItem(player, index, player.TPlayer.inventory[index]);
         }
     }
 }