Пример #1
0
        public static void ListResult(ClientInfo _cInfo, int _waypointLimit)
        {
            string    _sql     = string.Format("SELECT steamid, wayPointName, position FROM Waypoints WHERE steamid = '{0}' LIMIT {1}", _cInfo.playerId, _waypointLimit);
            DataTable _result1 = SQL.TypeQuery(_sql);

            if (_result1.Rows.Count > 0)
            {
                foreach (DataRow row in _result1.Rows)
                {
                    string   _name = row[1].ToString();
                    int      x, y, z;
                    string[] _cords = row[2].ToString().Split(',');
                    int.TryParse(_cords[0], out x);
                    int.TryParse(_cords[1], out y);
                    int.TryParse(_cords[2], out z);
                    string _message = "Waypoint {Name} @ {X} {Y} {Z}";
                    _message = _message.Replace("{Name}", _name);
                    _message = _message.Replace("{X}", x.ToString());
                    _message = _message.Replace("{Y}", y.ToString());
                    _message = _message.Replace("{Z}", z.ToString());
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
                string _message2 = "Waypoint Limit = {Limit}";
                _message2 = _message2.Replace("{Limit}", _waypointLimit.ToString());
                ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message2 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
        }
Пример #2
0
        public static void DelPoint(ClientInfo _cInfo, string _waypoint)
        {
            string    _sql    = string.Format("SELECT position FROM Waypoints WHERE steamid = '{0}' AND wayPointName = '{1}'", _cInfo.playerId, _waypoint);
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                _sql = string.Format("DELETE FROM Waypoints WHERE steamid = '{0}' AND wayPointName = '{1}'", _cInfo.playerId, _waypoint);
                SQL.FastQuery(_sql, "Waypoints");
                string _phrase583;
                if (!Phrases.Dict.TryGetValue(583, out _phrase583))
                {
                    _phrase583 = " waypoint {Name} has been deleted.";
                }
                _phrase583 = _phrase583.Replace("{Name}", _waypoint);
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase583 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                string _phrase578;
                if (!Phrases.Dict.TryGetValue(578, out _phrase578))
                {
                    _phrase578 = " you have not saved this waypoint.";
                }
                _phrase578 = _phrase578.Replace("{PlayerName}", _cInfo.playerName);
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase578 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            _result.Dispose();
        }
Пример #3
0
 public static void EventSpawn(ClientInfo _cInfo)
 {
     if (Open)
     {
         int _team;
         if (PlayersTeam.TryGetValue(_cInfo.playerId, out _team))
         {
             string    _sql     = string.Format("SELECT eventid FROM Events WHERE eventActive = 'true'");
             DataTable _result1 = SQL.TypeQuery(_sql);
             int       _eventid;
             int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
             _result1.Dispose();
             _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _team);
             DataTable _result2 = SQL.TypeQuery(_sql);
             string    _pos     = _result2.Rows[0].ItemArray.GetValue(0).ToString();
             _result2.Dispose();
             int      _x, _y, _z;
             string[] _cords = _pos.Split(',');
             int.TryParse(_cords[0], out _x);
             int.TryParse(_cords[1], out _y);
             int.TryParse(_cords[2], out _z);
             _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false));
             _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
             SQL.FastQuery(_sql, "Event");
             ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been sent to your event spawn point.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
     }
     else
     {
         string _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
         SQL.FastQuery(_sql, "Event");
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the event ended while you were offline or not spawned.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Пример #4
0
        public static void List(ClientInfo _cInfo)
        {
            string    _sql    = string.Format("SELECT steamid FROM Waypoints WHERE steamid = '{0}' LIMIT 1", _cInfo.playerId);
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                if (ReservedSlots.IsEnabled && ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                {
                    DateTime _dt;
                    ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                    if (DateTime.Now < _dt)
                    {
                        ListResult(_cInfo, Donator_Max_Waypoints);
                        return;
                    }
                }
                ListResult(_cInfo, Max_Waypoints);
            }
            else
            {
                string _phrase585;
                if (!Phrases.Dict.TryGetValue(585, out _phrase585))
                {
                    _phrase585 = " you have no waypoints saved to list.";
                }
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase585 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            _result.Dispose();
        }
Пример #5
0
        public static void Alert(ClientInfo _cInfo)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (_player != null)
            {
                string    _sql    = string.Format("SELECT deaths, extraLives FROM Hardcore WHERE steamid = '{0}'", _cInfo.playerId);
                DataTable _result = SQL.TypeQuery(_sql);
                if (_result.Rows.Count > 0)
                {
                    int _deaths, _extraLives;
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _deaths);
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _extraLives);
                    if (_deaths - _extraLives < Max_Deaths)
                    {
                        int    _lives = Max_Deaths - _deaths + _extraLives;
                        string _phrase949;
                        if (!Phrases.Dict.TryGetValue(949, out _phrase949))
                        {
                            _phrase949 = "Hardcore mode is enabled! You have {Lives} lives remaining...";
                        }
                        _phrase949 = _phrase949.Replace("{Lives}", _lives.ToString());
                        ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase949 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
            }
        }
Пример #6
0
 public static void NewPlayerExec3(ClientInfo _cInfo, EntityPlayer _player)
 {
     try
     {
         if (NewPlayer.IsEnabled)
         {
             NewPlayer.Exec(_cInfo);
         }
         if (Motd.IsEnabled)
         {
             Motd.Send(_cInfo);
         }
         if (Bloodmoon.IsEnabled)
         {
             Bloodmoon.Exec(_cInfo);
         }
         if (BattleLogger.IsEnabled)
         {
             BattleLogger.AlertPlayer(_cInfo);
         }
         if (PollConsole.IsEnabled)
         {
             string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
             if (!string.IsNullOrEmpty(_sql))
             {
                 DataTable _result = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId))
                 {
                     PollConsole.Message(_cInfo);
                 }
                 _result.Dispose();
             }
         }
         if (Hardcore.IsEnabled && !Hardcore.Optional)
         {
             string    _sql    = string.Format("SELECT * FROM Hardcore WHERE steamid = '{0}'", _cInfo.playerId);
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count == 0)
             {
                 int    _deaths     = XUiM_Player.GetDeaths(_player);
                 string _playerName = SQL.EscapeString(_cInfo.playerName);
                 SQL.FastQuery(string.Format("INSERT INTO Hardcore (steamid, playerName, deaths) VALUES ('{0}', '{1}', {2})", _cInfo.playerId, _playerName, _deaths), null);
             }
             else
             {
                 SQL.FastQuery(_sql = string.Format("UPDATE Hardcore SET deaths = {0} WHERE steamid = '{1}'", 0, _cInfo.playerId), "Hardcore");
             }
             _result.Dispose();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.NewPlayerExec3: {0}.", e.Message));
     }
     PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer = true;
     PersistentContainer.Instance.Save();
 }
Пример #7
0
 public static void TeleDelay(ClientInfo _cInfo, string _waypoint)
 {
     if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId))
     {
         if (Delay_Between_Uses < 1)
         {
             Checks(_cInfo, _waypoint);
         }
         else
         {
             string    _sql    = string.Format("SELECT lastWaypoint FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
             DataTable _result = SQL.TypeQuery(_sql);
             DateTime  _lastWaypoint;
             if (_result.Rows.Count == 0)
             {
                 SQL.FastQuery(string.Format("INSERT INTO Players (steamid, playername) VALUES ('{0}', '{1}')", _cInfo.playerId, _cInfo.playerName), null);
                 DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastWaypoint);
             }
             else
             {
                 DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastWaypoint);
             }
             _result.Dispose();
             if (_lastWaypoint.ToString() == "10/29/2000 7:30:00 AM")
             {
                 Checks(_cInfo, _waypoint);
             }
             else
             {
                 TimeSpan varTime           = DateTime.Now - _lastWaypoint;
                 double   fractionalMinutes = varTime.TotalMinutes;
                 int      _timepassed       = (int)fractionalMinutes;
                 if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay)
                 {
                     if (ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
                     {
                         DateTime _dt;
                         ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                         if (DateTime.Now < _dt)
                         {
                             int _delay = Delay_Between_Uses / 2;
                             Time(_cInfo, _waypoint, _timepassed, _delay);
                             return;
                         }
                     }
                 }
                 Time(_cInfo, _waypoint, _timepassed, Delay_Between_Uses);
             }
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you can not use waypoint commands while signed up for or in an event.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Пример #8
0
        public static void Message(ClientInfo _cInfo)
        {
            string    _sql    = "SELECT pollTime, pollHours, pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                DateTime _pollTime;
                DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollTime);
                int _pollHours;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollHours);
                string _pollMessage = _result.Rows[0].ItemArray.GetValue(2).ToString();
                int    _pollYes;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _pollYes);
                int _pollNo;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _pollNo);
                TimeSpan varTime         = DateTime.Now - _pollTime;
                double   fractionalHours = varTime.TotalHours;
                int      _timepassed     = (int)fractionalHours;
                if (_timepassed <= _pollHours)
                {
                    string _phrase926;
                    if (!Phrases.Dict.TryGetValue(926, out _phrase926))
                    {
                        _phrase926 = "Poll: {Message}";
                    }
                    _phrase926 = _phrase926.Replace("{Message}", _pollMessage);
                    string _phrase927;
                    if (!Phrases.Dict.TryGetValue(927, out _phrase927))
                    {
                        _phrase927 = "Type {CommandPrivate}{Command91} or {CommandPrivate}{Command92} to vote.";
                    }
                    _phrase927 = _phrase927.Replace("{CommandPrivate}", ChatHook.Command_Private);
                    _phrase927 = _phrase927.Replace("{Command91}", Command91);
                    _phrase927 = _phrase927.Replace("{Command92}", Command92);
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase926 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase927 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
                else
                {
                    string _phrase925;
                    if (!Phrases.Dict.TryGetValue(925, out _phrase925))
                    {
                        _phrase925 = "Poll results: Yes {YesVote} / No {NoVote}";
                    }
                    _phrase925 = _phrase925.Replace("{YesVote}", _pollYes.ToString());
                    _phrase925 = _phrase925.Replace("{NoVote}", _pollNo.ToString());
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase925 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null);
                }
            }
            _result.Dispose();
        }
Пример #9
0
        public static void VoteYes(ClientInfo _cInfo)
        {
            string    _sql    = "SELECT pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                if (PolledYes.Contains(_cInfo.playerId) || PolledNo.Contains(_cInfo.playerId))
                {
                    string _phrase812;
                    if (!Phrases.Dict.TryGetValue(812, out _phrase812))
                    {
                        _phrase812 = " you have already voted on the poll.";
                    }
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase812 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
                else
                {
                    PolledYes.Add(_cInfo.playerId);
                    int _pollYes;
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollYes);
                    int _pollNo;
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollNo);
                    _pollYes = _pollYes + 1;
                    _sql     = string.Format("UPDATE Polls SET pollYes = {0} WHERE pollOpen = 'true'", _pollYes);
                    SQL.FastQuery(_sql, "PollConsole");
                    string _phrase928;
                    if (!Phrases.Dict.TryGetValue(928, out _phrase928))
                    {
                        _phrase928 = " you have cast a vote for yes. Currently, the pole is yes {Yes} / no {No}.";
                    }
                    _phrase928 = _phrase928.Replace("{PlayerName}", _cInfo.playerName);
                    _phrase928 = _phrase928.Replace("{Yes}", _pollYes.ToString());
                    _phrase928 = _phrase928.Replace("{No}", _pollNo.ToString());
                    ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase928 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    using (StreamWriter sw = new StreamWriter(_filepath, true))
                    {
                        sw.WriteLine(string.Format("{0}  Player name {1} has voted yes in the poll. Yes {2} / no {3}", DateTime.Now, _cInfo.playerName, _pollYes, _pollNo));
                        sw.WriteLine();
                        sw.Flush();
                        sw.Close();
                    }
                }
            }
            _result.Dispose();
        }
