public BCMTileEntitySecureLootContainer(Vector3i pos, [NotNull] TileEntitySecureLootContainer te) : base(pos, te) { Owner = te.GetOwner(); Users = te.GetUsers(); HasPassword = te.HasPassword(); IsLocked = te.IsLocked(); }
public static void ChestCheck() { 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; AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(SecureLoot.GetOwner()); if (Admin.PermissionLevel > Admin_Level) { ItemStack[] items = SecureLoot.items; int slotNumber = 0; foreach (ItemStack item in items) { if (!item.IsEmpty()) { ItemClass _itemClass = ItemClass.list[item.itemValue.type]; string _itemName = _itemClass.GetItemName(); if (dict.Contains(_itemName)) { int _count = item.count; ItemStack itemStack = new ItemStack(); SecureLoot.UpdateSlot(slotNumber, itemStack); Vector3i _chestPos = SecureLoot.localChunkPos; Log.Out(string.Format("[SERVERTOOLS] Removed {0} {1}, from a chest located at {2} {3} {4}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z)); } } slotNumber++; } } } } } } }
public static void CheckStorage() { try { 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) { if (tile.GetTileEntityType().ToString().Equals("SecureLoot")) { TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile; AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(SecureLoot.GetOwner()); if (Admin.PermissionLevel > Admin_Level) { ItemStack[] items = SecureLoot.items; int slotNumber = 0; foreach (ItemStack item in items) { if (!item.IsEmpty()) { string _itemName = ItemClass.list[item.itemValue.type].Name; if (dict.Contains(_itemName)) { int _count = item.count; ItemStack itemStack = new ItemStack(); SecureLoot.UpdateSlot(slotNumber, itemStack.Clone()); Vector3i _chestPos = SecureLoot.localChunkPos; using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine("[SERVERTOOLS] Removed {0} {1}, from a secure loot located at {2} {3} {4}, owned by {5}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z, SecureLoot.GetOwner()); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Out(string.Format("[SERVERTOOLS] Removed {0} {1}, from a secure loot located at {2} {3} {4}, owned by {5}", item.count, _itemName, _chestPos.x, _chestPos.y, _chestPos.z, SecureLoot.GetOwner())); } } slotNumber++; } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in InventoryCheck.ChestCheck: {0}.", e.Message)); } }
public static void CheckBox(ClientInfo _cInfo, string _price) { string _sql = string.Format("SELECT auctionid, steamid FROM Auction WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { int _auctionid; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _auctionid); string _message = "you have auction item # {Value} in the auction already. Wait for it to sell or cancel it with /auction cancel."; _message = _message.Replace("{Value}", _auctionid.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { int _p; if (int.TryParse(_price, out _p)) { if (_p > 0) { 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) <= 1.5 * 1.5) { int _playerCount = ConnectionManager.Instance.ClientCount(); if (_playerCount > 1) { List <ClientInfo> _cInfoList = ConnectionManager.Instance.Clients.List.ToList(); for (int k = 0; k < _cInfoList.Count; k++) { ClientInfo _cInfo2 = _cInfoList[k]; if (_cInfo != _cInfo2) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8) { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } } } List <string> boxUsers = SecureLoot.GetUsers(); if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId)) { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the local secure loot is not owned by you or a friend. You can only auction an item through a secure loot you own.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } ItemStack[] items = SecureLoot.items; int count = 0; int slotNumber = 0; foreach (ItemStack item in items) { if (!item.IsEmpty()) { if (count < 1) { ItemClass _itemClass = ItemClass.list[item.itemValue.type]; string _itemName = _itemClass.GetItemName(); SecureLoot.UpdateSlot(slotNumber, ItemStack.Empty); _sql = string.Format("INSERT INTO Auction (steamid, itemName, itemCount, itemQuality, itemPrice, cancelTime, sellDate) VALUES ('{0}', '{1}', {2}, {3}, {4}, '{5}', '{6}')", _cInfo.playerId, _itemName, item.count, item.itemValue.Quality, _price, DateTime.Now, DateTime.Now); SQL.FastQuery(_sql); 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 + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); 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(); } count++; } } slotNumber++; } } } } } } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you need to input a price greater than zero. This is not a transfer system.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", your sell price must be an integer and greater than zero.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } _result.Dispose(); }
public static void CheckStorage() { try { LinkedList <Chunk> chunkArray = null; 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(); if (chunkArray != null) { foreach (Chunk c in chunkArray) { tiles = c.GetTileEntities(); if (tiles != null) { foreach (TileEntity tile in tiles.dict.Values) { if (tile.GetTileEntityType().ToString().Equals("SecureLoot")) { TileEntitySecureLootContainer SecureLoot = (TileEntitySecureLootContainer)tile; if (GameManager.Instance.adminTools.GetUserPermissionLevel(SecureLoot.GetOwner()) > Admin_Level) { ItemStack[] items = SecureLoot.items; int slotNumber = 0; foreach (ItemStack item in items) { if (!item.IsEmpty()) { string itemName = ItemClass.list[item.itemValue.type].Name; if (Dict.Contains(itemName)) { ItemStack itemStack = new ItemStack(); SecureLoot.UpdateSlot(slotNumber, itemStack.Clone()); tile.SetModified(); Vector3i _chestPos = SecureLoot.localChunkPos; using (StreamWriter sw = new StreamWriter(DetectionFilepath, true, Encoding.UTF8)) { sw.WriteLine("[SERVERTOOLS] Removed '{0}' '{1}' from a secure loot located at '{2}' owned by '{3}'", item.count, itemName, _chestPos, SecureLoot.GetOwner().CombinedString); } Log.Out(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from a secure loot located at '{2}' owned by '{3}'", item.count, itemName, _chestPos, SecureLoot.GetOwner().CombinedString)); } } slotNumber++; } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in InvalidItems.CheckStorage: {0}", e.Message)); } }
public static void Deposit(ClientInfo _cInfo, string _amount) { bool Found = false; int _coinAmount; if (int.TryParse(_amount, out _coinAmount)) { ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters; for (int i = 0; i < chunklist.Count; i++) { ChunkCluster chunk = chunklist[i]; chunkArray = chunk.GetChunkArray(); for (int j = 0; j < chunkArray.Count; j++) { Chunk _c = chunkArray[j]; 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) <= 1.5 * 1.5) { int _playerCount = ConnectionManager.Instance.ClientCount(); if (_playerCount > 1) { List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients(); for (int k = 0; k < _cInfoList.Count; k++) { ClientInfo _cInfo2 = _cInfoList[k]; if (_cInfo != _cInfo2) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); return; } } } } List <string> boxUsers = SecureLoot.GetUsers(); if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId)) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} the local secure loot is not owned by you. You can only deposit to the bank through a secure loot you own.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); return; } ItemStack[] items = SecureLoot.items; int slotNumber = 0; foreach (ItemStack item in items) { if (!item.IsEmpty()) { ItemClass _itemClass = ItemClass.list[item.itemValue.type]; string _itemName = _itemClass.GetItemName(); if (_itemName == Ingame_Coin) { if (item.count >= _coinAmount) { Found = true; int _newCount = item.count - _coinAmount; ItemValue _itemValue = ItemClass.GetItem(Ingame_Coin, true); if (_itemValue.type == ItemValue.None.type) { Log.Out(string.Format("[SERVERTOOLS] Unable to find item {0}", Ingame_Coin)); return; } else { _itemValue = new ItemValue(ItemClass.GetItem(Ingame_Coin).type, 1, 1, true); } ItemStack itemStack = new ItemStack(_itemValue, _newCount); SecureLoot.UpdateSlot(slotNumber, itemStack); int _oldBank = PersistentContainer.Instance.Players[_cInfo.playerId, true].Bank; double _percent = _coinAmount * 0.05; int _newCoin = _coinAmount - (int)_percent; PersistentContainer.Instance.Players[_cInfo.playerId, true].Bank = _oldBank + _newCoin; PersistentContainer.Instance.Save(); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} has added {2} to their bank account.", DateTime.Now, _cInfo.playerName, _newCoin)); sw.WriteLine(); sw.Flush(); sw.Close(); } continue; } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} there is not enough {2} in the secure loot to deposit this value.[-]", Config.Chat_Response_Color, _cInfo.playerName, Ingame_Coin), Config.Server_Response_Name, false, "ServerTools", false)); } } } slotNumber++; } } } } } } } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you input an invalid integer. Type /deposit #.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); } if (Found) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} deposited {2} into your bank account from the secure loot. 5% fee was applied.[-]", Config.Chat_Response_Color, _cInfo.playerName, Ingame_Coin), Config.Server_Response_Name, false, "ServerTools", false)); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you don't have enough in the secure loot to deposit that much into your bank.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); } }
public static void CheckBox(ClientInfo _cInfo, string _price) { int _p; if (int.TryParse(_price, out _p)) { if (_p > 0) { if (!AuctionItems.ContainsKey(_cInfo.entityId)) { ChunkClusterList chunklist = GameManager.Instance.World.ChunkClusters; for (int i = 0; i < chunklist.Count; i++) { ChunkCluster chunk = chunklist[i]; chunkArray = chunk.GetChunkArray(); for (int j = 0; j < chunkArray.Count; j++) { Chunk _c = chunkArray[j]; 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) <= 1.5 * 1.5) { int _playerCount = ConnectionManager.Instance.ClientCount(); if (_playerCount > 1) { List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients(); for (int k = 0; k < _cInfoList.Count; k++) { ClientInfo _cInfo2 = _cInfoList[k]; if (_cInfo != _cInfo2) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if ((vec3i.x - _player2.position.x) * (vec3i.x - _player2.position.x) + (vec3i.z - _player2.position.z) * (vec3i.z - _player2.position.z) <= 8 * 8) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you are too close to another player to use auction. Tell them to back off and get their own moldy sandwich.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); return; } } } } List <string> boxUsers = SecureLoot.GetUsers(); if (!boxUsers.Contains(_cInfo.playerId) && !SecureLoot.GetOwner().Equals(_cInfo.playerId)) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} the local secure loot is not owned by you or a friend. You can only auction an item through a secure loot you own.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); return; } ItemStack[] items = SecureLoot.items; int count = 0; int slotNumber = 0; foreach (ItemStack item in items) { if (!item.IsEmpty()) { if (count < 1) { ItemClass _itemClass = ItemClass.list[item.itemValue.type]; string _itemName = _itemClass.GetItemName(); string[] _auctionItem = { item.count.ToString(), _itemName, item.itemValue.Quality.ToString(), _price }; SecureLoot.UpdateSlot(slotNumber, ItemStack.Empty); AuctionItems.Add(_cInfo.entityId, _auctionItem); PersistentContainer.Instance.Players[_cInfo.playerId, true].CancelTime = DateTime.Now; PersistentContainer.Instance.Players[_cInfo.playerId, true].AuctionData = _cInfo.entityId; PersistentContainer.Instance.Players[_cInfo.playerId, true].AuctionItem = _auctionItem; PersistentContainer.Instance.Save(); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} your auction item {2} has been removed from the secure loot and added to the auction.[-]", Config.Chat_Response_Color, _cInfo.playerName, _itemName), Config.Server_Response_Name, false, "ServerTools", false)); 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}. Entry # {7}", DateTime.Now, _cInfo.playerName, item.count, _itemName, item.itemValue.Quality, _price, Wallet.Coin_Name, _cInfo.entityId)); sw.WriteLine(); sw.Flush(); sw.Close(); } count++; } } slotNumber++; } } } } } } if (!AuctionItems.ContainsKey(_cInfo.entityId)) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} auction sell failed. No items were found in a secure chest you own near by.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} place an item in a chest and stand very close to it, then use /auction sell #.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); } } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you have auction item # {2} in the auction already. Wait for it to sell or cancel it with /auction cancel.[-]", Config.Chat_Response_Color, _cInfo.playerName, _cInfo.entityId), Config.Server_Response_Name, false, "ServerTools", false)); } } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} you need to input a price greater than zero. This is not a transfer system.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); } } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1} your sell price must be an integer and greater than zero.[-]", Config.Chat_Response_Color, _cInfo.playerName), Config.Server_Response_Name, false, "ServerTools", false)); } }