Exemplo n.º 1
0
        public static void Try(string[] parameters)
        {
            string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Message.Send = "MSG:" + parameters[1] + ":0:Biller version: Sius " + version;
            SiusLog.Log(SiusLog.INFORMATION, "?bversion", "Sent biller version to " + Player.GetPlayerName(parameters[1]));
        }
Exemplo n.º 2
0
        //RMTSQD:pid:destsquad:sound:text
        public static void Try(string[] parameters)
        {
            if (string.IsNullOrEmpty(parameters[4]) || string.IsNullOrEmpty(parameters[2]))
            {
                return;
            }

            string squad   = parameters[2].ToLower();
            string name    = Player.GetPlayerName(parameters[1]);
            string message = SiusUtil.Collate(4, parameters);

            if (SiusConf.GetSetting.Boolean("squadonlychat"))
            {
                //player is sending a squad message to a different squad
                if (Player.GetSquad(parameters[1]).ToLower() != squad)
                {
                    SiusLog.Log(SiusLog.WARNING, "squad", name
                                + " tried to send a message to a different squad (refer to settings - squadonlychat).");
                    return;
                }
            }

            //It's easier to blindly send the message
            //RMTSQD:destsquad:sender:sound:text
            Zone.BroadcastMessage("RMTSQD:" + squad + ":" + name + ":" + parameters[3] + ":" + message);

            SiusLog.Log(SiusLog.INFORMATION, "squad", name + " sent squad message to " + squad);
            SiusLog.Log(SiusLog.DEBUG, "squad", "Message: " + message);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send the player his squad list.
        /// </summary>
        /// <param name="chats"></param>
        private static void SendSquadList(string[] list, string[] parameters)
        {
            TcpClient tcpZone = (TcpClient)Listen.htRcon[Zone.ZoneName];

            try
            {
                StreamWriter sw = new StreamWriter(tcpZone.GetStream());

                string message = "";

                for (int i = 0; i < list.Length; i++)
                {
                    if (message.Length < 230)
                    {
                        message += list[i] + ", ";
                    }
                    else
                    {
                        sw.WriteLine("MSG:" + parameters[1] + ":0:Members: " + message);
                        message = "";
                    }
                }

                sw.Flush();
                sw = null;
            }
            catch (Exception e)
            {
                SiusLog.Log(SiusLog.DEBUG, "squadlist", e.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Send the biller greeting message to the player.
        /// </summary>
        private static void SendGreeting(string[] parameters)
        {
            string greeting = SiusConf.GetSetting.String("greeting");

            if (String.IsNullOrEmpty(greeting))
            {
                return;
            }

            //MSG:pid:sound:text
            TcpClient tcpZone = (TcpClient)Listen.htRcon[Zone.ZoneName];

            try
            {
                StreamWriter swSenderSender;
                swSenderSender = new StreamWriter(tcpZone.GetStream());
                swSenderSender.WriteLine("MSG:" + parameters[1] + ":" +
                                         SiusConf.GetSetting.String("greetsound") + ":" + greeting);
                swSenderSender.Flush();
                swSenderSender = null;
            }
            catch (Exception e)
            {
                SiusLog.Log(SiusLog.DEBUG, "greet", e.Message);
            }
            return;
        }
Exemplo n.º 5
0
        public static void Try(string[] parameters)
        {
            //RMT:pid:destination:sound:text
            string sender  = Player.GetPlayerName(parameters[1]);
            string message = SiusUtil.Collate(4, parameters);

            for (int i = 0; i < Player.PlayerList.Count; i++)
            {
                Player.PlayerStruct p = (Player.PlayerStruct)Player.PlayerList[i];
                if (p.name == parameters[2])
                {
                    try
                    {
                        TcpClient    tcpZone = (TcpClient)Listen.htRcon[p.ZoneName];
                        StreamWriter swSenderSender;
                        swSenderSender = new StreamWriter(tcpZone.GetStream());
                        //RMT:pid:sender:sound:text
                        swSenderSender.WriteLine("RMT:" + p.pid + ":" + sender + ":" +
                                                 parameters[3] + ":" + message);
                        swSenderSender.Flush();
                        swSenderSender = null;
                    }
                    catch (Exception e)
                    {
                        SiusLog.Log(SiusLog.DEBUG, "remote", e.Message);
                    }
                    SiusLog.Log(SiusLog.INFORMATION, "remote", sender + " sent remote message to " + parameters[2]);
                    SiusLog.Log(SiusLog.DEBUG, "remote", "Message: " + message);
                    return;
                }
            }
            Message.Send = "MSG:" + parameters[1] + ":0:Unable to locate player.";
            SiusLog.Log(SiusLog.DEBUG, "remote", "Unable to locate and send remote message from " + sender + " to " + parameters[2]);
            SiusLog.Log(SiusLog.DEBUG, "remote", "Message: " + message);
        }
Exemplo n.º 6
0
        public static void Try(string[] parameters)
        {
            Message.Send = "MSG:" + parameters[1] + ":0:Current biller date and time: " +
                           System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " (UTC: " +
                           System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + ")";

            SiusLog.Log(SiusLog.INFORMATION, "?btime", "Sent biller local date and time to " + Player.GetPlayerName(parameters[1]));
        }
Exemplo n.º 7
0
        public static void Try(string[] parameters)
        {
            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);
            if (!string.IsNullOrEmpty(p.Squad) && !string.IsNullOrEmpty(parameters[3]) && p.name.ToLower() != parameters[3].ToLower())
            {
                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT owner FROM squads WHERE name = @nsquad";
                SQLiteParameter nsquad = new SQLiteParameter("@nsquad");
                SQLiteParameter pname  = new SQLiteParameter("@pname");
                cmd.Parameters.Add(nsquad);
                cmd.Parameters.Add(pname);
                nsquad.Value = p.Squad;
                pname.Value  = p.name;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0][0].ToString().ToLower() == p.name.ToLower())
                    {
                        /* Begin Database Connection */
                        SConnection.Open();
                        cmd.CommandText = @"UPDATE players SET squad = '' WHERE name = @kname AND squad = @nsquad";
                        SQLiteParameter kname = new SQLiteParameter("@kname");
                        cmd.Parameters.Add(kname);
                        kname.Value = parameters[3];
                        cmd.ExecuteNonQuery();
                        SConnection.Close();
                        /* End Database Connection */

                        //TODO: do we send the kicked player a message?
                        Message.Send = "MSG:" + parameters[1] + ":0:If said player was a member of your squad, he or she has been kicked.";
                        SiusLog.Log(SiusLog.INFORMATION, "?squadkick", p.name + " kicked " + parameters[3] + " from squad <" + p.Squad + ">.");
                    }
                    else
                    {
                        Message.Send = "MSG:" + parameters[1] + ":0:You do not own this squad.";
                        SiusLog.Log(SiusLog.INFORMATION, "?squadkick", p.name + " attempted to kick " + parameters[3] + " from squad <"
                                    + p.Squad + ">, but is not owner.");
                        return;
                    }
                }
            }
        }