Пример #10
0
 public static void BuyLife(ClientInfo _cInfo)
 {
     try
     {
         EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
         if (_player != null)
         {
             int       _deaths = XUiM_Player.GetDeaths(_player);
             string    _sql    = string.Format("SELECT extraLives FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 int _extraLives;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _extraLives);
                 _result.Dispose();
                 if (_extraLives < Max_Extra_Lives)
                 {
                     if (Life_Price < 0)
                     {
                         Life_Price = 0;
                     }
                     int _cost = Life_Price * _extraLives;
                     if (Wallet.GetCurrentCoins(_cInfo.playerId) >= _cost)
                     {
                         Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _cost);
                         SQL.FastQuery(_sql = string.Format("UPDATE Players SET extraLives = {0} WHERE steamid = '{1}'", _extraLives + 1, _cInfo.playerId), "Hardcore");
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you have bought one extra life." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                     else
                     {
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you need a total of " + _cost.ToString() + " " + Wallet.Coin_Name + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
                 else
                 {
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you are at the maximum extra lives." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Hardcore.BuyLife: {0}.", e.Message));
     }
 }
Пример #11
0
        public static void EndEvent()
        {
            ClientInfo _cInfo1 = ConnectionManager.Instance.Clients.GetForPlayerName(Admin);

            if (_cInfo1 != null)
            {
                ChatHook.ChatMessage(_cInfo1, LoadConfig.Chat_Response_Color + _cInfo1.playerName + ", the current event has ended and event players have been sent back to their return points.[-]", _cInfo1.entityId, _cInfo1.playerName, EChatType.Global, null);
            }
            foreach (var _player in PlayersTeam)
            {
                ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                if (_cInfo2 != null)
                {
                    EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                    if (_player2.IsSpawned())
                    {
                        string    _sql    = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                        DataTable _result = SQL.TypeQuery(_sql);
                        string    _pos    = _result.Rows[0].ItemArray.GetValue(0).ToString();
                        _result.Dispose();
                        _sql = string.Format("UPDATE Players SET eventReturn = 'Unknown' WHERE steamid = '{0}'", _player.Key);
                        SQL.FastQuery(_sql, "Event");
                        int      _x, _y, _z;
                        string[] _cords = _pos.Split(',');
                        int.TryParse(_cords[0], out _x);
                        int.TryParse(_cords[1], out _y);
                        int.TryParse(_cords[2], out _z);
                        _cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false));
                        PlayersTeam.Remove(_player.Key);
                        ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _cInfo2.playerName + ", the current event has ended and event players have been sent back to their return points.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    }
                }
                else
                {
                    string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _player.Key);
                    SQL.FastQuery(_sql, "Event");
                    PlayersTeam.Remove(_player.Key);
                }
            }
            string _sql2 = string.Format("UPDATE Events SET eventActive = 'false' WHERE eventAdmin = '{0}'", Admin);

            SQL.FastQuery(_sql2, "Event");
            Open  = false;
            Admin = null;
        }
Пример #12
0
        private static void ReservedCheck(ClientInfo _cInfo, string _waypoint)
        {
            string    _sql    = string.Format("SELECT steamid FROM Waypoints WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TypeQuery(_sql);

            if (ReservedSlots.IsEnabled && ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
            {
                DateTime _dt;
                ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                if (DateTime.Now < _dt)
                {
                    SavePoint(_cInfo, _waypoint, _result.Rows.Count, Donator_Max_Waypoints);
                    return;
                }
            }
            SavePoint(_cInfo, _waypoint, _result.Rows.Count, Max_Waypoints);
            _result.Dispose();
        }
Пример #13
0
        public static void EventReturn(ClientInfo _cInfo)
        {
            string    _sql    = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
            DataTable _result = SQL.TypeQuery(_sql);
            string    _pos    = _result.Rows[0].ItemArray.GetValue(0).ToString();

            _result.Dispose();
            int _x, _y, _z;

            string[] _cords = _pos.Split(',');
            int.TryParse(_cords[0], out _x);
            int.TryParse(_cords[1], out _y);
            int.TryParse(_cords[2], out _z);
            _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false));
            _sql = string.Format("UPDATE Players SET eventReturn = 'Unknown', return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
            SQL.FastQuery(_sql, "Event");
            ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the event ended while you were offline or not spawned. You have been sent to your return point.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
        }
Пример #14
0
 private static void CheckVersion()
 {
     try
     {
         DataTable _result = SQL.TypeQuery("SELECT sql_version FROM Config");
         int       _version;
         int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _version);
         _result.Dispose();
         if (_version != SQL.Sql_version)
         {
             Exec(_version);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in UpdateSQL.CheckVersion: {0}.", e));
     }
 }
Пример #15
0
        public static void Check()
        {
            string    _sql    = "SELECT pollTime, pollHours, pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                DateTime _pollTime;
                DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollTime);
                int _pollHours;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollHours);
                string _pollMessage = _result.Rows[0].ItemArray.GetValue(2).ToString();
                int    _pollYes;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _pollYes);
                int _pollNo;
                int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _pollNo);
                TimeSpan varTime         = DateTime.Now - _pollTime;
                double   fractionalHours = varTime.TotalHours;
                int      _timepassed     = (int)fractionalHours;
                if (_timepassed >= _pollHours)
                {
                    string _phrase925;
                    if (!Phrases.Dict.TryGetValue(925, out _phrase925))
                    {
                        _phrase925 = "Poll results: Yes {YesVote} / No {NoVote}";
                    }
                    _phrase925 = _phrase925.Replace("{YesVote}", _pollYes.ToString());
                    _phrase925 = _phrase925.Replace("{NoVote}", _pollNo.ToString());
                    _sql       = "UPDATE Polls SET pollOpen = 'false' WHERE pollOpen = 'true'";
                    SQL.FastQuery(_sql, "PollConsole");
                    using (StreamWriter sw = new StreamWriter(_filepath, true))
                    {
                        sw.WriteLine(string.Format("{0}  Poll {1} ... has completed. The final results were yes {2} / no {3}", DateTime.Now, _pollMessage, _pollYes, _pollNo));
                        sw.WriteLine();
                        sw.Flush();
                        sw.Close();
                    }
                }
            }
            _result.Dispose();
        }
Пример #16
0
 public static void Score(ClientInfo _cInfo, bool _announce)
 {
     try
     {
         string    _sql    = string.Format("SELECT sessionTime, kills, zKills, score, oldDeaths, playerName From Hardcore WHERE steamid = '{0}'", _cInfo.playerId);
         DataTable _result = SQL.TypeQuery(_sql);
         if (_result.Rows.Count > 0)
         {
             string _phrase948;
             if (!Phrases.Dict.TryGetValue(948, out _phrase948))
             {
                 _phrase948 = "{PlayerName} your last hardcore stats: Name {LastName} Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Deaths {Deaths}, Score {Score}, Playtime {Playtime} Minutes";
             }
             _phrase948 = _phrase948.Replace("{PlayerName}", _cInfo.playerName);
             _phrase948 = _phrase948.Replace("{LastName}", _result.Rows[0].ItemArray.GetValue(5).ToString());
             _phrase948 = _phrase948.Replace("{ZombieKills}", _result.Rows[0].ItemArray.GetValue(2).ToString());
             _phrase948 = _phrase948.Replace("{PlayerKills}", _result.Rows[0].ItemArray.GetValue(1).ToString());
             _phrase948 = _phrase948.Replace("{Deaths}", _result.Rows[0].ItemArray.GetValue(4).ToString());
             _phrase948 = _phrase948.Replace("{Score}", _result.Rows[0].ItemArray.GetValue(3).ToString());
             _phrase948 = _phrase948.Replace("{Playtime}", _result.Rows[0].ItemArray.GetValue(0).ToString());
             if (_announce)
             {
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase948 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
             }
             else
             {
                 ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase948 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         else
         {
             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have no hardcore records." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         }
         _result.Dispose();
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Hardcore.Score: {0}.", e.Message));
     }
 }
Пример #17
0
        private static void FExec(ClientInfo _cInfo, string _waypoint, Vector3 _playerPos)
        {
            string    _sql      = string.Format("SELECT position FROM Waypoints WHERE steamid = '{0}' AND wayPointName = '{1}'", _cInfo.playerId, _waypoint);
            DataTable _result   = SQL.TypeQuery(_sql);
            string    _position = _result.Rows[0].ItemArray.GetValue(0).ToString();

            if (_result.Rows.Count > 0)
            {
                FriendInvite(_cInfo, _playerPos, _position);
                int      x, y, z;
                string[] _cordsplit = _position.Split(',');
                int.TryParse(_cordsplit[0], out x);
                int.TryParse(_cordsplit[1], out y);
                int.TryParse(_cordsplit[2], out z);
                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false));
                if (Wallet.IsEnabled && Command_Cost > 0)
                {
                    Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost);
                }
                _sql = string.Format("UPDATE Players SET lastWaypoint = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId);
                SQL.FastQuery(_sql, "Waypoints");
                string _phrase577;
                if (!Phrases.Dict.TryGetValue(577, out _phrase577))
                {
                    _phrase577 = " traveling to waypoint {Waypoint}.";
                }
                _phrase577 = _phrase577.Replace("{Waypoint}", _waypoint);
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase577 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            else
            {
                string _phrase578;
                if (!Phrases.Dict.TryGetValue(578, out _phrase578))
                {
                    _phrase578 = " you have not saved this waypoint.";
                }
                ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase578 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
            }
            _result.Dispose();
        }
Пример #18
0
        public static void Check(ClientInfo _cInfo)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

            if (_player != null)
            {
                string    _sql    = string.Format("SELECT deaths, extraLives FROM Hardcore WHERE steamid = '{0}'", _cInfo.playerId);
                DataTable _result = SQL.TypeQuery(_sql);
                if (_result.Rows.Count > 0)
                {
                    int _deaths, _extraLives;
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _deaths);
                    int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _extraLives);
                    if (_deaths + 1 - _extraLives < Max_Deaths)
                    {
                        _sql = string.Format("UPDATE Hardcore SET deaths = {0} WHERE steamid = '{1}'", _deaths + 1, _cInfo.playerId);
                        SQL.FastQuery(_sql, "Hardcore");
                        int    _lives = Max_Deaths - _deaths - 1 + _extraLives;
                        string _phrase950;
                        if (!Phrases.Dict.TryGetValue(950, out _phrase950))
                        {
                            _phrase950 = "Hardcore: Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Score {Score}, Lives remaining {Lives}...";
                        }
                        _phrase950 = _phrase950.Replace("{ZombieKills}", _player.KilledZombies.ToString());
                        _phrase950 = _phrase950.Replace("{PlayerKills}", _player.KilledPlayers.ToString());
                        _phrase950 = _phrase950.Replace("{Score}", _player.Score.ToString());
                        _phrase950 = _phrase950.Replace("{Lives}", _lives.ToString());
                        ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase950 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                    }
                    else
                    {
                        EndGame(_cInfo, _player, _deaths, _extraLives);
                    }
                }
                _result.Dispose();
            }
        }
