public static void Clan(ClientInfo _cInfo, string _message)
        {
            Player            p          = PersistentContainer.Instance.Players[_cInfo.playerId, false];
            List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients();

            for (int i = 0; i < _cInfoList.Count; i++)
            {
                ClientInfo _cInfo1 = _cInfoList[i];
                Player     p1      = PersistentContainer.Instance.Players[_cInfo1.playerId, false];
                if (p.ClanName == p1.ClanName)
                {
                    _cInfo1.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Private_Chat_Color, _message), _cInfo.playerName, false, "", false));
                    if (ChatLog.IsEnabled)
                    {
                        ChatLog.Log(_message, _cInfo.playerName);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void Clan(ClientInfo _cInfo, string _message)
        {
            string    _sql      = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result   = SQL.TQuery(_sql);
            string    _clanname = _result.Rows[0].ItemArray.GetValue(0).ToString();

            _result.Dispose();
            _sql = string.Format("SELECT steamid FROM Players WHERE clanname = '{0}'", _clanname);
            DataTable _result1 = SQL.TQuery(_sql);

            foreach (DataRow row in _result1.Rows)
            {
                ClientInfo _cInfo1 = ConsoleHelper.ParseParamIdOrName(row[0].ToString());
                if (_cInfo1 != null)
                {
                    ChatHook.ChatMessage(_cInfo1, Private_Chat_Color + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                    if (ChatLog.IsEnabled)
                    {
                        ChatLog.Log(_message, _cInfo.playerName);
                    }
                }
            }
            _result1.Dispose();
        }
Esempio n. 3
0
 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);
                 }
             }
         }
     }
 }