Exemplo n.º 8
0
        public static void Try(string[] parameters)
        {
            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);
            if (!string.IsNullOrEmpty(p.Squad))
            {
                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT owner FROM squads WHERE name = @nsquad";
                SQLiteParameter nsquad = new SQLiteParameter("@nsquad");
                SQLiteParameter pname  = new SQLiteParameter("@pname");
                cmd.Parameters.Add(nsquad);
                cmd.Parameters.Add(pname);
                nsquad.Value = p.Squad;
                pname.Value  = p.name;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0][0].ToString().ToLower() == p.name.ToLower())
                    {
                        /* Begin Database Connection */
                        SConnection.Open();
                        cmd.CommandText = @"DELETE FROM squads WHERE name = @nsquad AND owner = @pname";
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = @"UPDATE players SET squad = '' WHERE squad = @nsquad";
                        cmd.ExecuteNonQuery();
                        SConnection.Close();
                        /* End Database Connection */

                        Message.Send = "MSG:" + parameters[1] + ":0:Squad dissolved.";
                        SiusLog.Log(SiusLog.DEBUG, "?squaddissolve", "Dissolved squad <" + p.Squad
                                    + "> for " + p.name);
                    }
                    else
                    {
                        Message.Send = "MSG:" + parameters[1] + ":0:You do not own this squad.";
                        SiusLog.Log(SiusLog.DEBUG, "?squaddissolve", "Unable to dissolve squad <" + p.Squad
                                    + "> for " + p.name + " (not owner).");
                        return;
                    }
                }
            }
        }
Exemplo n.º 9
0
        public static void Try(string[] parameters)
        {
            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);
            if (!string.IsNullOrEmpty(p.Squad))
            {
                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT name FROM players WHERE squad = @nsquad";
                SQLiteParameter nsquad = new SQLiteParameter("@nsquad");
                cmd.Parameters.Add(nsquad);
                nsquad.Value = p.Squad;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    string list = "";
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        list += dt.Rows[i][0].ToString();
                        if ((i + 1) < dt.Rows.Count)
                        {
                            list += ", ";
                        }
                    }

                    string message = "MSG:" + parameters[1] + ":0:Members: " + list;

                    if (message.Length >= 250)
                    {
                        SendSquadList(list.Split(", ".ToCharArray()), parameters);
                    }
                    else
                    {
                        Message.Send = message;
                    }

                    SiusLog.Log(SiusLog.INFORMATION, "?squadlist", p.name + " requested <" + p.Squad + ">'s member list.");
                }
                else
                {
                    SiusLog.Log(SiusLog.WARNING, "?squadlist", "An error occured while trying to locate " + p.name + "'s squad member list.");
                }
            }
        }
Exemplo n.º 10
0
        public static void Try(string[] parameters)
        {
            if (!string.IsNullOrEmpty(parameters[3]))
            {
                string name     = Player.GetPlayerName(parameters[1]);
                string password = SiusUtil.Collate(3, parameters);

                if (password.Contains(":"))
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:Your password may not contain colons.";
                    SiusLog.Log(SiusLog.DEBUG, "password", "Unable to change [" + name + "]'s password. Password contains a colon.");
                    return;
                }

                //Check the password length
                if (password.Length < 1 || password.Length > 23)
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:The length of you password is invalid.";
                    SiusLog.Log(SiusLog.DEBUG, "password", "Unable to change [" + name + "]'s password. Password length is invalid.");
                    return;
                }

                password = SiusEncrypt.Encrypt(password, name, "players");

                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"UPDATE 'players' SET password = @ppassword WHERE name = @pname";
                SQLiteParameter ppassword = new SQLiteParameter("@ppassword");
                SQLiteParameter pname     = new SQLiteParameter("@pname");
                cmd.Parameters.Add(ppassword);
                cmd.Parameters.Add(pname);
                ppassword.Value = password;
                pname.Value     = name;

                cmd.ExecuteNonQuery();

                SConnection.Close();
                SConnection.Dispose();
                /* End Database Connection */

                Message.Send = "MSG:" + parameters[1] + ":0:Your password has been successfully changed.";
                SiusLog.Log(SiusLog.INFORMATION, "?password", "Successfully changed " + name + "'s password.");
                SiusLog.Log(SiusLog.DEBUG, "password", "Player [" + name + "] changed password to: " + password);
            }
        }
Exemplo n.º 11
0
        public static void Try(string[] parameters)
        {
            DateTime Current = DateTime.Now;
            TimeSpan diff    = Current.Subtract(Sius.Time);

            Message.Send = "MSG:" + parameters[1] + ":0:Biller Uptime: " +
                           diff.Seconds.ToString() + (diff.Seconds == 1 ? " second " : " seconds ") +
                           diff.Minutes.ToString() + (diff.Minutes == 1 ? " minute " : " minutes ") +
                           diff.Hours.ToString() + (diff.Hours == 1 ? " hour " : " hours ") +
                           diff.Days.ToString() + (diff.Days == 1 ? " day" : " days");

            SiusLog.Log(SiusLog.INFORMATION, "?buptime", "Sent biller uptime to " + Player.GetPlayerName(parameters[1]));
        }