Пример #19
0
        public static void Died(ClientInfo _cInfo)
        {
            EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
            int          _team;

            if (PlayersTeam.TryGetValue(_cInfo.playerId, out _team))
            {
                string    _sql     = string.Format("SELECT eventid FROM Events WHERE eventActive = 'true'");
                DataTable _result1 = SQL.TypeQuery(_sql);
                int       _eventid;
                int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                _result1.Dispose();
                _sql = string.Format("SELECT eventRespawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _team);
                DataTable _result2    = SQL.TypeQuery(_sql);
                string    _respawnPos = _result2.Rows[1].ItemArray.GetValue(0).ToString();
                _result2.Dispose();
                int      _x, _y, _z;
                string[] _cords = _respawnPos.Split(',');
                int.TryParse(_cords[0], out _x);
                int.TryParse(_cords[1], out _y);
                int.TryParse(_cords[2], out _z);
                _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false));
            }
        }
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         string _steamId  = _senderInfo.RemoteClientInfo.playerId;
         int    _entityId = _senderInfo.RemoteClientInfo.entityId;
         if (_params[0].ToLower() == ("new"))
         {
             if (_params.Count < 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2 or more, found {0}.", _params.Count));
                 return;
             }
             string    _sql    = string.Format("SELECT eventName FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _params[1]);
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count == 0)
             {
                 _result.Dispose();
                 string _name = SQL.EscapeString(_params[1]);
                 _sql = string.Format("INSERT INTO Events (eventAdmin, eventName) VALUES ('{0}', '{1}')", _steamId, _name);
                 SQL.FastQuery(_sql, "EventCommandsConsole");
                 if (Event.SetupStage.ContainsKey(_steamId))
                 {
                     Event.SetupName[_steamId]  = _params[1];
                     Event.SetupStage[_steamId] = 1;
                 }
                 else
                 {
                     Event.SetupName.Add(_steamId, _params[1]);
                     Event.SetupStage.Add(_steamId, 1);
                 }
                 if (Event.Open)
                 {
                     SdtdConsole.Instance.Output(string.Format("There is an event being run by {0}.", Event.Admin));
                 }
                 SdtdConsole.Instance.Output("You have started to open a new event setup.");
                 SdtdConsole.Instance.Output(string.Format("The event name has been set to {0}.", _params[1]));
                 SdtdConsole.Instance.Output("What would you like the invitation for players to say? Type event \"invitation\".");
                 return;
             }
             else
             {
                 _result.Dispose();
                 SdtdConsole.Instance.Output(string.Format("The event name {0} already exists. Use a new name or delete the old event.", _params[1]));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("save"))
         {
             if (Event.SetupStage.ContainsKey(_steamId))
             {
                 int _stage;
                 Event.SetupStage.TryGetValue(_steamId, out _stage);
                 string _eventName;
                 Event.SetupName.TryGetValue(_steamId, out _eventName);
                 if (_stage == 3)
                 {
                     EntityPlayer _player    = GameManager.Instance.World.Players.dict[_entityId];
                     Vector3      _position  = _player.GetPosition();
                     int          x          = (int)_position.x;
                     int          y          = (int)_position.y;
                     int          z          = (int)_position.z;
                     string       _sposition = x + "," + y + "," + z;
                     string       _sql       = string.Format("SELECT eventid, eventTeams FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName);
                     DataTable    _result1   = SQL.TypeQuery(_sql);
                     int          _eventid;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                     int _eventTeams;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _eventTeams);
                     _result1.Dispose();
                     _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0}", _eventid);
                     DataTable _result2 = SQL.TypeQuery(_sql);
                     int       _count   = _result2.Rows.Count + 1;
                     _result2.Dispose();
                     string _pos = SQL.EscapeString(_sposition);
                     if (_count == _eventTeams)
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventSpawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         Event.SetupStage[_steamId] = 4;
                         SdtdConsole.Instance.Output(string.Format("The spawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output("Stand where you would like the respawn for team 1 if they die during the event, then type event save.");
                         return;
                     }
                     else
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventSpawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         SdtdConsole.Instance.Output(string.Format("The spawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Stand where you would like the spawn for team {0} when the event starts and type event save.", _count + 1));
                         return;
                     }
                 }
                 else if (_stage == 4)
                 {
                     EntityPlayer _player    = GameManager.Instance.World.Players.dict[_entityId];
                     Vector3      _position  = _player.GetPosition();
                     int          x          = (int)_position.x;
                     int          y          = (int)_position.y;
                     int          z          = (int)_position.z;
                     string       _sposition = x + "," + y + "," + z;
                     string       _sql       = string.Format("SELECT eventid, eventTeams FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName);
                     DataTable    _result1   = SQL.TypeQuery(_sql);
                     int          _eventid;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                     int _eventTeams;
                     int.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _eventTeams);
                     _result1.Dispose();
                     _sql = string.Format("SELECT eventRespawn FROM EventSpawns WHERE eventid = {0} AND eventRespawn != null", _eventid);
                     DataTable _result2 = SQL.TypeQuery(_sql);
                     int       _count   = _result2.Rows.Count + 1;
                     _result2.Dispose();
                     string _pos = SQL.EscapeString(_sposition);
                     if (_count == _eventTeams)
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventRespawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         Event.SetupStage[_steamId] = 5;
                         SdtdConsole.Instance.Output(string.Format("The respawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output("Setup is complete. Type event start to send out the invitation to players.");
                         return;
                     }
                     else
                     {
                         _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventRespawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos);
                         SQL.FastQuery(_sql, "EventCommandsConsole");
                         SdtdConsole.Instance.Output(string.Format("The respawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z));
                         SdtdConsole.Instance.Output(string.Format("Stand where you would like the respawn for team {0} when the event starts and type event save.", _count + 1));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("This command is invalid at this stage of setup.");
                     return;
                 }
             }
         }
         else if (_params[0].ToLower() == ("check"))
         {
             if (Event.Open)
             {
                 if (Event.Admin == _steamId)
                 {
                     string    _sql         = string.Format("SELECT eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Event.Admin);
                     DataTable _result      = SQL.TypeQuery(_sql);
                     string    _eventName   = _result.Rows[0].ItemArray.GetValue(0).ToString();
                     string    _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int       _eventTeams;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams);
                     int _eventPlayerCount;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount);
                     int _eventTime;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _eventTime);
                     _result.Dispose();
                     SdtdConsole.Instance.Output(string.Format("Event: {0}", _eventName));
                     SdtdConsole.Instance.Output(string.Format("Invitation: {0}", _eventInvite));
                     SdtdConsole.Instance.Output(string.Format("Info: Teams {0}, Players {1}, Time {2} minutes.", _eventTeams, _eventPlayerCount, _eventTime));
                     foreach (var _player in Event.PlayersTeam)
                     {
                         ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                         if (_cInfo != null)
                         {
                             int _team;
                             Event.PlayersTeam.TryGetValue(_player.Key, out _team);
                             SdtdConsole.Instance.Output(string.Format("Player name {0}, Id {1}, is on team {2}.", _cInfo.playerName, _cInfo.playerId, _team));
                         }
                         else
                         {
                             int _team;
                             Event.PlayersTeam.TryGetValue(_player.Key, out _team);
                             SdtdConsole.Instance.Output(string.Format("Offline player: Player name unknown, Id {0}, is on team {1}.", _player.Key, _team));
                         }
                     }
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("There is no event open.");
                 return;
             }
         }
         else if (_params[0].ToLower() == ("cancel"))
         {
             if (Event.Admin == _steamId)
             {
                 if (Event.Open)
                 {
                     if (!Event.Cancel)
                     {
                         Event.Cancel = true;
                         SdtdConsole.Instance.Output("Are you sure you want to cancel the current event? Type event cancel again to stop the event.");
                         return;
                     }
                     else
                     {
                         Event.SetupStage.Remove(_steamId);
                         Event.SetupName.Remove(_steamId);
                         foreach (var _player in Event.PlayersTeam)
                         {
                             ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                             if (_cInfo != null)
                             {
                                 EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                                 if (_player2.IsSpawned())
                                 {
                                     string    _sql      = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _steamId);
                                     DataTable _result   = SQL.TypeQuery(_sql);
                                     string    _position = _result.Rows[0].ItemArray.GetValue(0).ToString();
                                     _result.Dispose();
                                     int      x, y, z;
                                     string[] _cords = _position.Split(',');
                                     int.TryParse(_cords[0], out x);
                                     int.TryParse(_cords[1], out y);
                                     int.TryParse(_cords[2], out z);
                                     _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false));
                                     Event.PlayersTeam.Remove(_player.Key);
                                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the event has ended. Thank you for playing.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 }
                                 else
                                 {
                                     string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _steamId);
                                     SQL.FastQuery(_sql, "EventCommandsConsole");
                                     Event.PlayersTeam.Remove(_player.Key);
                                     SdtdConsole.Instance.Output(string.Format("Player with Id {0} was not spawned but they have been removed from the event and set to go back to their return point.", _player.Key));
                                 }
                             }
                             else
                             {
                                 string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _steamId);
                                 SQL.FastQuery(_sql, "EventCommandsConsole");
                                 Event.PlayersTeam.Remove(_player.Key);
                                 SdtdConsole.Instance.Output(string.Format("Player with Id {0} was offline but they have been removed from the event and set to go back to their return point.", _player.Key));
                             }
                         }
                         string _sql2 = string.Format("UPDATE Events SET eventAdmin = null, eventActive = 'false' WHERE eventAdmin = '{0}'", Event.Admin);
                         SQL.FastQuery(_sql2, "EventCommandsConsole");
                         Event.Cancel = false;
                         Event.Open   = false;
                         Event.Admin  = null;
                         SdtdConsole.Instance.Output("The current event has been cancelled and event players have been sent back to their return points.");
                     }
                 }
                 else
                 {
                     if (Event.Invited)
                     {
                         Event.Invited = false;
                         Event.Admin   = null;
                         if (Event.PlayersTeam.Count > 0)
                         {
                             foreach (var _player in Event.PlayersTeam)
                             {
                                 ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key);
                                 if (_cInfo != null)
                                 {
                                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the current event has been cancelled.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 }
                                 Event.PlayersTeam.Remove(_player.Key);
                             }
                         }
                         SdtdConsole.Instance.Output("The current setup has been cancelled and all signed up players were removed.");
                         return;
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("list"))
         {
             string    _sql    = string.Format("SELECT eventid, eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}'", _steamId);
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 foreach (DataRow row in _result.Rows)
                 {
                     SdtdConsole.Instance.Output(string.Format("Event Id = {0} Event Name = {1}", row[0].ToString(), row[1].ToString()));
                     SdtdConsole.Instance.Output(string.Format("Event Invite = {0}", row[2].ToString()));
                     SdtdConsole.Instance.Output(string.Format("Team Count = {0} Allowed Players = {1} Allowed Time = {2}", row[3].ToString(), row[4].ToString(), row[5].ToString()));
                     SdtdConsole.Instance.Output("-----------------------------------------------------------------------");
                     SdtdConsole.Instance.Output("-----------------------------------------------------------------------");
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("You have no saved event data.");
             }
             _result.Dispose();
             if (Event.Open || Event.Invited)
             {
                 SdtdConsole.Instance.Output(string.Format("An event is running by admin {0}", Event.Admin));
             }
             else
             {
                 SdtdConsole.Instance.Output("Type event load <eventid> to load that event. After loading, type event start to send the invitation to players.");
             }
         }
         else if (_params[0].ToLower() == ("load"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count));
                 return;
             }
             int _id;
             if (int.TryParse(_params[1], out _id))
             {
                 string    _sql    = string.Format("SELECT eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventid = {1}", _steamId, _id);
                 DataTable _result = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     string _eventName   = _result.Rows[0].ItemArray.GetValue(0).ToString();
                     string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int    _eventTeams;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams);
                     int _eventPlayerCount;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount);
                     int _eventTime;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _eventTime);
                     _result.Dispose();
                     SdtdConsole.Instance.Output(string.Format("Event: {0}", _eventName));
                     SdtdConsole.Instance.Output(string.Format("Invitation: {0}", _eventInvite));
                     SdtdConsole.Instance.Output(string.Format("Info: Teams {0}, Players {1}, Time {2} minutes.", _eventTeams, _eventPlayerCount, _eventTime));
                     if (Event.SetupStage.ContainsKey(_steamId))
                     {
                         Event.SetupStage[_steamId] = 5;
                         Event.SetupName[_steamId]  = _eventName;
                     }
                     else
                     {
                         Event.SetupStage.Add(_steamId, 5);
                         Event.SetupName.Add(_steamId, _eventName);
                     }
                     SdtdConsole.Instance.Output(string.Format("Event id: {0} has been loaded. Type event start to send the invitation out to players.", _id));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Could not find this event id: {0}", _id));
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}.", _params[1]));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("extend"))
         {
             if (Event.Admin == _steamId)
             {
                 if (Event.Open)
                 {
                     if (Event.Extend)
                     {
                         Event.Extend = false;
                         int _time;
                         if (int.TryParse(_params[1], out _time))
                         {
                             int _addTime = Timers._eventTime + (_time * 60);
                             Timers._eventTime = _addTime;
                             SdtdConsole.Instance.Output(string.Format("The event time was extended {0} minutes.", _time));
                             return;
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("The event can only be extended while five minutes remain in the event. Wait for an alert before using the command."));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("There is no event open to extend in time.");
                     return;
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin));
                 return;
             }
         }
         else if (_params[0].ToLower() == ("remove"))
         {
             if (Event.Admin == _steamId)
             {
                 if (Event.Open)
                 {
                     if (Event.PlayersTeam.ContainsKey(_params[1]))
                     {
                         ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_params[1]);
                         if (_cInfo != null)
                         {
                             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                             if (_player.IsSpawned())
                             {
                                 string    _sql      = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                 DataTable _result   = SQL.TypeQuery(_sql);
                                 string    _position = _result.Rows[0].ItemArray.GetValue(0).ToString();
                                 _result.Dispose();
                                 int      x, y, z;
                                 string[] _cords = _position.Split(',');
                                 int.TryParse(_cords[0], out x);
                                 int.TryParse(_cords[1], out y);
                                 int.TryParse(_cords[2], out z);
                                 _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false));
                                 _sql = string.Format("UPDATE Players SET eventReturn = 'Unknown', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "EventCommandsConsole");
                                 Event.PlayersTeam.Remove(_params[1]);
                                 ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been removed from the event and sent to your return point.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                                 SdtdConsole.Instance.Output(string.Format("Player with Id {0} was removed from the event and sent to their return point.", _params[1]));
                                 return;
                             }
                             else
                             {
                                 string _sql = string.Format("UPDATE Players SET return = 'true', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "EventCommandsConsole");
                                 Event.PlayersTeam.Remove(_params[1]);
                                 SdtdConsole.Instance.Output(string.Format("Player with Id {0} was not spawned but they were removed from the event and set to return to their return point.", _params[1]));
                             }
                         }
                         else
                         {
                             string _sql = string.Format("UPDATE Players SET return = 'true', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _params[1]);
                             SQL.FastQuery(_sql, "EventCommandsConsole");
                             Event.PlayersTeam.Remove(_params[1]);
                             SdtdConsole.Instance.Output(string.Format("Player with Id {0} was offline but they have been removed from the event and set to return to their return point.", _params[1]));
                             return;
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Invalid Id: {0}. They are not signed up for the event.", _params[1]));
                         return;
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("There is no event open.");
                     return;
                 }
             }
         }
         else if (_params[0].ToLower() == ("start"))
         {
             if (!Event.Invited)
             {
                 if (Event.SetupStage.ContainsKey(_steamId))
                 {
                     int _stage;
                     if (Event.SetupStage.TryGetValue(_steamId, out _stage))
                     {
                         string _eventName;
                         if (Event.SetupName.TryGetValue(_steamId, out _eventName))
                         {
                             if (_stage == 5)
                             {
                                 if (!Event.Open)
                                 {
                                     Event.Invited = true;
                                     Event.Admin   = _steamId;
                                     Event.SetupStage.Remove(_steamId);
                                     Event.SetupName.Remove(_steamId);
                                     string    _sql    = string.Format("SELECT eventid, eventInvite FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName);
                                     DataTable _result = SQL.TypeQuery(_sql);
                                     int       _eventid;
                                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
                                     string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString();
                                     _result.Dispose();
                                     _sql = string.Format("UPDATE Events SET eventActive = 'true' WHERE eventid = {0} AND eventAdmin = '{1}'", _eventid, _steamId);
                                     SQL.FastQuery(_sql, "EventCommandsConsole");
                                     string _msg1 = "Event: {EventName}[-]";
                                     string _msg2 = _eventInvite;
                                     string _msg3 = "Type /event if you want to join the event. You will return to where you are when it ends.[-]";
                                     _msg1 = _msg1.Replace("{EventName}", _eventName);
                                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg1, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg2, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg3, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                 }
                                 else
                                 {
                                     SdtdConsole.Instance.Output("The event has already started.");
                                     return;
                                 }
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output("This command is invalid at this stage of setup.");
                                 return;
                             }
                         }
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("There is an event invitation open already.");
                 return;
             }
         }
         else if (_params[0].ToLower() == ("delete") || _params[0].ToLower() == ("del"))
         {
             int _id;
             if (int.TryParse(_params[1], out _id))
             {
                 string    _sql    = string.Format("SELECT eventid FROM Events WHERE eventAdmin = '{0}'", _steamId);
                 DataTable _result = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     _sql = string.Format("Delete FROM Events WHERE eventid = {0}", _id);
                     SQL.FastQuery(_sql, "EventCommandsConsole");
                     _sql = string.Format("Delete FROM EventSpawns WHERE eventid = {0}", _id);
                     SQL.FastQuery(_sql, "EventCommandsConsole");
                     SdtdConsole.Instance.Output(string.Format("Deleted the event with id: {0}.", _id));
                     return;
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}. This id is not attached to you. Can not delete it.", _params[1]));
                 }
                 _result.Dispose();
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}.", _params[1]));
                 return;
             }
         }
         else
         {
             if (Event.SetupStage.ContainsKey(_steamId))
             {
                 int _stage;
                 if (Event.SetupStage.TryGetValue(_steamId, out _stage))
                 {
                     string _eventName;
                     if (Event.SetupName.TryGetValue(_steamId, out _eventName))
                     {
                         if (_stage == 1)
                         {
                             string _invite = SQL.EscapeString(_params[0]);
                             string _sql    = string.Format("UPDATE Events SET eventInvite = '{0}' WHERE eventAdmin = '{1}' AND eventName = '{2}'", _invite, _steamId, _eventName);
                             SQL.FastQuery(_sql, "EventCommandsConsole");
                             Event.SetupStage[_steamId] = 2;
                             SdtdConsole.Instance.Output(string.Format("The event invitation has been set to {0}.", _params[0]));
                             SdtdConsole.Instance.Output("How many teams, total players, and time in minutes will the event last? Type event <TeamCount> <TotalPlayers> <TimeInMin>.");
                             return;
                         }
                         else if (_stage == 2)
                         {
                             if (_params.Count == 3)
                             {
                                 int _teamCount;
                                 if (int.TryParse(_params[0], out _teamCount))
                                 {
                                     if (_teamCount < 1)
                                     {
                                         _teamCount = 1;
                                     }
                                     int _playerCount;
                                     if (int.TryParse(_params[1], out _playerCount))
                                     {
                                         if (_playerCount < 1)
                                         {
                                             _playerCount = 1;
                                         }
                                         int _eventTime;
                                         if (int.TryParse(_params[2], out _eventTime))
                                         {
                                             if (_eventTime < 1)
                                             {
                                                 _eventTime = 1;
                                             }
                                             string _sql = string.Format("UPDATE Events SET eventTeams = {0}, eventPlayerCount = {1}, eventTime = {2} WHERE eventAdmin = '{3}' AND eventName = '{4}'", _teamCount, _playerCount, _eventTime, _steamId, _eventName);
                                             SQL.FastQuery(_sql, "EventCommandsConsole");
                                             Event.SetupStage[_steamId] = 3;
                                             SdtdConsole.Instance.Output(string.Format("The event info has been set: team count {0}, total players {1}, event time {2}.", _teamCount, _playerCount, _eventTime));
                                             if (_teamCount == 1)
                                             {
                                                 SdtdConsole.Instance.Output("Stand where you would like players to spawn when the event starts and type event save.");
                                                 return;
                                             }
                                             else
                                             {
                                                 SdtdConsole.Instance.Output("Stand where you would like the team 1 to spawn when the event starts and type event save.");
                                                 return;
                                             }
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 3, found {0}.", _params.Count));
                                 return;
                             }
                         }
                     }
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("You have no event being setup. Setup a new one by typing event new <EventName>.");
                 return;
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in EventCommandsConsole.Execute: {0}", e));
     }
 }
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params[0].ToLower().Equals("add"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count));
                 return;
             }
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo != null)
             {
                 string    _sql              = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                 DataTable _result           = SQL.TypeQuery(_sql);
                 bool      _countrybanImmune = false;
                 if (_result.Rows.Count > 0)
                 {
                     bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _countrybanImmune);
                 }
                 if (_countrybanImmune)
                 {
                     SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Country Ban Immunity list.", _params[1]));
                 }
                 else
                 {
                     if (_result.Rows.Count > 0)
                     {
                         _sql = string.Format("UPDATE Players SET countryban = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                     }
                     else
                     {
                         _sql = string.Format("INSERT INTO Players (steamid, countryban) VALUES ('{0}', 'true')", _cInfo.playerId);
                     }
                     SQL.FastQuery(_sql, "CountryBanImmunityConsole");
                     SdtdConsole.Instance.Output(string.Format("Added Id {0} to the Country Ban Immunity list.", _params[1]));
                 }
                 _result.Dispose();
             }
             else
             {
                 if (_params[1].Length != 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("You can only use a player id or their name if online. Can not add Id: Invalid Id {0}", _params[1]));
                     return;
                 }
                 else
                 {
                     string    _id               = SQL.EscapeString(_params[1]);
                     string    _sql              = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}'", _id);
                     DataTable _result           = SQL.TypeQuery(_sql);
                     bool      _countrybanImmune = false;
                     if (_result.Rows.Count > 0)
                     {
                         bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _countrybanImmune);
                     }
                     if (_countrybanImmune)
                     {
                         SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Country Ban Immunity list.", _params[1]));
                     }
                     else
                     {
                         if (_result.Rows.Count > 0)
                         {
                             _sql = string.Format("UPDATE Players SET countryban = 'true' WHERE steamid = '{0}'", _id);
                         }
                         else
                         {
                             _sql = string.Format("INSERT INTO Players (steamid, countryban) VALUES ('{0}', 'true')", _id);
                         }
                         SQL.FastQuery(_sql, "CountryBanImmunityConsole");
                         SdtdConsole.Instance.Output(string.Format("Added Id {0} to the Country Ban Immunity list.", _params[1]));
                     }
                     _result.Dispose();
                 }
             }
         }
         else if (_params[0].ToLower().Equals("remove"))
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]);
             if (_cInfo != null)
             {
                 string    _sql    = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}' AND countryban = 'true'", _cInfo.playerId);
                 DataTable _result = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     _sql = string.Format("UPDATE Players SET countryban = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql, "CountryBanImmunityConsole");
                     SdtdConsole.Instance.Output(string.Format("Removed Id {0} from Country Ban Immunity list.", _params[1]));
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Id {0} was not found.", _params[1]));
                 }
                 _result.Dispose();
             }
             else
             {
                 if (_params[1].Length != 17)
                 {
                     SdtdConsole.Instance.Output(string.Format("You can only use a player id or their name if online. Can not remove Id: Invalid Id {0}", _params[1]));
                 }
                 else
                 {
                     string    _id     = SQL.EscapeString(_params[1]);
                     string    _sql    = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}' AND countryban = 'true'", _id);
                     DataTable _result = SQL.TypeQuery(_sql);
                     if (_result.Rows.Count > 0)
                     {
                         _sql = string.Format("UPDATE Players SET countryban = 'false' WHERE steamid = '{0}'", _id);
                         SQL.FastQuery(_sql, "CountryBanImmunityConsole");
                         SdtdConsole.Instance.Output(string.Format("Removed Id {0} from the Country Ban Immunity list.", _params[1]));
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Id {0} was not found.", _params[1]));
                     }
                     _result.Dispose();
                 }
             }
         }
         else if (_params[0].ToLower().Equals("list"))
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count));
                 return;
             }
             string    _sql    = "SELECT countryban FROM Players WHERE countryban = 'true'";
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count < 1)
             {
                 SdtdConsole.Instance.Output("There are no Ids on the Country Ban Immunity list.");
             }
             else
             {
                 foreach (DataRow row in _result.Rows)
                 {
                     SdtdConsole.Instance.Output(string.Format("{0}", row[0]));
                 }
                 SdtdConsole.Instance.Output(string.Format("Total: {0}", _result.Rows.Count.ToString()));
             }
             _result.Dispose();
         }
         else
         {
             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in CountryBanImmunityCommandConsole.Run: {0}.", e));
     }
 }
 public static void RemoveServerToolsPlayerData(string _id)
 {
     try
     {
         string    _sql    = string.Format("SELECT * FROM Players WHERE steamid = '{0}'", _id);
         DataTable _result = SQL.TypeQuery(_sql);
         if (_result.Rows.Count != 0)
         {
             _sql = string.Format("Delete FROM Players WHERE steamid = '{0}'", _id);
             SQL.FastQuery(_sql, "ResetPlayerConsole");
         }
         _result.Dispose();
         _sql    = string.Format("SELECT * FROM Waypoints WHERE steamid = '{0}'", _id);
         _result = SQL.TypeQuery(_sql);
         if (_result.Rows.Count != 0)
         {
             _sql = string.Format("Delete FROM Waypoints WHERE steamid = '{0}'", _id);
             SQL.FastQuery(_sql, "ResetPlayerConsole");
         }
         _result.Dispose();
         _sql    = string.Format("SELECT * FROM Hardcore WHERE steamid = '{0}'", _id);
         _result = SQL.TypeQuery(_sql);
         if (_result.Rows.Count != 0)
         {
             _sql = string.Format("Delete FROM Hardcore WHERE steamid = '{0}'", _id);
             SQL.FastQuery(_sql, "ResetPlayerConsole");
         }
         _result.Dispose();
         _sql    = string.Format("SELECT * FROM Tracking WHERE steamid = '{0}'", _id);
         _result = SQL.TypeQuery(_sql);
         if (_result.Rows.Count != 0)
         {
             _sql = string.Format("Delete FROM Tracking WHERE steamid = '{0}'", _id);
             SQL.FastQuery(_sql, "ResetPlayerConsole");
         }
         _result.Dispose();
         PersistentPlayer p = PersistentContainer.Instance.Players[_id];
         if (p != null)
         {
             p.AuctionCancelTime  = new DateTime();
             p.AuctionId          = 0;
             p.AuctionItemCount   = 0;
             p.AuctionItemName    = "";
             p.AuctionItemPrice   = 0;
             p.AuctionItemQuality = 0;
             p.AuctionReturn      = false;
             p.AuctionSellDate    = new DateTime();
             p.Bank               = 0;
             p.BikeId             = 0;
             p.Bounty             = 0;
             p.BountyHunter       = 0;
             p.ClanInvite         = "";
             p.ClanName           = "";
             p.ClanOfficer        = false;
             p.ClanOwner          = false;
             p.ClanRequestToJoin  = new List <string[]>();
             p.CountryBanImmune   = false;
             p.CustomCommand1     = new DateTime();
             p.CustomCommand2     = new DateTime();
             p.CustomCommand3     = new DateTime();
             p.CustomCommand4     = new DateTime();
             p.CustomCommand5     = new DateTime();
             p.CustomCommand6     = new DateTime();
             p.CustomCommand7     = new DateTime();
             p.CustomCommand8     = new DateTime();
             p.CustomCommand9     = new DateTime();
             p.CustomCommand10    = new DateTime();
             p.CustomCommand11    = new DateTime();
             p.CustomCommand12    = new DateTime();
             p.CustomCommand13    = new DateTime();
             p.CustomCommand14    = new DateTime();
             p.CustomCommand15    = new DateTime();
             p.CustomCommand16    = new DateTime();
             p.CustomCommand17    = new DateTime();
             p.CustomCommand18    = new DateTime();
             p.CustomCommand19    = new DateTime();
             p.CustomCommand20    = new DateTime();
             p.FirstClaimBlock    = false;
             p.GyroId             = 0;
             p.Hardcore           = false;
             p.HardcoreExtraLives = 0;
             p.HighPingImmune     = false;
             p.HighPingImmuneName = "";
             p.HomePosition1      = "";
             p.HomePosition2      = "";
             p.JailDate           = new DateTime();
             p.JailName           = "";
             p.JailTime           = 0;
             p.JeepId             = 0;
             p.LastAnimal         = new DateTime();
             p.LastBike           = new DateTime();
             p.LastDied           = new DateTime();
             p.LastFriendTele     = new DateTime();
             p.LastGimme          = new DateTime();
             p.LastGyro           = new DateTime();
             p.LastHome1          = new DateTime();
             p.LastHome2          = new DateTime();
             p.LastJeep           = new DateTime();
             p.LastJoined         = new DateTime();
             p.LastKillMe         = new DateTime();
             p.LastLobby          = new DateTime();
             p.LastLog            = new DateTime();
             p.LastMarket         = new DateTime();
             p.LastMiniBike       = new DateTime();
             p.LastMotorBike      = new DateTime();
             p.LastStuck          = new DateTime();
             p.LastTravel         = new DateTime();
             p.LastVote           = new DateTime();
             p.LastVoteWeek       = new DateTime();
             p.LastWhisper        = "";
             p.LobbyReturnPos     = "";
             p.MarketReturnPos    = "";
             p.MiniBikeId         = 0;
             p.MotorBikeId        = 0;
             p.MuteDate           = new DateTime();
             p.MuteName           = "";
             p.MuteTime           = 0;
             p.NewSpawn           = false;
             p.NewSpawnPosition   = "";
             p.OldPlayer          = false;
             p.PlayerName         = "";
             p.PlayerWallet       = 0;
             p.SessionTime        = 0;
             p.StartingItems      = false;
             p.TotalTimePlayed    = 0;
             p.VoteWeekCount      = 0;
             p.ZoneDeathTime      = new DateTime();
             PersistentContainer.Instance.Save();
         }
         string _phrase401;
         if (!Phrases.Dict.TryGetValue(401, out _phrase401))
         {
             _phrase401 = "You have reset the profile for Player {SteamId}.";
         }
         _phrase401 = _phrase401.Replace("{SteamId}", _id);
         SdtdConsole.Instance.Output(string.Format("{0}", _phrase401));
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ResetPlayerConsole.RemoveServerToolsPlayerData: {0}.", e.Message));
     }
 }
