Ejemplo n.º 1
0
    private void EventData_Event(object obj)
    {
        World world = GameManager.Instance.World;

        var eventData = obj as TimerEventData;

        object[] objArray = (object[])eventData.Data;

        int        _clrIdx    = (int)objArray[0];
        BlockValue blockValue = (BlockValue)objArray[1];

        Vector3i   vector3i = (Vector3i)objArray[2];
        BlockValue block    = world.GetBlock(vector3i);

        EntityPlayerLocal entityPlayerLocal = objArray[3] as EntityPlayerLocal;

        if (block.damage > 0)
        {
            GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied");
        }
        else if (block.type != blockValue.type)
        {
            GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttBlockMissingPickup", string.Empty), "ui_denied");
        }
        else
        {
            TileEntitySecureLootContainer tileEntity = world.GetTileEntity(_clrIdx, vector3i) as TileEntitySecureLootContainer;
            if (tileEntity.IsUserAccessing())
            {
                GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttCantPickupInUse", string.Empty), "ui_denied");
            }
            else
            {
                LocalPlayerUI uiForPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
                ItemStack     itemStack   = new ItemStack(block.ToItemValue(), 1);
                if (!uiForPlayer.xui.PlayerInventory.AddItem(itemStack, true))
                {
                    uiForPlayer.xui.PlayerInventory.DropItem(itemStack);
                }
                world.SetBlockRPC(_clrIdx, vector3i, BlockValue.Air);
            }
        }
    }