Exemplo n.º 12
0
        public static void Try(string[] parameters)
        {
            //PENTERARENA:pid

            string pname = Player.GetPlayerName(parameters[1]);

            if (!String.IsNullOrEmpty(pname))
            {
                /*string banner = SQLite.GetQuery("SELECT banner FROM 'banners' WHERE name = '" +
                 *                              pname + "';");*/

                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT banner FROM 'banners' WHERE name = @apname";
                SQLiteParameter apname = new SQLiteParameter("@apname");
                cmd.Parameters.Add(apname);
                apname.Value = pname;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                SConnection.Dispose();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    SendGreeting(parameters);
                    CheckMessages(parameters);
                    Message.Send = "BNR:" + parameters[1] + ":" + dt.Rows[0][0].ToString();
                    SiusLog.Log(SiusLog.INFORMATION, "arena", "(" + Zone.ZoneName + ") " + pname + " entered arena. Sent greeting, banner, and checked messages.");

                    return;
                }
                SiusLog.Log(SiusLog.DEBUG, "arena", "Unable to retrieve " + pname + "'s banner information from database.");
            }

            SendGreeting(parameters);
            CheckMessages(parameters);
            SiusLog.Log(SiusLog.INFORMATION, "arena", "(" + Zone.ZoneName + ") " + pname + " entered arena. Sent greeting and checked messages.");
            return;
        }
Exemplo n.º 13
0
        /// <summary>
        /// When a player logs in, check if he has any new messages unread.
        /// </summary>
        private static void CheckMessages(string[] parameters)
        {
            /*System.Data.DataTable result = SQLite.GetMultiQuery("SELECT * FROM 'messages'" +
             *                                                  "WHERE name = '" + name + "';");*/

            /* Begin Database Connection */
            DataTable dt = new DataTable();

            SQLiteConnection SConnection = new SQLiteConnection();

            SConnection.ConnectionString = SQLite.ConnectionString;
            SConnection.Open();

            SQLiteCommand cmd = new SQLiteCommand(SConnection);

            cmd.CommandText = @"SELECT * FROM 'messages' WHERE name = @pname";
            SQLiteParameter pname = new SQLiteParameter("@pname");

            cmd.Parameters.Add(pname);
            pname.Value = Player.GetPlayerName(parameters[1]);

            SQLiteDataReader Reader = cmd.ExecuteReader();

            dt.Load(Reader);
            Reader.Close();

            SConnection.Close();
            SConnection.Dispose();
            /* End Database Connection */

            if (dt.Rows.Count != 0)
            {
                TcpClient tcpZone = (TcpClient)Listen.htRcon[Zone.ZoneName];
                try
                {
                    StreamWriter swSenderSender;
                    swSenderSender = new StreamWriter(tcpZone.GetStream());
                    swSenderSender.WriteLine("MSG:" + parameters[1] + ":0:You have " +
                                             dt.Rows.Count.ToString() + " new messages. " +
                                             "Type ?messages to read them.");
                    swSenderSender.Flush();
                    swSenderSender = null;
                }
                catch (Exception e)
                {
                    SiusLog.Log(SiusLog.DEBUG, "CheckMessages", e.Message);
                }
            }
        }
Exemplo n.º 14
0
        public static void Try(string[] parameters)
        {
            string name = Player.GetPlayerName(parameters[1]);

            if (string.IsNullOrEmpty(parameters[3]))             //display self squad
            {
                string squad = Player.GetPlayer(parameters[1]).Squad;
                if (string.IsNullOrEmpty(squad))
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:You are not currently on any squad.";
                }
                else
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:Squad: " + squad;
                }

                SiusLog.Log(SiusLog.INFORMATION, "?squad", "Sent " + name + " his or her squad name.");
            }
            else             //display other person's squad
            {
                string squad = Player.GetSquad(parameters[3]);
                if (!string.IsNullOrEmpty(squad))
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:Squad: " + squad;
                    SiusLog.Log(SiusLog.DEBUG, "?squad", "Sent <" + name + "> " + parameters[3]
                                + "'s squad name (" + squad + ").");
                }
                else
                {
                    if (Player.Exists(parameters[3]))
                    {
                        Message.Send = "MSG:" + parameters[1] + ":0:This player is not on any squads.";
                    }
                    else
                    {
                        Message.Send = "MSG:" + parameters[1] + ":0:Unknown player";
                    }

                    SiusLog.Log(SiusLog.DEBUG, "?squad", "Attempted to send <" + name + "> " + parameters[3]
                                + "'s squad name, but this player either doesn't exist or is not currently on any squads.");
                }
            }
        }
Exemplo n.º 15
0
        public static void Try(string[] parameters)
        {
            string name = Player.GetPlayerName(parameters[1]);

            /* Begin Database Connection */
            DataTable dt = new DataTable();

            SQLiteConnection SConnection = new SQLiteConnection();

            SConnection.ConnectionString = SQLite.ConnectionString;
            SConnection.Open();

            SQLiteCommand cmd = new SQLiteCommand(SConnection);

            cmd.CommandText = @"SELECT id FROM 'players' WHERE name = @pname";
            SQLiteParameter pname = new SQLiteParameter("@pname");

            cmd.Parameters.Add(pname);
            pname.Value = name;

            SQLiteDataReader Reader = cmd.ExecuteReader();

            dt.Load(Reader);
            Reader.Close();

            SConnection.Close();
            SConnection.Dispose();
            /* End Database Connection */

            if (dt.Rows.Count > 0)
            {
                string userid = dt.Rows[0][0].ToString();
                Message.Send = "MSG:" + parameters[1] + ":0:UserID: " + userid;
                SiusLog.Log(SiusLog.INFORMATION, "?userid", "Player [" + name + "] requested userid: " + userid);
            }
            else
            {
                Message.Send = "MSG:" + parameters[1] + ":0:An error occured while trying to retrieve your userid.";
                SiusLog.Log(SiusLog.DEBUG, "?userid", "An error occured while trying to retrieve " + name + "'s userid");
            }
        }