Пример #23
0
 public static void AddPlayer(ClientInfo _cInfo)
 {
     if (!PlayersTeam.ContainsKey(_cInfo.playerId))
     {
         EntityPlayer _player      = GameManager.Instance.World.Players.dict[_cInfo.entityId];
         Vector3      _position    = _player.GetPosition();
         int          x            = (int)_position.x;
         int          y            = (int)_position.y;
         int          z            = (int)_position.z;
         string       _sposition   = x + "," + y + "," + z;
         string       _eventReturn = SQL.EscapeString(_sposition);
         string       _sql         = string.Format("UPDATE Players SET eventReturn = '{0}' WHERE steamid = {1}", _eventReturn, _cInfo.playerId);
         SQL.FastQuery(_sql, "Event");
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have signed up for the event and your current location has been saved for return.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         _sql = string.Format("SELECT eventid, eventName, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Admin);
         DataTable _result1 = SQL.TypeQuery(_sql);
         int       _eventid;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid);
         string _eventName = _result1.Rows[0].ItemArray.GetValue(1).ToString();
         int    _eventTeams;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams);
         int _eventPlayerCount;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount);
         int _time;
         int.TryParse(_result1.Rows[0].ItemArray.GetValue(4).ToString(), out _time);
         _result1.Dispose();
         PlayersTeam.Add(_cInfo.playerId, TeamCount);
         string _message = " you are on team {Team}.";
         _message = _message.Replace("{Team}", TeamCount.ToString());
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         if (TeamCount == _eventTeams)
         {
             TeamCount = 1;
         }
         if (PlayersTeam.Count == _eventPlayerCount)
         {
             Invited = false;
             foreach (var _eventPlayer in PlayersTeam)
             {
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_eventPlayer.Key);
                 if (_cInfo2 != null)
                 {
                     EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                     if (_player2 != null && _player2.IsAlive())
                     {
                         int _teamNumber;
                         PlayersTeam.TryGetValue(_eventPlayer.Key, out _teamNumber);
                         _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _teamNumber);
                         DataTable _result2  = SQL.TypeQuery(_sql);
                         string    _spawnPos = _result2.Rows[0].ItemArray.GetValue(0).ToString();
                         _result2.Dispose();
                         int      _x, _y, _z;
                         string[] _cords = _spawnPos.Split(',');
                         int.TryParse(_cords[0], out _x);
                         int.TryParse(_cords[1], out _y);
                         int.TryParse(_cords[2], out _z);
                         _cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false));
                         ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _cInfo2.playerName + ", you have been sent to your event spawn point.[-]", _cInfo2.entityId, _cInfo2.playerName, EChatType.Whisper, null);
                     }
                     else
                     {
                         _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key);
                         SQL.FastQuery(_sql, "Event");
                     }
                 }
                 else
                 {
                     _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key);
                     SQL.FastQuery(_sql, "Event");
                 }
             }
             int _eventTime = _time * 60;
             Timers._eventTime = _eventTime;
             Open     = true;
             _message = "{EventName} is full and has now started.";
             _message = _message.Replace("{EventName}", _eventName);
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
         }
         else
         {
             _message = "{EventName} still has space for more players. Type " + ChatHook.Command_Private + Command100 + ".";
             _message = _message.Replace("{EventName}", _eventName);
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
             _message = "{Count} of {Total} have signed up.";
             _message = _message.Replace("{Count}", PlayersTeam.Count.ToString());
             _message = _message.Replace("{Total}", _eventPlayerCount.ToString());
             ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
         }
     }
     else
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are already signed up for this event. It will start when enough players sign up.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
     }
 }
