protected virtual bool GetCurrentItemValue(object item) { BindingItem(item); if (!EnableEmptyItem) { if (ItemValue == null) { _markEmpty = true; } else if (string.IsNullOrEmpty(ItemValue.ToString())) { _markEmpty = true; } } switch (MatchMode) { case MatchMode.Only: return(ItemValue.Equals(Property)); break; case MatchMode.ExceptSelf: var isSelf = ItemValue.Equals(CurrentItemValue); if (isSelf) { selfCount++; } return(!isSelf && ItemValue.Equals(Property) || selfCount > 1); break; } return(true); //ItemValue.Equals(Property) && ItemValue.Equals(CurrentItemValue) }
public static void ReturnItem(ClientInfo _cInfo) { foreach (ItemStack _item in _stacks) { ItemValue _itemValue = _item.itemValue; if (_itemValue != null && !_itemValue.Equals(ItemValue.None)) { int _quality = 1; if (_itemValue.HasQuality) { _quality = _itemValue.Quality; } string _itemName = ItemClass.list[_itemValue.type].GetItemName(); ItemValue itemValue = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, true); World world = GameManager.Instance.World; if (world.Players.dict[_cInfo.entityId].IsSpawned()) { var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData { entityClass = EntityClass.FromString("item"), id = EntityFactory.nextEntityID++, itemStack = new ItemStack(itemValue, _item.count), pos = world.Players.dict[_cInfo.entityId].position, rot = new Vector3(20f, 0f, 20f), lifetime = 60f, belongsPlayerId = _cInfo.entityId }); world.SpawnEntityInWorld(entityItem); _cInfo.SendPackage(new NetPackageEntityCollect(entityItem.entityId, _cInfo.entityId)); world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed); } } } string _phrase770; if (!Phrases.Dict.TryGetValue(770, out _phrase770)) { _phrase770 = "The items from your dropped bag were sent to your inventory. If your bag is full, check the ground."; } _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase770), Config.Server_Response_Name, false, "ServerTools", false)); LastBagPos.Remove(_cInfo.entityId); Que(); }
private InvItem CreateInvItem(ItemValue _itemValue, int _count, int _playerId) { if (_count > 0 && _itemValue != null && !_itemValue.Equals (ItemValue.None)) { int maxAllowed = ItemClass.list [_itemValue.type].Stacknumber.Value; string name = ItemClass.list [_itemValue.type].GetItemName (); if (_count > maxAllowed) { Log.Out ("Player with ID " + _playerId + " has stack for \"" + name + "\" greater than allowed (" + _count + " > " + maxAllowed + ")"); } InvItem item = null; if (_itemValue.HasQuality) { item = new InvItem (name, _count, _itemValue.Quality); } else { item = new InvItem (name, _count); } return item; } else { return null; } }
public static void CheckInv(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (_cInfo != null) { AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel > Admin_Level) { int _bagClean = 0, _invClean = 0, _totalBagCount = 0, _totalInventoryCount = 0; for (int i = 0; i < _playerDataFile.inventory.Length; i++) { ItemStack _itemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _itemStack = _playerDataFile.inventory[i]; _itemValue = _itemStack.itemValue; int _count = _playerDataFile.inventory[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (Announce_Invalid_Stack && _count > _maxAllowed) { string _phrase3; if (!Phrases.Dict.TryGetValue(3, out _phrase3)) { _phrase3 = " you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; } _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + _phrase3 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); ChatLog.Log(_phrase3, LoadConfig.Server_Response_Name); } if (IsEnabled && (dict.Contains(_name) || _itemValue.ItemClass.CreativeMode == EnumCreativeMode.Dev || _itemValue.ItemClass.CreativeMode == EnumCreativeMode.None)) { if (Ban_Player) { string _phrase4; if (!Phrases.Dict.TryGetValue(4, out _phrase4)) { _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; } _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase4 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Invalid Item {1}\"", _cInfo.entityId, _name), (ClientInfo)null); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, with invalid item: {2}. Banned the player.", _cInfo.playerName, _cInfo.playerId, _name)); sw.WriteLine(); sw.Flush(); sw.Close(); } } else { if (playerflag.ContainsKey(_cInfo.entityId)) { int _value; if (playerflag.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 2) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), (ClientInfo)null); string _phrase5; if (!Phrases.Dict.TryGetValue(5, out _phrase5)) { _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; } _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase5 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, with invalid item: {2}. Kicked the player.", _cInfo.playerName, _cInfo.playerId, _name)); sw.WriteLine(); sw.Flush(); sw.Close(); } playerflag.Remove(_cInfo.entityId); } else { playerflag[_cInfo.entityId] = 2; string _phrase799; if (!Phrases.Dict.TryGetValue(799, out _phrase799)) { _phrase799 = "Cheat Detected: {PlayerName} you are holding a invalid item: {ItemName}. Final warning, drop it!"; } _phrase799 = _phrase799.Replace("{PlayerName}", _cInfo.playerName); _phrase799 = _phrase799.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase799 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } } } else { playerflag.Add(_cInfo.entityId, 1); string _phrase800; if (!Phrases.Dict.TryGetValue(800, out _phrase800)) { _phrase800 = "Cheat Detected: {PlayerName} you are holding a invalid item: {ItemName}. You have 30 seconds to drop it."; } _phrase800 = _phrase800.Replace("{PlayerName}", _cInfo.playerName); _phrase800 = _phrase800.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase800 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } } } else if (IsEnabled) { _totalInventoryCount++; if (_totalInventoryCount == _count) { _totalInventoryCount = 0; _invClean = 1; } } } } for (int i = 0; i < _playerDataFile.bag.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.bag[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.bag[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (Announce_Invalid_Stack && _count > _maxAllowed) { string _phrase3; if (!Phrases.Dict.TryGetValue(3, out _phrase3)) { _phrase3 = " you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; } _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); ChatLog.Log(_phrase3, LoadConfig.Server_Response_Name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + _phrase3 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } if (IsEnabled && (dict.Contains(_name) || _itemValue.ItemClass.CreativeMode == EnumCreativeMode.Dev || _itemValue.ItemClass.CreativeMode == EnumCreativeMode.None)) { if (Ban_Player) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Invalid Item {1}\"", _cInfo.entityId, _name), (ClientInfo)null); string _phrase4; if (!Phrases.Dict.TryGetValue(4, out _phrase4)) { _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; } _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase4 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { if (playerflag.ContainsKey(_cInfo.entityId)) { int _value; if (playerflag.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 2) { string _phrase5; if (!Phrases.Dict.TryGetValue(5, out _phrase5)) { _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; } _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase5 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), (ClientInfo)null); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, with invalid item: {2}. Kicked the player.", _cInfo.playerName, _cInfo.playerId, _name)); sw.WriteLine(); sw.Flush(); sw.Close(); } playerflag.Remove(_cInfo.entityId); } else { playerflag[_cInfo.entityId] = 2; string _phrase799; if (!Phrases.Dict.TryGetValue(799, out _phrase799)) { _phrase799 = "Cheat Detected: {PlayerName} you are holding a invalid item: {ItemName}. Final warning, drop it!"; } _phrase799 = _phrase799.Replace("{PlayerName}", _cInfo.playerName); _phrase799 = _phrase799.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase799 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } } } else { playerflag.Add(_cInfo.entityId, 1); string _phrase800; if (!Phrases.Dict.TryGetValue(800, out _phrase800)) { _phrase800 = "Cheat Detected: {PlayerName} you are holding a invalid item: {ItemName}. You have 30 seconds to drop it."; } _phrase800 = _phrase800.Replace("{PlayerName}", _cInfo.playerName); _phrase800 = _phrase800.Replace("{ItemName}", _name); ChatHook.ChatMessage(_cInfo, "[FF0000]" + _phrase800 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } } } else if (IsEnabled) { _totalBagCount++; if (_totalBagCount == _count) { _totalBagCount = 0; _bagClean = 1; } } } } if (_bagClean == 1 && _invClean == 1) { _bagClean = 0; _invClean = 0; if (dropCheck.Contains(_cInfo.entityId)) { dropCheck.Remove(_cInfo.entityId); } } } } }
public static void CheckInv(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (_cInfo != null && !GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId)) { for (int i = 0; i < _playerDataFile.inventory.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.inventory[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.inventory[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (_count > _maxAllowed && AnounceInvalidStack) { string _phrase3 = "{PlayerName} you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; if (Phrases._Phrases.TryGetValue(3, out _phrase3)) { _phrase3 = _phrase3.Replace("{0}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{1}", _name); _phrase3 = _phrase3.Replace("{2}", _count.ToString()); _phrase3 = _phrase3.Replace("{3}", _maxAllowed.ToString()); _phrase3 = _phrase3.Replace("{PlayerName}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); } _cInfo.SendPackage(new NetPackageGameMessage(string.Format("[FF8000]{0}[-]", _phrase3), "Server")); } if (_invaliditems.ContainsKey(_name)) { if (BanPlayer) { string _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; if (Phrases._Phrases.TryGetValue(4, out _phrase4)) { _phrase4 = _phrase4.Replace("{0}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{1}", _name); _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); } GameManager.Instance.GameMessageServer(_cInfo, string.Format("[FF8000]{0}[-]", _phrase4), "Server"); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 10 years \"Invalid Item {1}\"", _cInfo.entityId, _name), _cInfo); } else { string _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; if (Phrases._Phrases.TryGetValue(5, out _phrase5)) { _phrase5 = _phrase5.Replace("{0}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{1}", _name); _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); } GameManager.Instance.GameMessageServer(_cInfo, string.Format("[FF8000]{0}[-]", _phrase5), "Server"); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), _cInfo); } break; } } } for (int i = 0; i < _playerDataFile.bag.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.bag[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.bag[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (_count > _maxAllowed && AnounceInvalidStack) { string _phrase3 = "{PlayerName} you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; if (Phrases._Phrases.TryGetValue(3, out _phrase3)) { _phrase3 = _phrase3.Replace("{0}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{1}", _name); _phrase3 = _phrase3.Replace("{2}", _count.ToString()); _phrase3 = _phrase3.Replace("{3}", _maxAllowed.ToString()); _phrase3 = _phrase3.Replace("{PlayerName}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); } _cInfo.SendPackage(new NetPackageGameMessage(string.Format("[FF8000]{0}[-]", _phrase3), "Server")); } if (_invaliditems.ContainsKey(_name)) { if (BanPlayer) { string _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; if (Phrases._Phrases.TryGetValue(4, out _phrase4)) { _phrase4 = _phrase4.Replace("{0}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{1}", _name); _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); } GameManager.Instance.GameMessageServer(_cInfo, string.Format("[FF8000]{0}[-]", _phrase4), "Server"); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 10 years \"Invalid Item {1}\"", _cInfo.entityId, _name), _cInfo); } else { string _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; if (Phrases._Phrases.TryGetValue(5, out _phrase5)) { _phrase5 = _phrase5.Replace("{0}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{1}", _name); _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); } GameManager.Instance.GameMessageServer(_cInfo, string.Format("[FF8000]{0}[-]", _phrase5), "Server"); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), _cInfo); } break; } } } } }
public static void CheckInv(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { try { if (_cInfo != null) { AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel > Admin_Level) { for (int i = 0; i < _playerDataFile.inventory.Length; i++) { ItemStack _itemStack = _playerDataFile.inventory[i]; ItemValue _itemValue = _itemStack.itemValue; int _count = _playerDataFile.inventory[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None)) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].Name; if (_count > _maxAllowed) { MaxStack(_cInfo, _name, _count, _maxAllowed); } if (IsEnabled && dict.Contains(_name)) { if (Ban_Player) { Ban(_cInfo, _name); } else { if (Flags.ContainsKey(_cInfo.entityId)) { int _value; if (Flags.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 2) { Flag3(_cInfo, _name); } else { Flag2(_cInfo, _name); } } } else { Flag1(_cInfo, _name); } } return; } } } for (int i = 0; i < _playerDataFile.bag.Length; i++) { ItemStack _itemStack = _playerDataFile.bag[i]; ItemValue _itemValue = _itemStack.itemValue; int _count = _playerDataFile.bag[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None)) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].Name; if (_count > _maxAllowed) { MaxStack(_cInfo, _name, _count, _maxAllowed); } if (IsEnabled && dict.Contains(_name)) { if (Ban_Player) { Ban(_cInfo, _name); } else { if (Flags.ContainsKey(_cInfo.entityId)) { int _value; if (Flags.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 2) { Flag3(_cInfo, _name); } else { Flag2(_cInfo, _name); } } } else { Flag1(_cInfo, _name); } } return; } } } for (int i = 0; i < _playerDataFile.equipment.GetSlotCount(); i++) { ItemValue _item = _playerDataFile.equipment.GetSlotItem(i); if (_item != null && !_item.Equals(ItemValue.None)) { int _maxAllowed = ItemClass.list[_item.type].Stacknumber.Value; string _name = ItemClass.list[_item.type].Name; if (IsEnabled && dict.Contains(_name)) { if (Ban_Player) { Ban(_cInfo, _name); } else { if (Flags.ContainsKey(_cInfo.entityId)) { int _value; if (Flags.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 2) { Flag3(_cInfo, _name); } else { Flag2(_cInfo, _name); } } } else { Flag1(_cInfo, _name); } } return; } } } if (Flags.ContainsKey(_cInfo.entityId)) { Flags.Remove(_cInfo.entityId); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in InventoryCheck.CheckInv: {0}.", e.Message)); } }
public static void CheckInv(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { try { if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.PlatformId) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.CrossplatformId) > Admin_Level) { for (int i = 0; i < _playerDataFile.inventory.Length; i++) { ItemStack itemStack = _playerDataFile.inventory[i]; ItemValue itemValue = itemStack.itemValue; int count = _playerDataFile.inventory[i].count; if (count > 0 && itemValue != null && !itemValue.Equals(ItemValue.None)) { string name = ItemClass.list[itemValue.type].Name; if (Invalid_Stack) { int maxAllowed = ItemClass.list[itemValue.type].Stacknumber.Value; if (count > maxAllowed) { MaxStack(_cInfo, name, count, maxAllowed); } } if (Dict.Contains(name)) { if (Ban_Player) { Ban(_cInfo, name); } else { if (Flags.ContainsKey(_cInfo.entityId)) { if (Flags.TryGetValue(_cInfo.entityId, out int value)) { if (value == 2) { Flag3(_cInfo, name); } else { Flag2(_cInfo, name); } } } else { Flag1(_cInfo, name); } } return; } } } for (int i = 0; i < _playerDataFile.bag.Length; i++) { ItemStack itemStack = _playerDataFile.bag[i]; ItemValue itemValue = itemStack.itemValue; int count = _playerDataFile.bag[i].count; if (count > 0 && itemValue != null && !itemValue.Equals(ItemValue.None)) { string name = ItemClass.list[itemValue.type].Name; if (Invalid_Stack) { int maxAllowed = ItemClass.list[itemValue.type].Stacknumber.Value; if (count > maxAllowed) { MaxStack(_cInfo, name, count, maxAllowed); } } if (Dict.Contains(name)) { if (Ban_Player) { Ban(_cInfo, name); } else { if (Flags.ContainsKey(_cInfo.entityId)) { if (Flags.TryGetValue(_cInfo.entityId, out int value)) { if (value == 2) { Flag3(_cInfo, name); } else { Flag2(_cInfo, name); } } } else { Flag1(_cInfo, name); } } return; } } } for (int i = 0; i < _playerDataFile.equipment.GetSlotCount(); i++) { ItemValue itemValue = _playerDataFile.equipment.GetSlotItem(i); if (itemValue != null && !itemValue.Equals(ItemValue.None)) { string name = ItemClass.list[itemValue.type].Name; if (Dict.Contains(name)) { if (Ban_Player) { Ban(_cInfo, name); } else { if (Flags.ContainsKey(_cInfo.entityId)) { if (Flags.TryGetValue(_cInfo.entityId, out int value)) { if (value == 2) { Flag3(_cInfo, name); } else { Flag2(_cInfo, name); } } } else { Flag1(_cInfo, name); } } return; } } } if (Flags.ContainsKey(_cInfo.entityId)) { Flags.Remove(_cInfo.entityId); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in InvalidItems.CheckInv: {0}", e.Message)); } }
public static void CheckInv(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (_cInfo != null && !GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId)) { for (int i = 0; i < _playerDataFile.inventory.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.inventory[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.inventory[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (AnounceInvalidStack && _count > _maxAllowed) { string _phrase3; if (!Phrases.Dict.TryGetValue(3, out _phrase3)) { _phrase3 = "{PlayerName} you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; } _phrase3 = _phrase3.Replace("{PlayerName}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase3), "Server", false, "", false)); ChatLog.Log(_phrase3, "Server"); } if (IsEnabled && dict.ContainsKey(_name)) { if (BanPlayer) { string _phrase4; if (!Phrases.Dict.TryGetValue(4, out _phrase4)) { _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; } _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase4), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 10 years \"Invalid Item {1}\"", _cInfo.entityId, _name), _cInfo); } else { string _phrase5; if (!Phrases.Dict.TryGetValue(5, out _phrase5)) { _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; } _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase5), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), _cInfo); } break; } } } for (int i = 0; i < _playerDataFile.bag.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.bag[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.bag[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (AnounceInvalidStack && _count > _maxAllowed) { string _phrase3; if (!Phrases.Dict.TryGetValue(3, out _phrase3)) { _phrase3 = "{PlayerName} you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; } _phrase3 = _phrase3.Replace("{PlayerName}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase3), "Server", false, "", false)); ChatLog.Log(_phrase3, "Server"); } if (IsEnabled && dict.ContainsKey(_name)) { if (BanPlayer) { string _phrase4; if (!Phrases.Dict.TryGetValue(4, out _phrase4)) { _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; } _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase4), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 10 years \"Invalid Item {1}\"", _cInfo.entityId, _name), _cInfo); } else { string _phrase5; if (!Phrases.Dict.TryGetValue(5, out _phrase5)) { _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; } _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase5), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), _cInfo); } break; } } } } }