Exemplo n.º 16
0
        public static void Try(string[] parameters)
        {
            string zones = "";

            string[] ZoneList = new string[Listen.htZones.Count];
            Listen.htZones.Values.CopyTo(ZoneList, 0);

            for (int i = 0; i < ZoneList.Length; i++)
            {
                if (zones == "")
                {
                    zones += ZoneList[i].ToString() + " (" + Zone.PidToName.Count.ToString() + ")";
                }
                else
                {
                    zones += ", " + ZoneList[i].ToString() + " (" + Zone.PidToName.Count.ToString() + ")";
                }
            }

            Message.Send = "MSG:" + parameters[1] + ":0:" + zones;
            SiusLog.Log(SiusLog.INFORMATION, "?bzones", "Sent network zone list to " + Player.GetPlayerName(parameters[1]));
        }
Exemplo n.º 17
0
 public static void Try(string[] parameters)
 {
     if (string.IsNullOrEmpty(parameters[3]))
     {
         string[] chats = Player.GetPlayerChat(parameters[1]);
         if (chats != null)
         {
             SendChatList(chats, parameters);
             SiusLog.Log(SiusLog.INFORMATION, "?chat", "Retrieved " + Player.GetPlayerName(parameters[1]) + "'s chat list.");
             return;
         }
         else
         {
             Message.Send = "MSG:" + parameters[1] + ":0:Empty.";
         }
     }
     else
     {
         Player.SetPlayerChat(parameters[1], SiusUtil.Collate(3, parameters));
         SiusLog.Log(SiusLog.INFORMATION, "?chat", "Set " + Player.GetPlayerName(parameters[1]) + "'s chat list.");
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// Send the player his chatlist.
        /// </summary>
        /// <param name="chats"></param>
        private static void SendChatList(string[] chats, string[] parameters)
        {
            TcpClient tcpZone = (TcpClient)Listen.htRcon[Zone.ZoneName];

            try
            {
                StreamWriter sw = new StreamWriter(tcpZone.GetStream());

                for (int i = 0; i < chats.Length; i++)
                {
                    sw.WriteLine("MSG:" + parameters[1] + ":0:" +
                                 chats[i] + ": " + Player.GetChannelList(chats[i]));
                }

                sw.Flush();
                sw = null;
            }
            catch (Exception e)
            {
                SiusLog.Log(SiusLog.DEBUG, "chatlist", e.Message);
            }
        }
Exemplo n.º 19
0
        public static void Try(string[] parameters)
        {
            if (!string.IsNullOrEmpty(parameters[3]))
            {
                /*Message.Send = "MSG:" + parameters[1] + ":0:Owner is " +
                 *      SQLite.GetQuery("SELECT owner FROM 'squads' WHERE name = '" +
                 *                      parameters[3] + "';");*/

                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT owner FROM 'squads' WHERE name = @pname";
                SQLiteParameter pname = new SQLiteParameter("@pname");
                cmd.Parameters.Add(pname);
                pname.Value = parameters[3];

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:Owner is " + dt.Rows[0][0].ToString();
                    SiusLog.Log(SiusLog.INFORMATION, "?squadowner", Player.GetPlayerName(parameters[1])
                                + " requested the squad owner of " + parameters[3]);
                }
            }
        }
Exemplo n.º 20
0
        public static void Try(string[] parameters)
        {
            if (!String.IsNullOrEmpty(parameters[2]))
            {
                /*SQLite.SendQuery("INSERT OR REPLACE INTO 'banners' (name,banner) values ('" +
                 *               pname + "','" +
                 *               parameters[2] + "');");*/

                string name = Player.GetPlayerName(parameters[1]);

                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"INSERT OR REPLACE INTO 'banners' (name,banner)" +
                                  " values (@pname,@banner)";
                SQLiteParameter pname  = new SQLiteParameter("@pname");
                SQLiteParameter banner = new SQLiteParameter("@banner");
                cmd.Parameters.Add(pname);
                cmd.Parameters.Add(banner);
                pname.Value  = name;
                banner.Value = parameters[2];

                cmd.ExecuteNonQuery();

                SConnection.Close();
                SConnection.Dispose();
                /* End Database Connection */

                SiusLog.Log(SiusLog.INFORMATION, "banner", "Stored " + name + "'s banner into database.");
            }
        }
Exemplo n.º 21
0
 public static void Try(string[] parameters)
 {
     Message.Send = "MSG:" + parameters[1] + ":0:Zone: " + Zone.ZoneName;
     SiusLog.Log(SiusLog.INFORMATION, "?bzone", "Sent network zone name to " + Player.GetPlayerName(parameters[1]));
 }
Exemplo n.º 22
0
        public static void Try(string[] parameters)
        {
            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);
            if (!string.IsNullOrEmpty(p.Squad))
            {
                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT owner FROM squads WHERE name = @nsquad";
                SQLiteParameter nsquad = new SQLiteParameter("@nsquad");
                SQLiteParameter pname  = new SQLiteParameter("@pname");
                cmd.Parameters.Add(nsquad);
                cmd.Parameters.Add(pname);
                nsquad.Value = p.Squad;
                pname.Value  = p.name;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0][0].ToString().ToLower() == p.name.ToLower())                     //if owner
                    {
                        string password = SiusUtil.Collate(3, parameters);
                        if (string.IsNullOrEmpty(password))
                        {
                            Message.Send = "MSG:" + parameters[1] + ":0:Please specify a password.";
                            return;
                        }
                        if (password.Length > 23)
                        {
                            Message.Send = "MSG:" + parameters[1] + ":0:Password is too long.";
                            return;
                        }

                        password = SiusEncrypt.Encrypt(password, p.Squad, "squads");

                        /* Begin Database Connection */
                        SConnection.Open();
                        cmd.CommandText = @"UPDATE squads SET password = @spass WHERE name = @nsquad";
                        SQLiteParameter spass = new SQLiteParameter("@spass");
                        cmd.Parameters.Add(spass);
                        spass.Value = password;
                        cmd.ExecuteNonQuery();
                        SConnection.Close();
                        /* End Database Connection */

                        Message.Send = "MSG:" + parameters[1] + ":0:Squad password successfully changed.";
                        SiusLog.Log(SiusLog.INFORMATION, "?squadpassword", p.name + " successfully changed the password to squad <" + p.Squad + ">");
                        return;
                    }
                    else
                    {
                        Message.Send = "MSG:" + parameters[1] + ":0:You do not own this squad.";
                        SiusLog.Log(SiusLog.INFORMATION, "?squadpassword", p.name + " attempted to change the password of <"
                                    + p.Squad + ">, but is not owner.");
                        return;
                    }
                }
            }
            Message.Send = "MSG:" + parameters[1] + ":0:You are not on a squad.";
        }