Пример #24
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     if (!IsEnabled)
     {
         SdtdConsole.Instance.Output(string.Format("Polling is disabled. You must enable the tool first", _params.Count));
         return;
     }
     try
     {
         if (_params[0] == "new")
         {
             if (_params.Count < 3)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected at least 3, found {0}", _params.Count));
                 return;
             }
             else
             {
                 int _hours;
                 if (!int.TryParse(_params[1], out _hours))
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid integer {0}", _params[1]));
                     return;
                 }
                 _params.RemoveRange(0, 2);
                 string    _message = string.Join(" ", _params.ToArray());
                 string    _sql     = "SELECT pollTime, pollHours, pollMessage FROM Polls WHERE pollOpen = 'true'";
                 DataTable _result  = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     DateTime _pollTime;
                     DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollTime);
                     int _pollHours;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollHours);
                     string   _pollMessage    = _result.Rows[0].ItemArray.GetValue(2).ToString();
                     TimeSpan varTime         = DateTime.Now - _pollTime;
                     double   fractionalHours = varTime.TotalHours;
                     int      _timepassed     = (int)fractionalHours;
                     if (_timepassed >= _pollHours)
                     {
                         SdtdConsole.Instance.Output("There is a poll open but the time has expired.");
                         SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                         SdtdConsole.Instance.Output("You need to close the above poll before making a new one.");
                     }
                     else
                     {
                         int _timeleft = _pollHours - _timepassed;
                         SdtdConsole.Instance.Output("There is a poll open. Let it finish or close it");
                         SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                         SdtdConsole.Instance.Output(string.Format("Time Remaining: {0} hours", _timeleft));
                     }
                 }
                 else
                 {
                     _sql = string.Format("INSERT INTO Polls (pollOpen, pollTime, pollHours, pollMessage) VALUES ('true', '{0}', {1}, '{2}')", DateTime.Now, _hours, _message);
                     SQL.FastQuery(_sql, "PollConsole");
                     string _phrase926;
                     if (!Phrases.Dict.TryGetValue(926, out _phrase926))
                     {
                         _phrase926 = "Poll: {Message}";
                     }
                     _phrase926 = _phrase926.Replace("{Message}", _message);
                     string _phrase927;
                     if (!Phrases.Dict.TryGetValue(927, out _phrase927))
                     {
                         _phrase927 = "Type {CommandPrivate}{Command91} or {CommandPrivate}{Command92} to vote.";
                     }
                     _phrase927 = _phrase927.Replace("{CommandPrivate}", ChatHook.Command_Private);
                     _phrase927 = _phrase927.Replace("{Command91}", Command91);
                     _phrase927 = _phrase927.Replace("{Command92}", Command92);
                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase926, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase927, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     SdtdConsole.Instance.Output(string.Format("Opened a new poll for {0} hours.", _hours));
                     using (StreamWriter sw = new StreamWriter(_filepath, true))
                     {
                         sw.WriteLine(string.Format("{0}  New poll {1} ... The poll will be open for {2} hours", DateTime.Now, _message, _hours));
                         sw.WriteLine();
                         sw.Flush();
                         sw.Close();
                     }
                 }
                 _result.Dispose();
             }
         }
         else if (_params[0] == "close")
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             bool _announce = false;
             if (!bool.TryParse(_params[1], out _announce))
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid True/False argument: {0}", _params[1]));
                 return;
             }
             else
             {
                 string    _sql    = "SELECT pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
                 DataTable _result = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     int _pollYes;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollYes);
                     int _pollNo;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _pollNo);
                     if (_announce)
                     {
                         string _phrase925;
                         if (!Phrases.Dict.TryGetValue(925, out _phrase925))
                         {
                             _phrase925 = "Poll results: Yes {YesVote} / No {NoVote}";
                         }
                         _phrase925 = _phrase925.Replace("{YesVote}", _pollYes.ToString());
                         _phrase925 = _phrase925.Replace("{NoVote}", _pollNo.ToString());
                         ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase925, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                     }
                     using (StreamWriter sw = new StreamWriter(_filepath, true))
                     {
                         string _pollMessage = _result.Rows[0].ItemArray.GetValue(0).ToString();
                         sw.WriteLine(string.Format("{0}  Poll {1} ... has completed. The final results were yes {2} / no {3}", DateTime.Now, _pollMessage, _pollYes, _pollNo));
                         sw.WriteLine();
                         sw.Flush();
                         sw.Close();
                     }
                     _sql = "SELECT pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'false'";
                     DataTable _result1 = SQL.TypeQuery(_sql);
                     if (_result1.Rows.Count > 0)
                     {
                         _sql = "DELETE FROM Polls WHERE pollOpen = 'false'";
                         SQL.FastQuery(_sql, "PollConsole");
                     }
                     _result1.Dispose();
                     _sql = "UPDATE Polls SET pollOpen = 'false' WHERE pollOpen = 'true'";
                     SQL.FastQuery(_sql, "PollConsole");
                     PolledYes.Clear();
                     PolledNo.Clear();
                     SdtdConsole.Instance.Output("Closed the open poll.");
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("No poll is open");
                 }
                 _result.Dispose();
             }
         }
         else if (_params[0] == "last")
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}", _params.Count));
                 return;
             }
             else
             {
                 string    _sql    = "SELECT pollHours, pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'false'";
                 DataTable _result = SQL.TypeQuery(_sql);
                 if (_result.Rows.Count > 0)
                 {
                     int _pollHours;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollHours);
                     string _pollMessage = _result.Rows[0].ItemArray.GetValue(1).ToString();
                     int    _pollYes;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _pollYes);
                     int _pollNo;
                     int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _pollNo);
                     SdtdConsole.Instance.Output(string.Format("The last poll message: {0}", _pollMessage));
                     SdtdConsole.Instance.Output(string.Format("Last poll results: Yes {0} / No {1}", _pollYes, _pollNo));
                     SdtdConsole.Instance.Output(string.Format("Poll was open for {0} hours", _pollHours));
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("There are no saved prior poll results");
                 }
                 _result.Dispose();
             }
         }
         else if (_params[0] == "reopen")
         {
             if (_params.Count != 2)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count));
                 return;
             }
             string    _sql    = "SELECT pollTime, pollHours, pollMessage FROM Polls WHERE pollOpen = 'true'";
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 SdtdConsole.Instance.Output("A poll is open. Can not open a new poll until it is closed");
             }
             else
             {
                 _sql = "SELECT pollTime, pollHours, pollMessage FROM Polls WHERE pollOpen = 'false'";
                 DataTable _result1 = SQL.TypeQuery(_sql);
                 if (_result1.Rows.Count > 0)
                 {
                     int _hours;
                     int.TryParse(_params[1], out _hours);
                     _sql = string.Format("UPDATE Polls SET pollOpen = 'true', pollTime = '{0}', pollHours = {1} WHERE pollOpen = 'false'", DateTime.Now, _hours);
                     SQL.FastQuery(_sql, "PollConsole");
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("You have no previous poll");
                 }
                 _result1.Dispose();
             }
             _result.Dispose();
         }
         else if (_params[0] == "check")
         {
             if (_params.Count != 1)
             {
                 SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}", _params.Count));
                 return;
             }
             string    _sql    = "SELECT pollTime, pollHours, pollMessage, pollYes, pollNo FROM Polls WHERE pollOpen = 'true'";
             DataTable _result = SQL.TypeQuery(_sql);
             if (_result.Rows.Count > 0)
             {
                 DateTime _pollTime;
                 DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _pollTime);
                 int _pollHours;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _pollHours);
                 string _pollMessage = _result.Rows[0].ItemArray.GetValue(2).ToString();
                 int    _pollYes;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _pollYes);
                 int _pollNo;
                 int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _pollNo);
                 TimeSpan varTime         = DateTime.Now - _pollTime;
                 double   fractionalHours = varTime.TotalHours;
                 int      _timepassed     = (int)fractionalHours;
                 if (_timepassed >= _pollHours)
                 {
                     SdtdConsole.Instance.Output("There is a poll open but the time has expired.");
                     SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                     SdtdConsole.Instance.Output(string.Format("Current poll results: Yes votes {0} / No votes {1}", _pollYes, _pollNo));
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Poll: {0}", _pollMessage));
                     SdtdConsole.Instance.Output(string.Format("Current poll results: Yes votes {0} / No votes {1}", _pollYes, _pollNo));
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output("No poll is open");
             }
             _result.Dispose();
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in PollConsole.Run: {0}.", e));
     }
 }