Ejemplo n.º 2
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (int.TryParse(_price, out int _auctionPrice))
                 {
                     if (_auctionPrice > 0)
                     {
                         if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction == null)
                         {
                             Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>();
                             PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                             PersistentContainer.Instance.Save();
                         }
                         else if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count < Total_Items)
                         {
                             LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                             DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                             ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                             for (int i = 0; i < _chunklist.Count; i++)
                             {
                                 ChunkCluster _chunk = _chunklist[i];
                                 _chunkArray = _chunk.GetChunkArray();
                                 foreach (Chunk _c in _chunkArray)
                                 {
                                     _tiles = _c.GetTileEntities();
                                     foreach (TileEntity _tile in _tiles.dict.Values)
                                     {
                                         TileEntityType _type = _tile.GetTileEntityType();
                                         if (_type.ToString().Equals("SecureLoot"))
                                         {
                                             TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                             Vector3i vec3i = SecureLoot.ToWorldPos();
                                             if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                             {
                                                 if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                 {
                                                     if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                                     {
                                                         ItemStack[] items = SecureLoot.items;
                                                         ItemStack   _item = items[0];
                                                         if (_item != null && !_item.IsEmpty())
                                                         {
                                                             int _id = GenerateAuctionId();
                                                             if (_id > 0)
                                                             {
                                                                 AuctionItems.Add(_id, _cInfo.playerId);
                                                                 items[0] = ItemStack.Empty.Clone();
                                                                 if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction != null && PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count > 0)
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Add(_id, _serializedItemStack);
                                                                 }
                                                                 else
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>();
                                                                     _auctionItems.Add(_id, _serializedItemStack);
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                                                                 }
                                                                 if (PersistentContainer.Instance.AuctionPrices != null && PersistentContainer.Instance.AuctionPrices.Count > 0)
                                                                 {
                                                                     PersistentContainer.Instance.AuctionPrices.Add(_id, _auctionPrice);
                                                                 }
                                                                 else
                                                                 {
                                                                     Dictionary <int, int> _auctionPrices = new Dictionary <int, int>();
                                                                     _auctionPrices.Add(_id, _auctionPrice);
                                                                     PersistentContainer.Instance.AuctionPrices = _auctionPrices;
                                                                 }
                                                                 PersistentContainer.Instance.Save();
                                                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                                                 {
                                                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} {4}, {5} quality, {6} percent durability for {7} {8}.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _item.count, _item.itemValue.ItemClass.GetItemName(), _item.itemValue.Quality, _item.itemValue.UseTimes / _item.itemValue.MaxUseTimes * 100, _price, Wallet.Coin_Name));
                                                                     sw.WriteLine();
                                                                     sw.Flush();
                                                                     sw.Close();
                                                                 }
                                                                 string _message = "Your auction item {Name} has been removed from the secure loot and added to the auction.";
                                                                 _message = _message.Replace("{Name}", _item.itemValue.ItemClass.GetLocalizedItemName() ?? _item.itemValue.ItemClass.GetItemName());
                                                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                                 _tile.SetModified();
                                                                 return;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         else
                         {
                             string _message = "You have the max auction items already listed. Wait for one to sell or cancel it with {CommandPrivate}{Command72} #.";
                             _message = _message.Replace("{CommandPrivate}", ChatHook.Command_Private);
                             _message = _message.Replace("{Command72}", Command72);
                             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You need to input a price greater than zero. This is not a transfer system.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Your sell price must be an integer and greater than zero.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in AuctionBox.CheckBox: {0}", e.Message));
     }
 }
Ejemplo n.º 3
0
 public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount)
 {
     try
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 ItemValue _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1);
                 if (_itemValue != null)
                 {
                     int _coinId = _itemValue.GetItemOrBlockId();
                     if (int.TryParse(_amount, out int _value))
                     {
                         if (_value > 0)
                         {
                             int _currencyToRemove          = _value;
                             int _currencyRemoved           = 0;
                             LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                             DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                             ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                             for (int i = 0; i < _chunklist.Count; i++)
                             {
                                 ChunkCluster _chunkCluster = _chunklist[i];
                                 _chunkArray = _chunkCluster.GetChunkArray();
                                 foreach (Chunk _chunk in _chunkArray)
                                 {
                                     _tiles = _chunk.GetTileEntities();
                                     foreach (TileEntity _tile in _tiles.dict.Values)
                                     {
                                         TileEntityType type = _tile.GetTileEntityType();
                                         if (type.ToString().Equals("SecureLoot"))
                                         {
                                             TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                             if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                             {
                                                 Vector3i vec3i = SecureLoot.ToWorldPos();
                                                 if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                                 {
                                                     if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                     {
                                                         ItemStack[] _items = SecureLoot.items;
                                                         if (_items != null && _items.Length > 0)
                                                         {
                                                             for (int j = 0; j < _items.Length; j++)
                                                             {
                                                                 if (_currencyToRemove > 0)
                                                                 {
                                                                     if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _coinId)
                                                                     {
                                                                         if (_items[j].count <= _currencyToRemove)
                                                                         {
                                                                             int _newCount  = _currencyToRemove - _items[j].count;
                                                                             int _newCount2 = _currencyRemoved + _items[j].count;
                                                                             _currencyToRemove = _newCount;
                                                                             _currencyRemoved  = _newCount2;
                                                                             _items[j]         = ItemStack.Empty.Clone();
                                                                         }
                                                                         else
                                                                         {
                                                                             int _newCount      = _currencyRemoved + _currencyToRemove;
                                                                             int _newStackCount = _items[j].count - _currencyToRemove;
                                                                             _currencyToRemove = 0;
                                                                             _currencyRemoved  = _newCount;
                                                                             _items[j]         = new ItemStack(_itemValue, _newStackCount);
                                                                         }
                                                                         _tile.SetModified();
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                             if (_currencyRemoved > 0)
                             {
                                 if (Deposit_Fee_Percent > 0)
                                 {
                                     float _fee             = _currencyRemoved * ((float)Deposit_Fee_Percent / 100);
                                     int   _adjustedDeposit = _currencyRemoved - (int)_fee;
                                     AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                                     using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                                     {
                                         sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _adjustedDeposit));
                                         sw.WriteLine();
                                         sw.Flush();
                                         sw.Close();
                                     }
                                     Phrases.Dict.TryGetValue(643, out string _phrase643);
                                     _phrase643 = _phrase643.Replace("{Value}", _adjustedDeposit.ToString());
                                     _phrase643 = _phrase643.Replace("{CoinName}", Ingame_Coin);
                                     _phrase643 = _phrase643.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase643 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                 }
                                 else
                                 {
                                     AddCoinsToBank(_cInfo.playerId, _currencyRemoved);
                                     using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                                     {
                                         sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _currencyRemoved));
                                         sw.WriteLine();
                                         sw.Flush();
                                         sw.Close();
                                     }
                                     Phrases.Dict.TryGetValue(644, out string _phrase644);
                                     _phrase644 = _phrase644.Replace("{Value}", _currencyRemoved.ToString());
                                     _phrase644 = _phrase644.Replace("{CoinName}", Ingame_Coin);
                                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase644 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                 }
                             }
                             else
                             {
                                 Phrases.Dict.TryGetValue(645, out string _phrase645);
                                 _phrase645 = _phrase645.Replace("{CoinName}", Ingame_Coin);
                                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase645 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                             }
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue(646, out string _phrase646);
                             _phrase646 = _phrase646.Replace("{CommandPrivate}", ChatHook.Chat_Command_Prefix1);
                             _phrase646 = _phrase646.Replace("{Command95}", Command95);
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase646 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue(646, out string _phrase646);
                         _phrase646 = _phrase646.Replace("{CommandPrivate}", ChatHook.Chat_Command_Prefix1);
                         _phrase646 = _phrase646.Replace("{Command95}", Command95);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase646 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue(647, out string _phrase647);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase647 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     Log.Out(string.Format("[SERVERTOOLS] Bank operation failed. Unable to find item {0}. Check the default game currency from your items.xml", Ingame_Coin));
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Bank.ChestToBankDeposit: {0}", e.Message));
     }
 }
Ejemplo n.º 4
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         if (AuctionItems.ContainsKey(_cInfo.entityId))
         {
             string _message = " you have auction item # {Value} in the auction already. Wait for it to sell or cancel it with {CommandPrivate}{Command72}.";
             _message = _message.Replace("{Value}", _cInfo.entityId.ToString());
             _message = _message.Replace("{CommandPrivate}", ChatHook.Command_Private);
             _message = _message.Replace("{Command72}", Command72);
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         else
         {
             int _p;
             if (int.TryParse(_price, out _p))
             {
                 if (_p > 0)
                 {
                     LinkedList <Chunk> chunkArray = new LinkedList <Chunk>();
                     DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
                     ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                     for (int i = 0; i < chunklist.Count; i++)
                     {
                         ChunkCluster chunk = chunklist[i];
                         chunkArray = chunk.GetChunkArray();
                         foreach (Chunk _c in chunkArray)
                         {
                             tiles = _c.GetTileEntities();
                             foreach (TileEntity tile in tiles.dict.Values)
                             {
                                 TileEntityType type = tile.GetTileEntityType();
                                 if (type.ToString().Equals("SecureLoot"))
                                 {
                                     EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                     TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                     Vector3i vec3i = SecureLoot.ToWorldPos();
                                     if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 2.5f * 2.5f)
                                     {
                                         if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                         {
                                             ItemStack[] items = SecureLoot.items;
                                             ItemStack   _item = items[0];
                                             if (_item != null && !_item.IsEmpty())
                                             {
                                                 ItemClass _itemClass = ItemClass.list[_item.itemValue.type];
                                                 string    _itemName  = _item.itemValue.ItemClass.GetItemName();
                                                 SecureLoot.UpdateSlot(0, ItemStack.Empty.Clone());
                                                 AuctionItems.Add(_cInfo.entityId, _cInfo.playerId);
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionId          = _cInfo.entityId;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemName    = _itemName;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemCount   = _item.count;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemQuality = _item.itemValue.Quality;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionItemPrice   = _p;
                                                 PersistentContainer.Instance.Players[_cInfo.playerId].AuctionCancelTime  = DateTime.Now;
                                                 PersistentContainer.Instance.Save();
                                                 string _message = " your auction item {Name} has been removed from the secure loot and added to the auction.";
                                                 _message = _message.Replace("{Name}", _itemName);
                                                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                                 Log.Out(string.Format("{0} has added {1} {2}, {3} quality to the auction for {4} {5}.", _cInfo.playerName, _item.count, _itemName, _item.itemValue.Quality, _price, Wallet.Coin_Name));
                                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                                 {
                                                     sw.WriteLine(string.Format("{0}: {1} has added {2} {3}, {4} quality to the auction for {5} {6}.", DateTime.Now, _cInfo.playerName, _item.count, _itemName, _item.itemValue.Quality, _price, Wallet.Coin_Name));
                                                     sw.WriteLine();
                                                     sw.Flush();
                                                     sw.Close();
                                                 }
                                                 return;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " no item was found in the first slot of the secure chest near you." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you need to input a price greater than zero. This is not a transfer system.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " your sell price must be an integer and greater than zero.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in AuctionBox.CheckBox: {0}.", e));
     }
 }
Ejemplo n.º 5
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
         if (player != null)
         {
             if (int.TryParse(_price, out int auctionPrice))
             {
                 if (auctionPrice > 0)
                 {
                     if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction == null)
                     {
                         Dictionary <int, ItemDataSerializable> auctionItems = new Dictionary <int, ItemDataSerializable>();
                         PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction = auctionItems;
                         PersistentContainer.DataChange = true;
                     }
                     else if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction.Count < Total_Items)
                     {
                         List <Chunk> chunks = new List <Chunk>();
                         DictionaryList <Vector3i, TileEntity> tiles = new DictionaryList <Vector3i, TileEntity>();
                         Vector3 _position = player.position;
                         Chunk   chunk     = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos((int)_position.x - 5, (int)_position.y, (int)_position.z);
                         if (chunk != null && !chunks.Contains(chunk))
                         {
                             chunks.Add(chunk);
                         }
                         chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos((int)_position.x + 5, (int)_position.y, (int)_position.z);
                         if (chunk != null && !chunks.Contains(chunk))
                         {
                             chunks.Add(chunk);
                         }
                         chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos((int)_position.x, (int)_position.y, (int)_position.z - 5);
                         if (chunk != null && !chunks.Contains(chunk))
                         {
                             chunks.Add(chunk);
                         }
                         chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos((int)_position.x + 5, (int)_position.y, (int)_position.z + 5);
                         if (chunk != null && !chunks.Contains(chunk))
                         {
                             chunks.Add(chunk);
                         }
                         for (int i = 0; i < chunks.Count; i++)
                         {
                             tiles = chunks[i].GetTileEntities();
                             foreach (TileEntity tile in tiles.dict.Values)
                             {
                                 TileEntityType type = tile.GetTileEntityType();
                                 if (type.ToString().Equals("SecureLoot"))
                                 {
                                     TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                     Vector3i vec3i = SecureLoot.ToWorldPos();
                                     if ((vec3i.x - player.position.x) * (vec3i.x - player.position.x) + (vec3i.z - player.position.z) * (vec3i.z - player.position.z) <= 3 * 3)
                                     {
                                         if (vec3i.y >= (int)player.position.y - 3 && vec3i.y <= (int)player.position.y + 3)
                                         {
                                             if (SecureLoot.IsUserAllowed(_cInfo.InternalId) && !SecureLoot.IsUserAccessing())
                                             {
                                                 ItemStack[] items = SecureLoot.items;
                                                 ItemStack   item  = items[0];
                                                 if (item != null && !item.IsEmpty())
                                                 {
                                                     if (item.itemValue.Modifications.Length > 0)
                                                     {
                                                         for (int j = 0; j < item.itemValue.Modifications.Length; j++)
                                                         {
                                                             if (!item.itemValue.Modifications[j].IsEmpty())
                                                             {
                                                                 Phrases.Dict.TryGetValue("Auction18", out string phrase);
                                                                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                                                 return;
                                                             }
                                                         }
                                                     }
                                                     if (item.itemValue.CosmeticMods.Length > 0)
                                                     {
                                                         for (int j = 0; j < item.itemValue.CosmeticMods.Length; j++)
                                                         {
                                                             if (!item.itemValue.CosmeticMods[j].IsEmpty())
                                                             {
                                                                 Phrases.Dict.TryGetValue("Auction18", out string _phrase);
                                                                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                                                 return;
                                                             }
                                                         }
                                                     }
                                                     int id = GenerateAuctionId();
                                                     if (id > 0)
                                                     {
                                                         AuctionItems.Add(id, _cInfo.CrossplatformId.CombinedString);
                                                         items[0] = ItemStack.Empty.Clone();
                                                         ItemDataSerializable serializedItemStack = new ItemDataSerializable();
                                                         {
                                                             serializedItemStack.name     = item.itemValue.ItemClass.GetItemName();
                                                             serializedItemStack.count    = item.count;
                                                             serializedItemStack.useTimes = item.itemValue.UseTimes;
                                                             serializedItemStack.quality  = item.itemValue.Quality;
                                                             serializedItemStack.seed     = item.itemValue.Seed;
                                                             if (item.itemValue.Modifications.Length > 0)
                                                             {
                                                                 serializedItemStack.modSlots = item.itemValue.Modifications.Length;
                                                             }
                                                             else
                                                             {
                                                                 serializedItemStack.modSlots = 0;
                                                             }
                                                             if (item.itemValue.CosmeticMods.Length > 0)
                                                             {
                                                                 serializedItemStack.cosmeticSlots = item.itemValue.CosmeticMods.Length;
                                                             }
                                                             else
                                                             {
                                                                 serializedItemStack.cosmeticSlots = 0;
                                                             }
                                                         }
                                                         if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction != null && PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction.Count > 0)
                                                         {
                                                             PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction.Add(id, serializedItemStack);
                                                         }
                                                         else
                                                         {
                                                             Dictionary <int, ItemDataSerializable> auctionItems = new Dictionary <int, ItemDataSerializable>
                                                             {
                                                                 { id, serializedItemStack }
                                                             };
                                                             PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Auction = auctionItems;
                                                         }
                                                         if (PersistentContainer.Instance.AuctionPrices != null && PersistentContainer.Instance.AuctionPrices.Count > 0)
                                                         {
                                                             PersistentContainer.Instance.AuctionPrices.Add(id, auctionPrice);
                                                         }
                                                         else
                                                         {
                                                             Dictionary <int, int> _auctionPrices = new Dictionary <int, int>
                                                             {
                                                                 { id, auctionPrice }
                                                             };
                                                             PersistentContainer.Instance.AuctionPrices = _auctionPrices;
                                                         }
                                                         tile.SetModified();
                                                         PersistentContainer.DataChange = true;
                                                         if (item.itemValue.HasQuality)
                                                         {
                                                             using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8))
                                                             {
                                                                 sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' has added '{4}' '{5}', '{6}' quality, '{7}' percent durability for '{8}' '{9}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, item.count, item.itemValue.ItemClass.GetItemName(), item.itemValue.Quality, item.itemValue.UseTimes / item.itemValue.MaxUseTimes * 100, _price, Wallet.Currency_Name));
                                                                 sw.WriteLine();
                                                                 sw.Flush();
                                                                 sw.Close();
                                                             }
                                                         }
                                                         else
                                                         {
                                                             using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8))
                                                             {
                                                                 sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' has added '{4}' '{5}' for '{6}' '{7}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, item.count, item.itemValue.ItemClass.GetItemName(), _price, Wallet.Currency_Name));
                                                                 sw.WriteLine();
                                                                 sw.Flush();
                                                                 sw.Close();
                                                             }
                                                         }
                                                         Phrases.Dict.TryGetValue("Auction1", out string phrase);
                                                         phrase = phrase.Replace("{Name}", item.itemValue.ItemClass.GetLocalizedItemName() ?? item.itemValue.ItemClass.GetItemName());
                                                         phrase = phrase.Replace("{Value}", id.ToString());
                                                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                                         return;
                                                     }
                                                     else
                                                     {
                                                         Phrases.Dict.TryGetValue("Auction16", out string _phrase);
                                                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue("Auction2", out string phrase);
                         phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1);
                         phrase = phrase.Replace("{Command_auction_cancel}", Command_auction_cancel);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue("Auction3", out string phrase);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 Phrases.Dict.TryGetValue("Auction4", out string phrase);
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Auction.CheckBox: {0}", e.Message));
     }
 }
Ejemplo n.º 6
0
 public static void CheckBox(ClientInfo _cInfo, string _price)
 {
     try
     {
         if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
         {
             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player != null)
             {
                 if (int.TryParse(_price, out int _auctionPrice))
                 {
                     if (_auctionPrice > 0)
                     {
                         if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction == null)
                         {
                             Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>();
                             PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                             PersistentContainer.DataChange = true;
                         }
                         else if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count < Total_Items)
                         {
                             LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                             DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                             ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                             for (int i = 0; i < _chunklist.Count; i++)
                             {
                                 ChunkCluster _chunk = _chunklist[i];
                                 _chunkArray = _chunk.GetChunkArray();
                                 foreach (Chunk _c in _chunkArray)
                                 {
                                     _tiles = _c.GetTileEntities();
                                     foreach (TileEntity _tile in _tiles.dict.Values)
                                     {
                                         TileEntityType _type = _tile.GetTileEntityType();
                                         if (_type.ToString().Equals("SecureLoot"))
                                         {
                                             TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                             Vector3i vec3i = SecureLoot.ToWorldPos();
                                             if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                             {
                                                 if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                 {
                                                     if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                                     {
                                                         ItemStack[] items = SecureLoot.items;
                                                         ItemStack   _item = items[0];
                                                         if (_item != null && !_item.IsEmpty())
                                                         {
                                                             int _id = GenerateAuctionId();
                                                             if (_id > 0)
                                                             {
                                                                 AuctionItems.Add(_id, _cInfo.playerId);
                                                                 items[0] = ItemStack.Empty.Clone();
                                                                 if (PersistentContainer.Instance.Players[_cInfo.playerId].Auction != null && PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Count > 0)
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction.Add(_id, _serializedItemStack);
                                                                 }
                                                                 else
                                                                 {
                                                                     ItemDataSerializable _serializedItemStack = new ItemDataSerializable();
                                                                     {
                                                                         _serializedItemStack.name     = _item.itemValue.ItemClass.GetItemName();
                                                                         _serializedItemStack.count    = _item.count;
                                                                         _serializedItemStack.useTimes = _item.itemValue.UseTimes;
                                                                         _serializedItemStack.quality  = _item.itemValue.Quality;
                                                                     }
                                                                     Dictionary <int, ItemDataSerializable> _auctionItems = new Dictionary <int, ItemDataSerializable>
                                                                     {
                                                                         { _id, _serializedItemStack }
                                                                     };
                                                                     PersistentContainer.Instance.Players[_cInfo.playerId].Auction = _auctionItems;
                                                                 }
                                                                 if (PersistentContainer.Instance.AuctionPrices != null && PersistentContainer.Instance.AuctionPrices.Count > 0)
                                                                 {
                                                                     PersistentContainer.Instance.AuctionPrices.Add(_id, _auctionPrice);
                                                                 }
                                                                 else
                                                                 {
                                                                     Dictionary <int, int> _auctionPrices = new Dictionary <int, int>
                                                                     {
                                                                         { _id, _auctionPrice }
                                                                     };
                                                                     PersistentContainer.Instance.AuctionPrices = _auctionPrices;
                                                                 }
                                                                 _tile.SetModified();
                                                                 PersistentContainer.DataChange = true;
                                                                 using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8))
                                                                 {
                                                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} {4}, {5} quality, {6} percent durability for {7} {8}.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _item.count, _item.itemValue.ItemClass.GetItemName(), _item.itemValue.Quality, _item.itemValue.UseTimes / _item.itemValue.MaxUseTimes * 100, _price, Wallet.Coin_Name));
                                                                     sw.WriteLine();
                                                                     sw.Flush();
                                                                     sw.Close();
                                                                 }
                                                                 Phrases.Dict.TryGetValue(621, out string _phrase621);
                                                                 _phrase621 = _phrase621.Replace("{Name}", _item.itemValue.ItemClass.GetLocalizedItemName() ?? _item.itemValue.ItemClass.GetItemName());
                                                                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase621 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                                                                 return;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         else
                         {
                             Phrases.Dict.TryGetValue(622, out string _phrase622);
                             _phrase622 = _phrase622.Replace("{CommandPrivate}", ChatHook.Chat_Command_Prefix1);
                             _phrase622 = _phrase622.Replace("{Command72}", Command72);
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase622 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         Phrases.Dict.TryGetValue(623, out string _phrase623);
                         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase623 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     Phrases.Dict.TryGetValue(624, out string _phrase624);
                     ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase624 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in AuctionBox.CheckBox: {0}", e.Message));
     }
 }
Ejemplo n.º 7
0
        public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount)
        {
            ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, false);

            if (CoinCheck(_cInfo, _itemValue))
            {
                int _value;
                if (int.TryParse(_amount, out _value))
                {
                    _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1);
                    int _currencyToRemove      = _value;
                    int _currencyRemoved       = 0;
                    ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters;
                    for (int i = 0; i < chunklist.Count; i++)
                    {
                        if (_currencyToRemove > 0)
                        {
                            ChunkCluster chunk = chunklist[i];
                            chunkArray = chunk.GetChunkArray();
                            foreach (Chunk _c in chunkArray)
                            {
                                tiles = _c.GetTileEntities();
                                foreach (TileEntity tile in tiles.dict.Values)
                                {
                                    TileEntityType type = tile.GetTileEntityType();
                                    if (type.ToString().Equals("SecureLoot"))
                                    {
                                        TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile;
                                        if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                        {
                                            Vector3i     vec3i   = SecureLoot.ToWorldPos();
                                            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                            if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 2.5 * 2.5)
                                            {
                                                ItemStack[] _items = SecureLoot.items;
                                                for (int j = 0; j < _items.Length; j++)
                                                {
                                                    if (_currencyToRemove > 0)
                                                    {
                                                        if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _itemValue.GetItemOrBlockId())
                                                        {
                                                            if (_items[j].count <= _currencyToRemove)
                                                            {
                                                                int _newCount  = _currencyToRemove - _items[j].count;
                                                                int _newCount2 = _currencyRemoved + _items[j].count;
                                                                _currencyToRemove = _newCount;
                                                                _currencyRemoved  = _newCount2;
                                                                _items[j]         = ItemStack.Empty.Clone();
                                                            }
                                                            else
                                                            {
                                                                int _newCount      = _currencyRemoved + _currencyToRemove;
                                                                int _newStackCount = _items[j].count - _currencyToRemove;
                                                                _currencyToRemove = 0;
                                                                _currencyRemoved  = _newCount;
                                                                _items[j]         = new ItemStack(_itemValue, _newStackCount);
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (_currencyRemoved > 0)
                    {
                        if (Deposit_Fee_Percent > 0)
                        {
                            int _depositFeePercent = Deposit_Fee_Percent / 100;
                            int _depositFee        = (int)_currencyRemoved * _depositFeePercent;
                            int _adjustedDeposit   = _currencyRemoved - _depositFee;
                            AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                            string _message = " deposited {Value} {Name} from the secure loot to your bank account. " + " {Percent}" + "% fee was applied.";
                            _message = _message.Replace("{Value}", _value.ToString());
                            _message = _message.Replace("{Name}", Ingame_Coin);
                            _message = _message.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                            ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            using (StreamWriter sw = new StreamWriter(filepath, true))
                            {
                                sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerName, _currencyRemoved));
                                sw.WriteLine();
                                sw.Flush();
                                sw.Close();
                            }
                            using (StreamWriter sw = new StreamWriter(filepath, true))
                            {
                                sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerName, _adjustedDeposit));
                                sw.WriteLine();
                                sw.Flush();
                                sw.Close();
                            }
                        }
                        else
                        {
                            AddCoinsToBank(_cInfo.playerId, _currencyRemoved);
                            string _message = "Removed {Total} {Name} and deposited it to your bank. ";
                            _message = _message.Replace("{Total}", _currencyRemoved.ToString());
                            _message = _message.Replace("{Name}", Ingame_Coin);
                            ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                            using (StreamWriter sw = new StreamWriter(filepath, true))
                            {
                                sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerName, _currencyRemoved));
                                sw.WriteLine();
                                sw.Flush();
                                sw.Close();
                            }
                        }
                    }
                    else
                    {
                        string _message = "Could not find any {Name} in a near by secure loot.";
                        _message = _message.Replace("{Name}", Ingame_Coin);
                        ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
        }
Ejemplo n.º 8
0
 public static void ChestToBankDeposit(ClientInfo _cInfo, string _amount)
 {
     if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId))
     {
         EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
         if (_player != null)
         {
             ItemValue _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, false, null, 1);
             if (_itemValue != null)
             {
                 int _coinId = _itemValue.GetItemOrBlockId();
                 if (int.TryParse(_amount, out int _value))
                 {
                     if (_value > 0)
                     {
                         int _currencyToRemove          = _value;
                         int _currencyRemoved           = 0;
                         LinkedList <Chunk> _chunkArray = new LinkedList <Chunk>();
                         DictionaryList <Vector3i, TileEntity> _tiles = new DictionaryList <Vector3i, TileEntity>();
                         ChunkClusterList _chunklist = GameManager.Instance.World.ChunkClusters;
                         for (int i = 0; i < _chunklist.Count; i++)
                         {
                             ChunkCluster _chunk = _chunklist[i];
                             _chunkArray = _chunk.GetChunkArray();
                             foreach (Chunk _c in _chunkArray)
                             {
                                 _tiles = _c.GetTileEntities();
                                 foreach (TileEntity _tile in _tiles.dict.Values)
                                 {
                                     TileEntityType type = _tile.GetTileEntityType();
                                     if (type.ToString().Equals("SecureLoot"))
                                     {
                                         TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)_tile;
                                         if (SecureLoot.IsUserAllowed(_cInfo.playerId) && !SecureLoot.IsUserAccessing())
                                         {
                                             Vector3i vec3i = SecureLoot.ToWorldPos();
                                             if ((vec3i.x - _player.position.x) * (vec3i.x - _player.position.x) + (vec3i.z - _player.position.z) * (vec3i.z - _player.position.z) <= 3 * 3)
                                             {
                                                 if (vec3i.y >= (int)_player.position.y - 3 && vec3i.y <= (int)_player.position.y + 3)
                                                 {
                                                     ItemStack[] _items = SecureLoot.items;
                                                     if (_items != null && _items.Length > 0)
                                                     {
                                                         for (int j = 0; j < _items.Length; j++)
                                                         {
                                                             if (_currencyToRemove > 0)
                                                             {
                                                                 if (!_items[j].IsEmpty() && _items[j].itemValue.GetItemOrBlockId() == _coinId)
                                                                 {
                                                                     if (_items[j].count <= _currencyToRemove)
                                                                     {
                                                                         int _newCount  = _currencyToRemove - _items[j].count;
                                                                         int _newCount2 = _currencyRemoved + _items[j].count;
                                                                         _currencyToRemove = _newCount;
                                                                         _currencyRemoved  = _newCount2;
                                                                         _items[j]         = ItemStack.Empty.Clone();
                                                                     }
                                                                     else
                                                                     {
                                                                         int _newCount      = _currencyRemoved + _currencyToRemove;
                                                                         int _newStackCount = _items[j].count - _currencyToRemove;
                                                                         _currencyToRemove = 0;
                                                                         _currencyRemoved  = _newCount;
                                                                         _items[j]         = new ItemStack(_itemValue, _newStackCount);
                                                                     }
                                                                     _tile.SetModified();
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         if (_currencyRemoved > 0)
                         {
                             if (Deposit_Fee_Percent > 0)
                             {
                                 float _fee             = _currencyRemoved * ((float)Deposit_Fee_Percent / 100);
                                 int   _adjustedDeposit = _currencyRemoved - (int)_fee;
                                 AddCoinsToBank(_cInfo.playerId, _adjustedDeposit);
                                 string _message = "Deposited {Value} {Name} from the secure loot to your bank account. " + "{Percent}" + "% deposit fee was applied.";
                                 _message = _message.Replace("{Value}", _adjustedDeposit.ToString());
                                 _message = _message.Replace("{Name}", Ingame_Coin);
                                 _message = _message.Replace("{Percent}", Deposit_Fee_Percent.ToString());
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                 {
                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _adjustedDeposit));
                                     sw.WriteLine();
                                     sw.Flush();
                                     sw.Close();
                                 }
                             }
                             else
                             {
                                 AddCoinsToBank(_cInfo.playerId, _currencyRemoved);
                                 string _message = "Deposited {Value} {Name} from the secure loot to your bank account.";
                                 _message = _message.Replace("{Value}", _currencyRemoved.ToString());
                                 _message = _message.Replace("{Name}", Ingame_Coin);
                                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 using (StreamWriter sw = new StreamWriter(filepath, true))
                                 {
                                     sw.WriteLine(string.Format("{0}: {1} {2} has added {3} to their bank account from a secure loot.", DateTime.Now, _cInfo.playerId, _cInfo.playerName, _currencyRemoved));
                                     sw.WriteLine();
                                     sw.Flush();
                                     sw.Close();
                                 }
                             }
                         }
                         else
                         {
                             string _message = "Could not find any {CoinName} in a near by secure loot.";
                             _message = _message.Replace("{CoinName}", Ingame_Coin);
                             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                     else
                     {
                         ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You input an invalid integer. Type " + ChatHook.Command_Private + Command95 + " #[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "The bank coin is not setup correctly, contact the server Admin.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 Log.Out(string.Format("[SERVERTOOLS] Bank operation failed. Unable to find item {0}. Check the default game currency from your items.xml", Ingame_Coin));
             }
         }
     }
 }