Exemplo n.º 23
0
        public static void Try(string[] parameters)
        {
            //CHAT:pid:channel:sound:text

            string sender  = "";            // the name of the sender
            string channel = "";            // the name of the chat channel

            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);

            // Check if the player is sending to a valid channel
            if (p.Chat != null)
            {
                sender = p.name;
                int num;
                try
                {
                    num = Convert.ToInt32(parameters[2]);
                }
                catch
                {
                    num = 0;
                }

                if (num < p.Chat.Length)
                {
                    channel = p.Chat[num];
                }
                else
                {
                    return;
                }
            }

            if (string.IsNullOrEmpty(channel) || string.IsNullOrEmpty(sender))
            {
                return;
            }

            // Send the message to every player on that chat
            for (int i = 0; i < Player.PlayerList.Count; i++)
            {
                Player.PlayerStruct pp = (Player.PlayerStruct)Player.PlayerList[i];

                if (SiusUtil.StringInArray(channel, pp.Chat) && pp.name != sender)
                {
                    try
                    {
                        TcpClient tcpZone = (TcpClient)Listen.htRcon[pp.ZoneName];

                        StreamWriter swSenderSender;
                        swSenderSender = new StreamWriter(tcpZone.GetStream());
                        //CHATTXT:channel:sender:sound:text
                        //CHAT:pid:number
                        swSenderSender.WriteLine("CHATTXT:" + channel + ":" + sender + ":" +
                                                 parameters[3] + ":" + SiusUtil.Collate(4, parameters));
                        if (pp.ZoneSW == "asss 1.4.3" || pp.ZoneSW == "asss 1.4.2")                         // Older versions are broken.
                        {
                            swSenderSender.WriteLine("CHAT:" + pp.pid + ":" + Array.IndexOf(pp.Chat, channel).ToString() + ":");
                        }
                        else
                        {
                            swSenderSender.WriteLine("CHAT:" + pp.pid + ":" + Array.IndexOf(pp.Chat, channel).ToString());
                        }
                        swSenderSender.Flush();
                        swSenderSender = null;
                    }
                    catch (Exception e)
                    {
                        SiusLog.Log(SiusLog.DEBUG, "chat", e.Message);
                    }
                }
            }
            SiusLog.Log(SiusLog.INFORMATION, "chat", sender + " to " + channel + ": " + SiusUtil.Collate(4, parameters));
            return;
        }
Exemplo n.º 24
0
        public static void Try(string[] parameters)
        {
            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);
            if (!string.IsNullOrEmpty(p.Squad))
            {
                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT owner FROM squads WHERE name = @nsquad";
                SQLiteParameter nsquad = new SQLiteParameter("@nsquad");
                SQLiteParameter pname  = new SQLiteParameter("@pname");
                cmd.Parameters.Add(nsquad);
                cmd.Parameters.Add(pname);
                nsquad.Value = p.Squad;
                pname.Value  = p.name;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                if (dt.Rows.Count > 0)
                {
                    DataTable others = new DataTable();
                    SConnection.Open();
                    cmd.CommandText = @"SELECT * FROM players WHERE squad = @nsquad";

                    SQLiteDataReader Reade = cmd.ExecuteReader();
                    others.Load(Reade);
                    Reade.Close();
                    SConnection.Close();

                    if (others.Rows.Count > 1)                                      //there are others on this squad
                    {
                        if (dt.Rows[0][0].ToString().ToLower() == p.name.ToLower()) //is owner
                        {
                            Message.Send = "MSG:" + parameters[1] + ":0:Unable to remove you from squad. Consider transfering ownership"
                                           + " to someone else (?squadgrant <name>), or dissolving this squad (?squaddissolve).";

                            SiusLog.Log(SiusLog.INFORMATION, "?squadleave", "Unable to remove " + p.name + " from squad <" + p.Squad + "> due to ownership.");
                            return;

                            //cmd.CommandText = @"UPDATE squads SET owner = '**UNKNOWN**' WHERE name = @nsquad"; //TODO: Should we allow him to squadleave?
                            //cmd.ExecuteNonQuery();
                        }
                        SConnection.Open();
                        cmd.CommandText = @"UPDATE players SET squad = '' WHERE name = @pname";
                        cmd.ExecuteNonQuery();
                        SConnection.Close();

                        Message.Send = "MSG:" + parameters[1] + ":0:Left squad. Please exit the zone for the changes to take effect.";
                        SiusLog.Log(SiusLog.INFORMATION, "?squadleave", p.name + " left squad <" + p.Squad + ">");
                    }
                    else                     //player is lone on squad
                    {
                        SConnection.Open();
                        cmd.CommandText = @"DELETE FROM squads WHERE name = @nsquad";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = @"UPDATE players SET squad = '' WHERE name = @pname";
                        cmd.ExecuteNonQuery();
                        SConnection.Close();

                        Message.Send = "MSG:" + parameters[1] + ":0:Left squad. Please exit the zone for the changes to take effect.";
                        SiusLog.Log(SiusLog.INFORMATION, "?squadleave", p.name + " left squad <" + p.Squad + ">");
                        SiusLog.Log(SiusLog.DEBUG, "?squadleave", "Deleted squad from database: no other players.");
                    }
                    SConnection.Dispose();
                    return;
                }
                else
                {
                    //squad doesn't exist? no owner? Remove player from squad only.
                    SiusLog.Log(SiusLog.WARNING, "squad", "Unable to locate the squad <" + p.Squad + "> in database.");

                    SConnection.Open();
                    cmd.CommandText = @"UPDATE players SET squad = '' WHERE name = @pname";
                    cmd.ExecuteNonQuery();
                    SConnection.Close();
                    SConnection.Dispose();

                    Message.Send = "MSG:" + parameters[1] + ":0:Left squad. Please exit the zone for the changes to take effect.";
                    SiusLog.Log(SiusLog.INFORMATION, "?squadleave", p.name + " left squad <" + p.Squad + ">");

                    return;
                }
            }
        }