Пример #25
0
        public static void Load()
        {
            Timers.TimerStart();
            Timers.Timer2Start();
            string    _sql    = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                PollConsole.Check();
            }
            _result.Dispose();
            if (!ClanManager.IsEnabled)
            {
                ClanManager.Clans.Clear();
                ClanManager.ClanMember.Clear();
            }
            if (!InfoTicker.IsEnabled && InfoTicker.IsRunning)
            {
                InfoTicker.Unload();
            }
            if (InfoTicker.IsEnabled && !InfoTicker.IsRunning)
            {
                InfoTicker.Load();
            }
            if (Gimme.IsRunning && !Gimme.IsEnabled)
            {
                Gimme.Unload();
            }
            if (!Gimme.IsRunning && Gimme.IsEnabled)
            {
                Gimme.Load();
            }
            if (Badwords.IsRunning && !Badwords.IsEnabled)
            {
                Badwords.Unload();
            }
            if (!Badwords.IsRunning && Badwords.IsEnabled)
            {
                Badwords.Load();
            }
            if (!LoginNotice.IsRunning && LoginNotice.IsEnabled)
            {
                LoginNotice.Load();
            }
            if (LoginNotice.IsRunning && !LoginNotice.IsEnabled)
            {
                LoginNotice.Unload();
            }
            if (!Zones.IsRunning && Zones.IsEnabled)
            {
                Zones.Load();
            }
            if (Zones.IsRunning && !Zones.IsEnabled)
            {
                Zones.Unload();
            }
            if (!VoteReward.IsRunning && VoteReward.IsEnabled)
            {
                VoteReward.Load();
            }
            if (VoteReward.IsRunning && !VoteReward.IsEnabled)
            {
                VoteReward.Unload();
            }
            if (!Watchlist.IsRunning && Watchlist.IsEnabled)
            {
                Watchlist.Load();
            }
            if (Watchlist.IsRunning && !Watchlist.IsEnabled)
            {
                Watchlist.Unload();
            }
            if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled)
            {
                ReservedSlots.Load();
            }
            if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled)
            {
                ReservedSlots.Unload();
            }
            if (!StartingItems.IsRunning && StartingItems.IsEnabled)
            {
                StartingItems.Load();
            }
            if (StartingItems.IsRunning && !StartingItems.IsEnabled)
            {
                StartingItems.Unload();
            }
            if (!Travel.IsRunning && Travel.IsEnabled)
            {
                Travel.Load();
            }
            if (Travel.IsRunning && !Travel.IsEnabled)
            {
                Travel.Unload();
            }
            if (!Shop.IsRunning && Shop.IsEnabled)
            {
                Shop.Load();
            }
            if (Shop.IsRunning && !Shop.IsEnabled)
            {
                Shop.Unload();
            }
            if (!Motd.IsRunning && Motd.IsEnabled)
            {
                Motd.Load();
            }
            if (Motd.IsRunning && !Motd.IsEnabled)
            {
                Motd.Unload();
            }
            if (InventoryCheck.IsRunning && !InventoryCheck.IsEnabled)
            {
                InventoryCheck.Unload();
            }
            if (!InventoryCheck.IsRunning && InventoryCheck.IsEnabled)
            {
                InventoryCheck.Load();
            }
            if (HighPingKicker.IsEnabled)
            {
                HighPingKicker.Load();
            }
            if (CredentialCheck.IsRunning && !CredentialCheck.IsEnabled)
            {
                CredentialCheck.Unload();
            }
            if (!CredentialCheck.IsRunning && CredentialCheck.IsEnabled)
            {
                CredentialCheck.Load();
            }
            if (CustomCommands.IsRunning && !CustomCommands.IsEnabled)
            {
                CustomCommands.Unload();
            }
            if (!CustomCommands.IsRunning && CustomCommands.IsEnabled)
            {
                CustomCommands.Load();
            }
            if (DupeLog.IsRunning && !DupeLog.IsEnabled)
            {
                DupeLog.Unload();
            }
            if (!DupeLog.IsRunning && DupeLog.IsEnabled)
            {
                DupeLog.Load();
            }
            if (ChatColorPrefix.IsRunning && !ChatColorPrefix.IsEnabled)
            {
                ChatColorPrefix.Unload();
            }
            if (!ChatColorPrefix.IsRunning && ChatColorPrefix.IsEnabled)
            {
                ChatColorPrefix.Load();
            }
            if (KillNotice.IsRunning && !KillNotice.IsEnabled)
            {
                KillNotice.Unload();
            }
            if (!KillNotice.IsRunning && KillNotice.IsEnabled)
            {
                KillNotice.Load();
            }
            if (!Prayer.IsRunning && Prayer.IsEnabled)
            {
                Prayer.Load();
            }
            if (Prayer.IsRunning && !Prayer.IsEnabled)
            {
                Prayer.Unload();
            }
            if (LoadTriggers.IsRunning)
            {
                LoadTriggers.Unload();
            }
            if (!LoadTriggers.IsRunning)
            {
                LoadTriggers.Load();
            }
            if (ProtectedSpace.IsRunning)
            {
                ProtectedSpace.Unload();
            }
            if (!ProtectedSpace.IsRunning)
            {
                ProtectedSpace.Load();
            }
            if (ClanManager.IsEnabled)
            {
                ClanManager.ClanList();
            }
            if (AuctionBox.IsEnabled)
            {
                AuctionBox.AuctionList();
            }
            if (Mute.IsEnabled)
            {
                Mute.MuteList();
            }
            if (Jail.IsEnabled)
            {
                Jail.JailList();
            }
            if (BattleLogger.IsEnabled && !BattleLogger.LogFound && !string.IsNullOrEmpty(Utils.GetApplicationScratchPath()))
            {
                if (!GamePrefs.GetString(EnumGamePrefs.ServerDisabledNetworkProtocols).ToLower().Contains("litenetlib"))
                {
                    BattleLogger.LogDirectory = Utils.GetApplicationScratchPath();
                    BattleLogger.ConfirmLog();
                }
                else
                {
                    Log.Out("--------------------------------------------------------------------------");
                    Log.Out("[SERVERTOOLS] Unable to verify log file. Battle_Loggers has been disabled.");
                    Log.Out("[SERVERTOOLS] Network protocol litenetlib is required for this tool.");
                    Log.Out("--------------------------------------------------------------------");
                }
            }
            PatchTools.ApplyPatches();
        }
