Exemplo n.º 1
0
        static object[] GetProfile(ServerPacket header, string username)
        {
            List <object> profile = new List <object> {
                (byte)header
            };

            MySqlCommand q = new MySqlCommand("SELECT * FROM users WHERE Username=@Username;", SQL);

            q.Parameters.AddWithValue("@Username", username);

            MySqlDataReader r       = q.ExecuteReader();
            bool            success = r.Read();

            if (success)
            {
                string link   = r.GetString("ProfileLink");
                int    points = r.GetInt32("Points");
                byte   rank   = r.GetByte("Rank");
                string bio    = r.GetString("Bio");
                string avatar = r.GetString("Avatar");

                UserState state = new UserState()
                {
                    Points = points,
                    Rank   = rank
                };

                state.AddPoints(0);

                profile.AddRange(new object[] { username, link, rank, bio, avatar, state.Percentage });

                r.Close();
                r.Dispose();
            }
            else
            {
                profile.AddRange(new object[] { username, "", 0, "", "", 0 });
                r.Close();
                r.Dispose();
            }

            return(profile.ToArray());
        }