Exemplo n.º 25
0
        public static void Try(string[] parameters)
        {
            //CMD:pid:cmdname:args
            string command = parameters[2].ToLower();

            //TODO: Check permission
            SiusLog.Log(SiusLog.DEBUG, "command", "Received: ?" + command);

            if (command == "chat")
            {
                Commands.Chat.Try(parameters);
            }
            else if (command == "find")
            {
                Commands.Find.Try(parameters);
            }
            else if (command == "squad")
            {
                Commands.Squad.Try(parameters);
            }
            else if (command == "squadowner")
            {
                Commands.Squadowner.Try(parameters);
            }
            else if (command == "squadlist")
            {
                Commands.Squadlist.Try(parameters);
            }
            else if (command == "squadcreate")
            {
                Commands.Squadcreate.Try(parameters);
            }
            else if (command == "squadleave")
            {
                Commands.Squadleave.Try(parameters);
            }
            else if (command == "squadjoin")
            {
                Commands.Squadjoin.Try(parameters);
            }
            else if (command == "squadkick")
            {
                Commands.Squadkick.Try(parameters);
            }
            else if (command == "password")
            {
                Commands.Password.Try(parameters);
            }
            else if (command == "message" || command == "messages")
            {
                Commands.Messages.Try(parameters);
            }
            else if (command == "bzones" || command == "zones")
            {
                Commands.Bzones.Try(parameters);
            }
            else if (command == "bzone")
            {
                Commands.Bzone.Try(parameters);
            }
            else if (command == "userid")
            {
                Commands.UserID.Try(parameters);
            }
            else if (command == "squadpassword")
            {
                Commands.Squadpassword.Try(parameters);
            }
            else if (command == "btime")
            {
                Commands.Btime.Try(parameters);
            }
            else if (command == "buptime")
            {
                Commands.Buptime.Try(parameters);
            }
            else if (command == "bversion")
            {
                Commands.Bversion.Try(parameters);
            }
            else if (command == "squaddissolve")
            {
                Commands.Squaddissolve.Try(parameters);
            }
            else if (command == "squadgrant")
            {
                Commands.Squadgrant.Try(parameters);
            }
        }
Exemplo n.º 26
0
        public static void Try(string[] parameters)
        {
            if (!string.IsNullOrEmpty(parameters[3]))
            {
                string squad    = parameters[3];
                string password = SiusUtil.Collate(4, parameters);
                string name     = Player.GetPlayerName(parameters[1]);

                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT * FROM squads WHERE name = @nsquad";
                SQLiteParameter nsquad = new SQLiteParameter("@nsquad");
                cmd.Parameters.Add(nsquad);
                nsquad.Value = squad;

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                //The squad exists
                if (dt.Rows.Count > 0)
                {
                    Message.Send = "MSG:" + parameters[1] + ":0:Sorry, this squad already exists.";
                    SiusLog.Log(SiusLog.DEBUG, "?squadcreate", "Unable to create squad <" + squad + "> for " + name
                                + ", but squad already exists.");
                    SConnection.Dispose();
                    return;
                }
                else
                {
                    SConnection.Open();

                    cmd.CommandText = @"INSERT INTO squads (name, owner, lastact) values (@nsquad, @pname, @last)";
                    SQLiteParameter last  = new SQLiteParameter("@last");
                    SQLiteParameter pname = new SQLiteParameter("@pname");
                    cmd.Parameters.Add(last);
                    cmd.Parameters.Add(pname);
                    last.Value  = System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
                    pname.Value = name;
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = @"UPDATE squads SET password = @spass WHERE name = @nsquad";
                    SQLiteParameter spass = new SQLiteParameter("@spass");
                    cmd.Parameters.Add(spass);
                    spass.Value = SiusEncrypt.Encrypt(password, squad, "squads");
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = @"UPDATE players SET squad = @nsquad WHERE name = @pname";
                    cmd.ExecuteNonQuery();

                    SConnection.Close();
                    SConnection.Dispose();

                    Message.Send = "MSG:" + parameters[1] + ":0:Squad successfully created. Please exit"
                                   + " your current zone and log back in for the change to take effect.";

                    SiusLog.Log(SiusLog.INFORMATION, "?squadcreate", "Successfully created squad <" + squad + "> for " + name);
                    return;
                }
            }
        }