Пример #26
0
 private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player
 {
     try
     {
         if (_cInfo != null)
         {
             if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawned
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName;
                 PersistentContainer.Instance.Save();
                 PersistentOperations.SessionTime(_cInfo);
                 Timers.NewPlayerExecTimer(_cInfo);
             }
             else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawned
             {
                 PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName;
                 PersistentContainer.Instance.Save();
                 PersistentOperations.SessionTime(_cInfo);
                 if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer)
                 {
                     Timers.NewPlayerExecTimer(_cInfo);
                 }
                 else
                 {
                     if (Hardcore.IsEnabled && !Hardcore.Optional)
                     {
                         string    _sql    = string.Format("SELECT * FROM Hardcore WHERE steamid = '{0}'", _cInfo.playerId);
                         DataTable _result = SQL.TypeQuery(_sql);
                         if (_result.Rows.Count == 0)
                         {
                             EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId];
                             if (_player != null)
                             {
                                 int    _deaths     = XUiM_Player.GetDeaths(_player);
                                 string _playerName = SQL.EscapeString(_cInfo.playerName);
                                 SQL.FastQuery(string.Format("INSERT INTO Hardcore (steamid, playerName, deaths) VALUES ('{0}', '{1}', {2})", _cInfo.playerId, _playerName, _deaths), null);
                             }
                         }
                         _result.Dispose();
                     }
                     if (LoginNotice.IsEnabled && LoginNotice.dict.ContainsKey(_cInfo.playerId))
                     {
                         LoginNotice.PlayerNotice(_cInfo);
                     }
                     if (Motd.IsEnabled)
                     {
                         Motd.Send(_cInfo);
                     }
                     if (Bloodmoon.IsEnabled)
                     {
                         Bloodmoon.Exec(_cInfo);
                     }
                     if (AutoShutdown.IsEnabled && AutoShutdown.Alert_On_Login)
                     {
                         AutoShutdown.NextShutdown(_cInfo);
                     }
                     if (Hardcore.IsEnabled)
                     {
                         if (!Hardcore.Optional)
                         {
                             Hardcore.Alert(_cInfo);
                         }
                         else if (PersistentContainer.Instance.Players[_cInfo.playerId].Hardcore)
                         {
                             Hardcore.Alert(_cInfo);
                         }
                     }
                     if (BattleLogger.IsEnabled)
                     {
                         BattleLogger.AlertPlayer(_cInfo);
                     }
                     if (PollConsole.IsEnabled)
                     {
                         string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
                         if (!string.IsNullOrEmpty(_sql))
                         {
                             DataTable _result = SQL.TypeQuery(_sql);
                             if (_result.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId))
                             {
                                 PollConsole.Message(_cInfo);
                             }
                             _result.Dispose();
                         }
                     }
                     if (Event.Open)
                     {
                         if (Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                         {
                             string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                             if (!string.IsNullOrEmpty(_sql))
                             {
                                 DataTable _result1      = SQL.TypeQuery(_sql);
                                 bool      _eventRespawn = false;
                                 if (_result1.Rows.Count > 0)
                                 {
                                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn);
                                 }
                                 _result1.Dispose();
                                 if (_eventRespawn)
                                 {
                                     Event.Died(_cInfo);
                                 }
                                 else
                                 {
                                     _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                     DataTable _result2 = SQL.TypeQuery(_sql);
                                     bool      _return1 = false, _return2 = false;
                                     if (_result2.Rows.Count > 0)
                                     {
                                         bool.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                                         bool.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                                     }
                                     _result2.Dispose();
                                     if (_return1)
                                     {
                                         if (_return2)
                                         {
                                             _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                             SQL.FastQuery(_sql, "API");
                                         }
                                         _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                         SQL.FastQuery(_sql, "API");
                                         Event.EventSpawn(_cInfo);
                                     }
                                     else if (_return2)
                                     {
                                         Event.EventSpawn(_cInfo);
                                     }
                                 }
                             }
                         }
                     }
                     if (ClanManager.IsEnabled)
                     {
                         List <string[]> _clanRequests = PersistentContainer.Instance.Players[_cInfo.playerId].ClanRequestToJoin;
                         if (_clanRequests != null && _clanRequests.Count > 0)
                         {
                             string[] _request    = _clanRequests[0];
                             string   _playerName = _request[1];
                             ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "There is a request to join the group from " + _playerName + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                         }
                     }
                 }
             }
             else if (_respawnReason == RespawnType.Died)//Player Died
             {
                 PersistentOperations.SessionTime(_cInfo);
                 if (Bloodmoon.IsEnabled && Bloodmoon.Show_On_Respawn)
                 {
                     Bloodmoon.Exec(_cInfo);
                 }
                 if (BattleLogger.IsEnabled)
                 {
                     BattleLogger.AlertPlayer(_cInfo);
                 }
                 if (Event.Open)
                 {
                     if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                     {
                         string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                         if (!string.IsNullOrEmpty(_sql))
                         {
                             DataTable _result1 = SQL.TypeQuery(_sql);
                             bool      _return1 = false, _return2 = false;
                             if (_result1.Rows.Count > 0)
                             {
                                 bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                                 bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                             }
                             _result1.Dispose();
                             if (_return1)
                             {
                                 if (_return2)
                                 {
                                     _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                     SQL.FastQuery(_sql, "API");
                                 }
                                 _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "API");
                                 Event.EventSpawn(_cInfo);
                                 return;
                             }
                         }
                     }
                     else
                     {
                         string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                         if (!string.IsNullOrEmpty(_sql))
                         {
                             DataTable _result       = SQL.TypeQuery(_sql);
                             bool      _eventRespawn = false;
                             if (_result.Rows.Count > 0)
                             {
                                 bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn);
                             }
                             _result.Dispose();
                             if (_eventRespawn)
                             {
                                 Event.Died(_cInfo);
                                 return;
                             }
                             else
                             {
                                 _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                 DataTable _result1 = SQL.TypeQuery(_sql);
                                 bool      _return1 = false, _return2 = false;
                                 if (_result1.Rows.Count > 0)
                                 {
                                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                                     bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                                 }
                                 _result1.Dispose();
                                 if (_return1)
                                 {
                                     if (_return2)
                                     {
                                         _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                         SQL.FastQuery(_sql, "API");
                                     }
                                     _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                     SQL.FastQuery(_sql, "API");
                                     Event.EventSpawn(_cInfo);
                                     return;
                                 }
                                 else if (_return2)
                                 {
                                     Event.EventSpawn(_cInfo);
                                     return;
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                     if (!string.IsNullOrEmpty(_sql))
                     {
                         DataTable _result1 = SQL.TypeQuery(_sql);
                         bool      _return1 = false, _return2 = false;
                         if (_result1.Rows.Count > 0)
                         {
                             bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1);
                             bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2);
                         }
                         _result1.Dispose();
                         if (_return1)
                         {
                             if (_return2)
                             {
                                 _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                                 SQL.FastQuery(_sql, "API");
                             }
                             _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId);
                             SQL.FastQuery(_sql, "API");
                             Event.EventSpawn(_cInfo);
                             return;
                         }
                     }
                 }
                 if (Wallet.IsEnabled)
                 {
                     if (Wallet.Lose_On_Death)
                     {
                         Wallet.ClearWallet(_cInfo);
                     }
                     else if (Wallet.Deaths > 0)
                     {
                         Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Wallet.Deaths);
                     }
                 }
                 if (Hardcore.IsEnabled)
                 {
                     if (!Hardcore.Optional)
                     {
                         Hardcore.Check(_cInfo);
                     }
                     else if (PersistentContainer.Instance.Players[_cInfo.playerId].Hardcore)
                     {
                         Hardcore.Check(_cInfo);
                     }
                 }
                 if (Zones.IsEnabled && Zones.Victim.ContainsKey(_cInfo.entityId))
                 {
                     string _response = " type {CommandPrivate}{Command50} to teleport back to your death position. There is a time limit.";
                     _response = _response.Replace("{CommandPrivate}", ChatHook.Command_Private);
                     _response = _response.Replace("{Command50}", Zones.Command50);
                     ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _response + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     PersistentContainer.Instance.Players[_cInfo.playerId].ZoneDeathTime = DateTime.Now;
                     PersistentContainer.Instance.Save();
                     if (Zones.Forgive.ContainsKey(_cInfo.entityId))
                     {
                         string _response2 = " type {CommandPrivate}{Command55} to release your killer from jail.";
                         _response2 = _response2.Replace("{CommandPrivate}", ChatHook.Command_Private);
                         _response2 = _response2.Replace("{Command55}", Jail.Command55);
                         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _response2 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                     }
                 }
             }
             else if (_respawnReason == RespawnType.Teleport)
             {
             }
             string _ip = _cInfo.ip;
             if (_ip.Contains(":"))
             {
                 _ip = _ip.Split(':').First();
             }
             if (!string.IsNullOrEmpty(_ip) && BattleLogger.IsEnabled && BattleLogger.LogFound && !StopServer.StopServerCountingDown && !StopServer.Shutdown && GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId).PermissionLevel > BattleLogger.Admin_Level)
             {
                 if (!BattleLogger.Players.ContainsKey(_cInfo.playerId))
                 {
                     BattleLogger.Players.Add(_cInfo.playerId, _cInfo.ip);
                 }
                 else
                 {
                     string _recordedIp;
                     BattleLogger.Players.TryGetValue(_cInfo.playerId, out _recordedIp);
                     if (_recordedIp != _ip)
                     {
                         BattleLogger.Players[_cInfo.playerId] = _ip;
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}.", e.Message));
     }
 }
Пример #27
0
        public static void TopThree(ClientInfo _cInfo, bool _announce)
        {
            int       _sessionTime, _score, _topSession1 = 0, _topSession2 = 0, _topSession3 = 0, _topScore1 = 0, _topScore2 = 0, _topScore3 = 0;
            string    _sessionName1 = "", _sessionName2 = "", _sessionName3 = "", _ScoreName1 = "", _ScoreName2 = "", _ScoreName3 = "";
            string    _sql    = "SELECT sessionTime, score, playerName From Hardcore";
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                foreach (DataRow row in _result.Rows)
                {
                    int.TryParse(row[0].ToString(), out _sessionTime);
                    if (_sessionTime > _topSession1)
                    {
                        _topSession3  = _topSession2;
                        _sessionName3 = _sessionName2;
                        _topSession2  = _topSession1;
                        _sessionName2 = _sessionName1;
                        _topSession1  = _sessionTime;
                        _sessionName1 = row[2].ToString();
                    }
                    else if (_sessionTime > _topSession2)
                    {
                        _topSession3  = _topSession2;
                        _sessionName3 = _sessionName2;
                        _topSession2  = _sessionTime;
                        _sessionName2 = row[2].ToString();
                    }
                    else if (_sessionTime > _topSession3)
                    {
                        _topSession3  = _sessionTime;
                        _sessionName3 = row[2].ToString();
                    }
                    int.TryParse(row[1].ToString(), out _score);
                    if (_score > _topScore1)
                    {
                        _topScore3  = _topScore2;
                        _ScoreName3 = _ScoreName2;
                        _topScore2  = _topScore1;
                        _ScoreName2 = _ScoreName1;
                        _topScore1  = _score;
                        _ScoreName1 = row[2].ToString();
                    }
                    else if (_score > _topScore2)
                    {
                        _topScore3  = _topScore2;
                        _ScoreName3 = _ScoreName2;
                        _topScore2  = _score;
                        _ScoreName2 = row[2].ToString();
                    }
                    else if (_score > _topScore3)
                    {
                        _topScore3  = _score;
                        _ScoreName3 = row[2].ToString();
                    }
                }
                string _phrase945;
                if (!Phrases.Dict.TryGetValue(945, out _phrase945))
                {
                    _phrase945 = "Hardcore Top Players";
                }
                string _phrase946;
                if (!Phrases.Dict.TryGetValue(946, out _phrase946))
                {
                    _phrase946 = "Playtime 1 {Name1}, {Session1}. Playtime 2 {Name2}, {Session3}. Playtime 3 {Name3}, {Session3}";
                }
                _phrase946 = _phrase946.Replace("{Name1}", _sessionName1);
                _phrase946 = _phrase946.Replace("{Session1}", _topSession1.ToString());
                _phrase946 = _phrase946.Replace("{Name2}", _sessionName2);
                _phrase946 = _phrase946.Replace("{Session2}", _topSession2.ToString());
                _phrase946 = _phrase946.Replace("{Name3}", _sessionName3);
                _phrase946 = _phrase946.Replace("{Session3}", _topSession3.ToString());
                string _phrase947;
                if (!Phrases.Dict.TryGetValue(947, out _phrase947))
                {
                    _phrase947 = "Score 1 {Name1}, {Score1}. Score 2 {Name2}, {Score2}. Score 3 {Name3}, {Score3}";
                }
                _phrase947 = _phrase947.Replace("{Name1}", _ScoreName1);
                _phrase947 = _phrase947.Replace("{Score1}", _topScore1.ToString());
                _phrase947 = _phrase947.Replace("{Name2}", _ScoreName2);
                _phrase947 = _phrase947.Replace("{Score2}", _topScore2.ToString());
                _phrase947 = _phrase947.Replace("{Name3}", _ScoreName3);
                _phrase947 = _phrase947.Replace("{Score3}", _topScore3.ToString());
                if (_announce)
                {
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase945 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase946 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase947 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                }
                else
                {
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase945 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase946 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase947 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
                }
            }
            else
            {
                ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "There are no hardcore records" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
            }
            _result.Dispose();
        }