Exemplo n.º 27
0
        public static string Try(string message)
        {
            // CONNECT:version:swname:zonename:hostname:password
            string[] parameters = message.Split(':');

            string protocol = SiusConf.GetSetting.String("protocol");
            string server   = SiusConf.GetSetting.String("server");

            string[] _protocol = protocol.Split(',');
            string[] _server   = server.Split(',');

            Zone.ZoneName = parameters[3];
            Zone.Software = parameters[2];

            // Check if the number of parameters expected is different (e.g. zone name containing ':')
            if (parameters.Length != 6)
            {
                message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":Invalid connection protocol.";
                SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: Invalid connection protocol.");
                return(message);
            }

            // Check if the server is using the appropriate protocol
            if ((!SiusUtil.StringInArray(parameters[1], _protocol)) && (!string.IsNullOrEmpty(protocol)))
            {
                message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":Invalid protocol version.";
                SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: Unrecognized protocol version.");
                return(message);
            }

            // Check if the server is using a recognized type
            if ((!SiusUtil.StringInArray(parameters[2], _server)) && (!string.IsNullOrEmpty(server)))
            {
                message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":Invalid server version.";
                SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: Invalid server version.");
                return(message);
            }

            // Check if there are too many zones connected.
            if (!string.IsNullOrEmpty(SiusConf.GetSetting.String("maxzones")))
            {
                if (Listen.htZones.Count >= SiusConf.GetSetting.Integer("maxzones"))
                {
                    message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":There are too many zones currently connected.";
                    SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: There are too many zones currently connected.");
                    return(message);
                }
            }

            // Verify the password
            if (!string.IsNullOrEmpty(SiusConf.GetSetting.String("password")))
            {
                if (parameters[5] != SiusConf.GetSetting.String("password"))
                {
                    message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":Authentication failed: Invalid Password.";
                    SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: Invalid Password.");
                    return(message);
                }
            }

            // Check if the zone contains the illegal character ',' or if it's empty
            if (Zone.ZoneName.Contains(",") || string.IsNullOrEmpty(Zone.ZoneName))
            {
                message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":The selected zone name is not valid.";
                SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: The selected zone name is not valid.");
                return(message);
            }

            // Check if a zone with this name already exists
            if (Listen.htRcon.Contains(Zone.ZoneName))
            {
                message = "CONNECTBAD:Sius:" + SiusConf.GetSetting.String("network") + ":A zone with this name already exists.";
                SiusLog.Log(SiusLog.WARNING, "connect", Zone.ZoneName + " failed to connect: a zone with this name already exists.");
                return(message);
            }

            message = "CONNECTOK:Sius:" + SiusConf.GetSetting.String("network");
            SiusLog.Log(SiusLog.INFORMATION, "connect", Zone.ZoneName + " successfully connected to the network.");
            return(message);
        }
Exemplo n.º 28
0
 public static void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     Zone.BroadcastMessage("SCORERESET");
     SiusLog.Log(SiusLog.INFORMATION, "score", "Sent score reset to all connected zones.");
 }
Exemplo n.º 29
0
        public static void Try(string[] parameters)
        {
            Player.PlayerStruct p = Player.GetPlayer(parameters[1]);

            /* Begin Database Connection */
            SQLiteConnection SConnection = new SQLiteConnection();

            SConnection.ConnectionString = SQLite.ConnectionString;
            SConnection.Open();

            SQLiteCommand cmd = new SQLiteCommand(SConnection);

            cmd.CommandText = @"UPDATE players SET lastseen = @lastseen WHERE name = @pname; "
                              + @"UPDATE players SET usage = (usage + @time) WHERE name = @pname;";
            SQLiteParameter lastseen = new SQLiteParameter("@lastseen");
            SQLiteParameter pname    = new SQLiteParameter("@pname");
            SQLiteParameter time     = new SQLiteParameter("@time");

            cmd.Parameters.Add(lastseen);
            cmd.Parameters.Add(pname);
            cmd.Parameters.Add(time);
            lastseen.Value = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
            pname.Value    = p.name;

            DateTime Current      = DateTime.Now;
            TimeSpan diff         = Current.Subtract(p.LoginTime);
            int      totalseconds = (((((diff.Days * 24) + diff.Hours) * 60) + diff.Minutes) * 60) + diff.Seconds;

            time.Value = totalseconds;

            cmd.ExecuteNonQuery();

            SConnection.Close();
            /* End Database Connection */

            SiusLog.Log(SiusLog.DEBUG, "leave", "Updated " + p.name + "'s player information into database.");

            // Remove the player
            Player.RemovePlayer(parameters[1]);

            /* Begin Database Connection */
            DataTable messages = new DataTable();

            SConnection.Open();
            cmd.CommandText = @"SELECT * FROM messages WHERE name = @pname";

            SQLiteDataReader Reader = cmd.ExecuteReader();

            messages.Load(Reader);
            Reader.Close();

            SConnection.Close();
            /* End Database Connection */

            if (messages.Rows.Count != 0)
            {
                for (int i = 0; i < messages.Rows.Count; i++)
                {
                    if (messages.Rows[i][4].ToString() == "1")
                    {
                        /* Begin Database Connection */
                        SConnection.Open();
                        cmd.CommandText = @"DELETE FROM messages WHERE name = @pname AND sender = @sender AND message = @message";
                        SQLiteParameter sender  = new SQLiteParameter("@sender");
                        SQLiteParameter message = new SQLiteParameter("@message");
                        cmd.Parameters.Add(sender);
                        cmd.Parameters.Add(message);
                        sender.Value  = messages.Rows[i][1].ToString();
                        message.Value = messages.Rows[i][2].ToString();

                        cmd.ExecuteNonQuery();

                        SConnection.Close();
                        /* End Database Connection */
                    }
                }
                SiusLog.Log(SiusLog.INFORMATION, "leave", "Deleted " + p.name + "'s old messages.");
            }

            SConnection.Dispose();
            SiusLog.Log(SiusLog.INFORMATION, "leave", "Player " + p.name + " disconnected from " + Zone.ZoneName);
        }