Пример #28
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count < 1 || _params.Count == 3 || _params.Count == 4 || _params.Count > 5)
         {
             SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, 2 or 5, found {0}", _params.Count));
             return;
         }
         if (_params[0].ToLower().Equals("off"))
         {
             Tracking.IsEnabled = false;
             LoadConfig.WriteXml();
             SdtdConsole.Instance.Output(string.Format("Tracking has been set to off"));
             return;
         }
         else if (_params[0].ToLower().Equals("on"))
         {
             Tracking.IsEnabled = true;
             LoadConfig.WriteXml();
             SdtdConsole.Instance.Output(string.Format("Tracking has been set to on"));
             return;
         }
         else if (_params.Count == 2)
         {
             int _hours, _range;
             if (int.TryParse(_params[0], out _hours))
             {
                 if (int.TryParse(_params[1], out _range))
                 {
                     List <string> PlayerInRange = new List <string>();
                     string        _sql          = string.Format("SELECT * FROM Tracking ORDER BY dateTime DESC");
                     DataTable     _result       = SQL.TypeQuery(_sql);
                     if (_result.Rows.Count > 0)
                     {
                         bool         _found  = false;
                         EntityPlayer _player = GameManager.Instance.World.Players.dict[_senderInfo.RemoteClientInfo.entityId];
                         SdtdConsole.Instance.Output(string.Format("Tracking results at a range of {0} blocks:", _range));
                         foreach (DataRow row in _result.Rows)
                         {
                             DateTime _dateTime;
                             DateTime.TryParse(row.ItemArray.GetValue(1).ToString(), out _dateTime);
                             if (_dateTime.AddHours(_hours) >= DateTime.Now)
                             {
                                 string[] _cords = row.ItemArray.GetValue(2).ToString().Split(' ');
                                 int      _x, _y, _z;
                                 int.TryParse(_cords[0], out _x);
                                 int.TryParse(_cords[1], out _y);
                                 int.TryParse(_cords[2], out _z);
                                 Vector3 _trackedVecPos = new Vector3(_x, _y, _z);
                                 if (RangeCheck(_player.position, _trackedVecPos, _range))
                                 {
                                     _found = true;
                                     string _playerId   = row.ItemArray.GetValue(3).ToString();
                                     string _playerName = row.ItemArray.GetValue(4).ToString();
                                     string _itemHeld   = row.ItemArray.GetValue(5).ToString();
                                     if (!PlayerInRange.Contains(_playerId))
                                     {
                                         PlayerInRange.Add(_playerId);
                                         SdtdConsole.Instance.Output(string.Format("Player: {0}, SteamId: {1}, Time: {2}, Position: {3} {4} {5}, Item Held: {6}", _playerName, _playerId, _dateTime, _x, _y, _z, _itemHeld));
                                     }
                                 }
                             }
                         }
                         if (!_found)
                         {
                             SdtdConsole.Instance.Output(string.Format("Tracking results found nobody at this time and range inside your current position"));
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("No tracking positions are recorded in the database"));
                     }
                     _result.Dispose();
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[1]));
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
             }
             return;
         }
         else if (_params.Count == 5)
         {
             int _hours, _range, _worldX, _worldY, _worldZ;
             if (int.TryParse(_params[0], out _hours))
             {
                 if (int.TryParse(_params[1], out _range))
                 {
                     if (int.TryParse(_params[2], out _worldX))
                     {
                         if (int.TryParse(_params[3], out _worldY))
                         {
                             if (int.TryParse(_params[4], out _worldZ))
                             {
                                 string    _sql    = string.Format("SELECT * FROM Tracking ORDER BY dateTime DESC");
                                 DataTable _result = SQL.TypeQuery(_sql);
                                 if (_result.Rows.Count > 0)
                                 {
                                     bool          _found        = false;
                                     List <string> PlayerInRange = new List <string>();
                                     SdtdConsole.Instance.Output(string.Format("Tracking results at a range of {0} blocks:", _range));
                                     foreach (DataRow row in _result.Rows)
                                     {
                                         DateTime _dateTime;
                                         DateTime.TryParse(row.ItemArray.GetValue(1).ToString(), out _dateTime);
                                         if (_dateTime.AddHours(_hours) >= DateTime.Now)
                                         {
                                             string[] _cords = row.ItemArray.GetValue(2).ToString().Split(' ');
                                             int      _x, _y, _z;
                                             int.TryParse(_cords[0], out _x);
                                             int.TryParse(_cords[1], out _y);
                                             int.TryParse(_cords[2], out _z);
                                             Vector3 _worldVecPos   = new Vector3(_worldX, _worldY, _worldZ);
                                             Vector3 _trackedVecPos = new Vector3(_x, _y, _z);
                                             if (RangeCheck(_worldVecPos, _trackedVecPos, _range))
                                             {
                                                 _found = true;
                                                 string _playerId   = row.ItemArray.GetValue(3).ToString();
                                                 string _playerName = row.ItemArray.GetValue(4).ToString();
                                                 string _itemHeld   = row.ItemArray.GetValue(5).ToString();
                                                 if (!PlayerInRange.Contains(_playerId))
                                                 {
                                                     PlayerInRange.Add(_playerId);
                                                     SdtdConsole.Instance.Output(string.Format("Player: {0}, SteamId: {1}, Time: {2}, Position: {3} {4} {5}, Item Held: {6}", _playerName, _playerId, _dateTime, _x, _y, _z, _itemHeld));
                                                 }
                                             }
                                         }
                                     }
                                     if (!_found)
                                     {
                                         SdtdConsole.Instance.Output(string.Format("Tracking results found nobody at this time and range inside the specified position"));
                                     }
                                 }
                                 else
                                 {
                                     SdtdConsole.Instance.Output(string.Format("No tracking positions are recorded in the database"));
                                 }
                                 _result.Dispose();
                             }
                             else
                             {
                                 SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[4]));
                             }
                         }
                         else
                         {
                             SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[3]));
                         }
                     }
                     else
                     {
                         SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[2]));
                     }
                 }
                 else
                 {
                     SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[1]));
                 }
             }
             else
             {
                 SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0]));
             }
             return;
         }
         else
         {
             SdtdConsole.Instance.Output("Invalid arguments.");
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in TrackingConsole.Run: {0}.", e));
     }
 }
Пример #29
0
        public static void Load()
        {
            Confirm.Exec();
            PatchTools.ApplyPatches();
            if (!LoadTriggers.IsRunning)
            {
                LoadTriggers.Load();
            }
            Timers.TimerStart();
            string    _sql    = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'";
            DataTable _result = SQL.TypeQuery(_sql);

            if (_result.Rows.Count > 0)
            {
                PollConsole.Check();
            }
            _result.Dispose();
            if (!ClanManager.IsEnabled)
            {
                ClanManager.Clans.Clear();
                ClanManager.ClanMember.Clear();
            }
            if (!InfoTicker.IsEnabled && InfoTicker.IsRunning)
            {
                InfoTicker.Unload();
            }
            if (InfoTicker.IsEnabled && !InfoTicker.IsRunning)
            {
                InfoTicker.Load();
            }
            if (Gimme.IsRunning && !Gimme.IsEnabled)
            {
                Gimme.Unload();
            }
            if (!Gimme.IsRunning && Gimme.IsEnabled)
            {
                Gimme.Load();
            }
            if (Badwords.IsRunning && !Badwords.IsEnabled)
            {
                Badwords.Unload();
            }
            if (!Badwords.IsRunning && Badwords.IsEnabled)
            {
                Badwords.Load();
            }
            if (!LoginNotice.IsRunning && LoginNotice.IsEnabled)
            {
                LoginNotice.Load();
            }
            if (LoginNotice.IsRunning && !LoginNotice.IsEnabled)
            {
                LoginNotice.Unload();
            }
            if (!Zones.IsRunning && Zones.IsEnabled)
            {
                Zones.Load();
            }
            if (Zones.IsRunning && !Zones.IsEnabled)
            {
                Zones.Unload();
            }
            if (!VoteReward.IsRunning && VoteReward.IsEnabled)
            {
                VoteReward.Load();
            }
            if (VoteReward.IsRunning && !VoteReward.IsEnabled)
            {
                VoteReward.Unload();
            }
            if (!Watchlist.IsRunning && Watchlist.IsEnabled)
            {
                Watchlist.Load();
            }
            if (Watchlist.IsRunning && !Watchlist.IsEnabled)
            {
                Watchlist.Unload();
            }
            if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled)
            {
                ReservedSlots.Load();
            }
            if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled)
            {
                ReservedSlots.Unload();
            }
            if (!StartingItems.IsRunning && StartingItems.IsEnabled)
            {
                StartingItems.Load();
            }
            if (StartingItems.IsRunning && !StartingItems.IsEnabled)
            {
                StartingItems.Unload();
            }
            if (!Travel.IsRunning && Travel.IsEnabled)
            {
                Travel.Load();
            }
            if (Travel.IsRunning && !Travel.IsEnabled)
            {
                Travel.Unload();
            }
            if (!Shop.IsRunning && Shop.IsEnabled)
            {
                Shop.Load();
            }
            if (Shop.IsRunning && !Shop.IsEnabled)
            {
                Shop.Unload();
            }
            if (!Motd.IsRunning && Motd.IsEnabled)
            {
                Motd.Load();
            }
            if (Motd.IsRunning && !Motd.IsEnabled)
            {
                Motd.Unload();
            }
            if (InvalidItems.IsRunning && !InvalidItems.IsEnabled)
            {
                InvalidItems.Unload();
            }
            if (!InvalidItems.IsRunning && InvalidItems.IsEnabled)
            {
                InvalidItems.Load();
            }
            if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled)
            {
                HighPingKicker.Unload();
            }
            if (!HighPingKicker.IsRunning && HighPingKicker.IsEnabled)
            {
                HighPingKicker.Load();
            }
            if (CredentialCheck.IsRunning && !CredentialCheck.IsEnabled)
            {
                CredentialCheck.Unload();
            }
            if (!CredentialCheck.IsRunning && CredentialCheck.IsEnabled)
            {
                CredentialCheck.Load();
            }
            if (CustomCommands.IsRunning && !CustomCommands.IsEnabled)
            {
                CustomCommands.Unload();
            }
            if (!CustomCommands.IsRunning && CustomCommands.IsEnabled)
            {
                CustomCommands.Load();
            }
            if (DupeLog.IsRunning && !DupeLog.IsEnabled)
            {
                DupeLog.Unload();
            }
            if (!DupeLog.IsRunning && DupeLog.IsEnabled)
            {
                DupeLog.Load();
            }
            if (ChatColorPrefix.IsRunning && !ChatColorPrefix.IsEnabled)
            {
                ChatColorPrefix.Unload();
            }
            if (!ChatColorPrefix.IsRunning && ChatColorPrefix.IsEnabled)
            {
                ChatColorPrefix.Load();
            }
            if (KillNotice.IsRunning && !KillNotice.IsEnabled)
            {
                KillNotice.Unload();
            }
            if (!KillNotice.IsRunning && KillNotice.IsEnabled)
            {
                KillNotice.Load();
            }
            if (Prayer.IsRunning && !Prayer.IsEnabled)
            {
                Prayer.Unload();
            }
            if (!Prayer.IsRunning && Prayer.IsEnabled)
            {
                Prayer.Load();
            }
            if (BloodmoonWarrior.IsRunning && !BloodmoonWarrior.IsEnabled)
            {
                BloodmoonWarrior.Unload();
            }
            if (!BloodmoonWarrior.IsRunning && BloodmoonWarrior.IsEnabled)
            {
                BloodmoonWarrior.Load();
            }
            if (ProtectedSpaces.IsRunning && !ProtectedSpaces.IsEnabled)
            {
                ProtectedSpaces.Unload();
            }
            if (!ProtectedSpaces.IsRunning && ProtectedSpaces.IsEnabled)
            {
                ProtectedSpaces.Load();
            }
            if (ClanManager.IsEnabled)
            {
                ClanManager.ClanList();
            }
            if (AuctionBox.IsEnabled)
            {
                AuctionBox.AuctionList();
            }
            if (Mute.IsEnabled)
            {
                Mute.ClientMuteList();
                Mute.MuteList();
            }
            if (Jail.IsEnabled)
            {
                Jail.JailList();
            }
            //always load the website last
            if (WebsiteServer.IsEnabled && !WebsiteServer.DirFound)
            {
                WebsiteServer.CheckDir();
            }
            if (WebsiteServer.IsRunning && !WebsiteServer.IsEnabled)
            {
                WebsiteServer.Unload();
            }
            if (!WebsiteServer.IsRunning && WebsiteServer.IsEnabled && WebsiteServer.DirFound)
            {
                WebsiteServer.Load();
            }
        }