Exemplo n.º 30
0
        public static void Try(string[] parameters)
        {
            //PLOGIN:pid:flag:name:pw:ip:macid:contid

            // We are expecting 8 parameters (or seven occurences of ':')
            if (parameters.Length != 8)
            {
                Message.Send = "PBAD:" + parameters[1] + ":Invalid player connection protocol.";
                SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3] + ") : Invalid connection protocol");
                return;
            }

            //Check username length
            if (parameters[3].Length < 1)
            {
                Message.Send = "PBAD:" + parameters[1] + ":Username is too short.";
                SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3] + ") : Username is too short.");
                return;
            }

            //Check username length
            if (parameters[3].Length > 23)
            {
                Message.Send = "PBAD:" + parameters[1] + ":Username is too long.";
                SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3] + ") : Username is too long.");
                return;
            }

            //Check password length
            if (parameters[4].Length < 1)
            {
                Message.Send = "PBAD:" + parameters[1] + ":Password is too short.";
                SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3] + ") : Password is too short.");
                return;
            }

            //Check password length
            if (parameters[4].Length > 23)
            {
                Message.Send = "PBAD:" + parameters[1] + ":Password is too long.";
                SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3] + ") : Password is too long.");
                return;
            }

            int newplayers = SiusConf.GetSetting.Integer("newplayers");

            if (newplayers > 0)
            {
                //Check if the player already exists

                /* Begin Database Connection */
                DataTable dt = new DataTable();

                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString = SQLite.ConnectionString;
                SConnection.Open();

                SQLiteCommand cmd = new SQLiteCommand(SConnection);

                cmd.CommandText = @"SELECT * FROM players WHERE name = @pname";
                SQLiteParameter pname = new SQLiteParameter("@pname");
                cmd.Parameters.Add(pname);
                pname.Value = parameters[3];

                SQLiteDataReader Reader = cmd.ExecuteReader();
                dt.Load(Reader);
                Reader.Close();

                SConnection.Close();
                /* End Database Connection */

                //The player exists
                if (dt.Rows.Count > 0)
                {
                    //Check if the password is correct
                    if (SiusEncrypt.Encrypt(parameters[4], parameters[3], "players") == dt.Rows[0][2].ToString())
                    {
                        if (newplayers != 3)
                        {
                            //POK:pid:rtext:name:squad:billerid:usage:firstused
                            Message.Send = "POK:" + parameters[1] + "::" + parameters[3] + ":" +
                                           dt.Rows[0][4].ToString() + ":" + dt.Rows[0][0].ToString() + ":" +
                                           dt.Rows[0][5].ToString() + ":" + dt.Rows[0][6].ToString();

                            SiusLog.Log(SiusLog.INFORMATION, "login", parameters[3] + " successfully logged in to " + Zone.ZoneName);

                            Player.AddPlayer(parameters[3], parameters[1], dt.Rows[0][4].ToString());
                            return;
                        }
                        else
                        {
                            Message.Send = "PBAD:" + parameters[1] + ":0:The biller is currently not accepting any existing player connections.";
                            SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3]
                                        + ") : The biller is currently not accepting any existing player connections.");
                            return;
                        }
                    }
                    else
                    {
                        Message.Send = "PBAD:" + parameters[1] + ":0:Invalid password for the specified user.";
                        SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3] + ") : Invalid password for the specified user.");
                        return;
                    }
                }
                else
                {
                    //Create a new player
                    if (newplayers != 2)
                    {
                        /* Begin Database Connection */
                        SConnection.Open();

                        //Create row
                        cmd.CommandText = @"INSERT INTO players (name,created) values (@pname, @created)";
                        SQLiteParameter created = new SQLiteParameter("@created");
                        cmd.Parameters.Add(created);
                        cmd.Parameters.Add(pname);
                        created.Value = System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
                        pname.Value   = parameters[3];

                        cmd.ExecuteNonQuery();

                        //Update password
                        cmd.CommandText = @"UPDATE players SET password = @password where name = @pname";
                        SQLiteParameter password = new SQLiteParameter("@password");
                        cmd.Parameters.Add(password);
                        cmd.Parameters.Add(pname);
                        password.Value = SiusEncrypt.Encrypt(parameters[4], parameters[3], "players");
                        pname.Value    = parameters[3];

                        cmd.ExecuteNonQuery();

                        //Retrieve information
                        cmd.CommandText = @"SELECT * FROM players WHERE name = @pname";
                        cmd.Parameters.Add(pname);
                        pname.Value = parameters[3];

                        Reader = cmd.ExecuteReader();
                        dt.Load(Reader);
                        Reader.Close();

                        SConnection.Close();
                        SConnection.Dispose();
                        /* End Database Connection */

                        SiusLog.Log(SiusLog.INFORMATION, "user", "Succesfully created new user: "******"POK:" + parameters[1] + "::" + parameters[3] + ":" +
                                           dt.Rows[0][4].ToString() + ":" + dt.Rows[0][0].ToString() + ":" +
                                           dt.Rows[0][5].ToString() + ":" + dt.Rows[0][6].ToString();

                            SiusLog.Log(SiusLog.INFORMATION, "login", parameters[3] + " successfully logged in to " + Zone.ZoneName);

                            Player.AddPlayer(parameters[3], parameters[1], dt.Rows[0][4].ToString());
                            return;
                        }
                        else
                        {
                            Message.Send = "PBAD:" + parameters[1] + ":0:An error occured when attempting to log in. Please try again in a few seconds.";
                            SiusLog.Log(SiusLog.ERROR, "login", "Disconnected player (" + parameters[3] + ") : Database appears to be unreachable.");
                            return;
                        }
                    }
                    else
                    {
                        Message.Send = "PBAD:" + parameters[1] + ":0:The biller is currently not accepting any new player connections.";
                        SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3]
                                    + ") : The biller is currently not accepting any new player connections.");
                        return;
                    }
                }
            }
            else
            {
                Message.Send = "PBAD:" + parameters[1] + ":0:The biller is currently not accepting any player connections.";
                SiusLog.Log(SiusLog.WARNING, "login", "Disconnected player (" + parameters[3]
                            + ") : The biller is currently not accepting any player connections.");
                return;
            }
        }