public void updateRequi(long player_id, int medalhas, int insignias, int ordens_azuis, int broche) { try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.Parameters.AddWithValue("@pid", player_id); command.Parameters.AddWithValue("@broche", broche); command.Parameters.AddWithValue("@insignias", insignias); command.Parameters.AddWithValue("@medalhas", medalhas); command.Parameters.AddWithValue("@ordensazuis", ordens_azuis); command.CommandType = CommandType.Text; command.CommandText = "UPDATE contas SET brooch=@broche, insignia=@insignias, medal=@medalhas, blue_order=@ordensazuis WHERE player_id=@pid"; command.ExecuteNonQuery(); command.Dispose(); connection.Close(); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[TitleManager.updateRequi] Erro fatal!"); } }
public List <Friends> getFriends(int owner_id) { List <Friends> list = new List <Friends>(); try { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlConnection.Open(); mySqlCommand.CommandText = "SELECT * FROM friends WHERE owner_id='" + owner_id + "'"; mySqlCommand.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); while (mySqlDataReader.Read()) { Friends item = new Friends { FriendNumered = mySqlDataReader.GetInt32("object_id"), friend_id = mySqlDataReader.GetInt32("friend_id"), owner_id = mySqlDataReader.GetInt32("owner_id") }; list.Add(item); this.id++; } } } catch (Exception ex) { this.dbstatus = -100; CLogger.getInstance().error("[Friend] database not found"); CLogger.getInstance().error("[Friend] " + ex.ToString()); } return(list); }
public static void GenerateList() { try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.CommandText = "SELECT * FROM events_quest"; command.CommandType = CommandType.Text; NpgsqlDataReader data = command.ExecuteReader(); while (data.Read()) { QuestModel ev = new QuestModel { startDate = (UInt32)data.GetInt64(0), endDate = (UInt32)data.GetInt64(1) }; _events.Add(ev); } command.Dispose(); data.Close(); connection.Dispose(); connection.Close(); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[EventQuestSyncer] Fatal Error!"); } }
public static bool isClanLogoExist(uint logo) { try { int value = 0; using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@logo", (long)logo); command.CommandText = "SELECT COUNT(*) FROM clan_data WHERE logo=@logo"; value = Convert.ToInt32(command.ExecuteScalar()); command.Dispose(); connection.Dispose(); connection.Close(); } return(value > 0); } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[ClanManager.isClanLogoExist] Erro fatal!"); return(true); } }
public bool CreateTitleDB(long player_id) { if (player_id == 0) { return(false); } try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand cmd = connection.CreateCommand(); connection.Open(); cmd.Parameters.AddWithValue("@owner", player_id); cmd.CommandText = "INSERT INTO player_titles (owner_id) VALUES (@owner)"; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); cmd.Dispose(); connection.Close(); } return(true); } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[TitleManager.CreateTitleDB] Erro fatal!"); return(false); } }
public static bool isClanNameExist(string name) { if (string.IsNullOrEmpty(name)) { return(true); } try { int value = 0; using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@name", name); command.CommandText = "SELECT COUNT(*) FROM clan_data WHERE clan_name=@name"; value = Convert.ToInt32(command.ExecuteScalar()); command.Dispose(); connection.Dispose(); connection.Close(); } return(value > 0); } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[ClanManager.isClanNameExist] Erro fatal!"); return(true); } }
public MedalManager() { try { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlConnection.Open(); mySqlCommand.CommandText = "SELECT * FROM player_medal"; mySqlCommand.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); while (mySqlDataReader.Read()) { Medal item = new Medal { player_id = mySqlDataReader.GetInt32("Player_Id"), brooch = mySqlDataReader.GetInt32("Brooch"), insignia = mySqlDataReader.GetInt32("Insignia"), medal = mySqlDataReader.GetInt32("Medal"), blue_order = mySqlDataReader.GetInt32("Blue_order") }; this._accounts.Add(item); this.id++; } CLogger.getInstance().extra_info("[Medal] Loaded: " + this._accounts.Count + " info(s)."); } } catch (Exception ex) { this.dbstatus = -100; CLogger.getInstance().error("[Medal] database not found"); CLogger.getInstance().error("[Medal] " + ex.ToString()); } }
public FriendManager() { try { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlConnection.Open(); mySqlCommand.CommandText = "SELECT * FROM friends"; mySqlCommand.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); while (mySqlDataReader.Read()) { Friends item = new Friends { FriendNumered = mySqlDataReader.GetInt32("object_id"), friend_id = mySqlDataReader.GetInt32("friend_id"), owner_id = mySqlDataReader.GetInt32("owner_id") }; this._clans.Add(item); this.id++; } CLogger.getInstance().extra_info("[Friend] Loaded: " + this._clans.Count + " friends."); } } catch (Exception ex) { this.dbstatus = -100; CLogger.getInstance().error("[Friend] database not found"); CLogger.getInstance().error("[Friend] " + ex.ToString()); } }
public static List <Account> getClanPlayers(int clan_id, long exception, bool useCache, bool isOnline) { List <Account> accountList = new List <Account>(); if (clan_id == 0) { return(accountList); } try { using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn()) { NpgsqlCommand command = npgsqlConnection.CreateCommand(); npgsqlConnection.Open(); command.Parameters.AddWithValue("@clan", (object)clan_id); command.Parameters.AddWithValue("@on", (object)isOnline); command.CommandText = "SELECT player_id,player_name,name_color,rank,clanaccess,clandate,status FROM accounts WHERE clan_id=@clan AND online=@on"; command.CommandType = CommandType.Text; NpgsqlDataReader npgsqlDataReader = command.ExecuteReader(); while (npgsqlDataReader.Read()) { long int64 = npgsqlDataReader.GetInt64(0); if (int64 != exception) { Account account1 = new Account() { player_id = int64, player_name = npgsqlDataReader.GetString(1), name_color = npgsqlDataReader.GetInt32(2), clanId = clan_id, _rank = npgsqlDataReader.GetInt32(3), _isOnline = isOnline, clanAccess = npgsqlDataReader.GetInt32(4), clanDate = npgsqlDataReader.GetInt32(5) }; account1._status.SetData((uint)npgsqlDataReader.GetInt64(6), account1.player_id); if (useCache) { Account account2 = AccountManager.getAccount(account1.player_id, true); if (account2 != null) { account1._connection = account2._connection; } } accountList.Add(account1); } } command.Dispose(); npgsqlDataReader.Close(); npgsqlConnection.Dispose(); npgsqlConnection.Close(); } } catch (Exception ex) { Logger.error(ex.ToString()); } return(accountList); }
public static void Load() { try { using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn()) { NpgsqlCommand command = npgsqlConnection.CreateCommand(); npgsqlConnection.Open(); command.CommandText = "SELECT * FROM clan_data"; 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); ClanManager._clans.Add(clan); } } command.Dispose(); npgsqlDataReader.Close(); npgsqlConnection.Close(); } } catch (Exception ex) { Logger.error(ex.ToString()); } }
public static List <Account> getClanPlayers(int clanId, long exception, bool isOnline) { List <Account> friends = new List <Account>(); if (clanId <= 0) { return(friends); } try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.Parameters.AddWithValue("@clan", clanId); command.Parameters.AddWithValue("@on", isOnline); command.CommandText = "SELECT player_id,player_name,rank,online,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), _rank = data.GetInt32(2), _isOnline = data.GetBoolean(3) }; p._status.SetData((uint)data.GetInt64(4), pId); if (p._isOnline && !AccountManager.getInstance()._contas.ContainsKey(pId)) { p.setOnlineStatus(false); p._status.ResetData(p.player_id); } friends.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(friends); }
public static void LoadList() { // Limpa as regras caso já exista (Ex: Reload) itemscamp.Clear(); itemscnpb.Clear(); items79.Clear(); itemslan.Clear(); try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.CommandText = "SELECT * FROM regras WHERE item_id > 100000000 and (camp=true OR cnpb=true OR lan=true OR _79=true) "; command.CommandType = CommandType.Text; NpgsqlDataReader data = command.ExecuteReader(); while (data.Read()) { int item_id = data.GetInt32(1); bool camp = data.GetBoolean(3); bool cnpb = data.GetBoolean(4); bool lan = data.GetBoolean(5); bool _79 = data.GetBoolean(6); if (camp) { itemscamp.Add(item_id); } if (cnpb) { itemscnpb.Add(item_id); } if (lan) { itemslan.Add(item_id); } if (_79) { items79.Add(item_id); } } command.Dispose(); data.Close(); connection.Dispose(); connection.Close(); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[ClanManager.LoadList] Erro fatal!"); } }
public void getFriendlyAccounts(FriendSystem system) { if (system == null) { return; } if (system._friends.Count == 0) { return; } try { using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn()) { NpgsqlCommand command = npgsqlConnection.CreateCommand(); npgsqlConnection.Open(); List <string> stringList = new List <string>(); for (int index = 0; index < system._friends.Count; ++index) { Friend friend = system._friends[index]; string parameterName = "@valor" + (object)index; command.Parameters.AddWithValue(parameterName, (object)friend.player_id); stringList.Add(parameterName); } string str = string.Join(",", stringList.ToArray()); command.CommandText = "SELECT player_name,player_id,rank,online,status FROM accounts WHERE player_id in (" + str + ") 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 = npgsqlDataReader.GetBoolean(3); friend.player._status.SetData((uint)npgsqlDataReader.GetInt64(4), friend.player_id); if (friend.player._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 (FriendlyAccounts)!\r\n" + ex.ToString()); } }
public void excludeFriendInDb(int object_id) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { mySqlConnection.Open(); new MySqlCommand(string.Concat(new object[] { "DELETE FROM friends WHERE object_id='" + object_id + "'" }), mySqlConnection).ExecuteNonQuery(); } }
public void excludeClanInDb(int id) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { mySqlConnection.Open(); new MySqlCommand(string.Concat(new object[] { "DELETE FROM clan_data WHERE clan_id='" + id + "'" }), mySqlConnection).ExecuteNonQuery(); } }
public void AddFriend(int friend_id, int owner_id) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { mySqlConnection.Open(); MySqlCommand mySqlCommand = new MySqlCommand(string.Concat(new object[] { "INSERT INTO friends(friend_id,owner_id)VALUES('" + friend_id + "','" + owner_id + "')" }), mySqlConnection); mySqlCommand.ExecuteNonQuery(); } }
public static void Load() { SQLjec.getInstance(); AccountManager.getInstance(); ClanManager.getInstance(); ConfigManager.getInstance(); FriendManager.getInstance(); MessageManager.getInstance(); MissionManager.getInstance(); ShopInfoManager.getInstance(); TitleManager.getInstance(); }
public void createClanInDb(string name, int ownerId) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { mySqlConnection.Open(); MySqlCommand mySqlCommand = new MySqlCommand(string.Concat(new object[] { "INSERT INTO clan_data(clan_id,clan_name,owner_id,create_date)VALUES('" + ownerId + "','" + name + "','" + ownerId + "','" + DateTime.Now.ToString("yyyyMMdd") + "')" }), mySqlConnection); mySqlCommand.ExecuteNonQuery(); } }
public PlayerMissions getMission(long pId, int mission1, int mission2, int mission3, int mission4) { if (pId == 0) { return(null); } PlayerMissions mission = null; try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.Parameters.AddWithValue("@owner", pId); command.CommandText = "SELECT * FROM player_missions WHERE owner_id=@owner"; command.CommandType = CommandType.Text; NpgsqlDataReader data = command.ExecuteReader(); while (data.Read()) { mission = new PlayerMissions { actualMission = data.GetInt32(1), card1 = data.GetInt32(2), card2 = data.GetInt32(3), card3 = data.GetInt32(4), card4 = data.GetInt32(5), mission1 = mission1, mission2 = mission2, mission3 = mission3, mission4 = mission4, }; data.GetBytes(6, 0, mission.list1, 0, 40); data.GetBytes(7, 0, mission.list2, 0, 40); data.GetBytes(8, 0, mission.list3, 0, 40); data.GetBytes(9, 0, mission.list4, 0, 40); mission.UpdateSelectedCard(); } command.Dispose(); data.Close(); connection.Dispose(); connection.Close(); } return(mission); } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[MissionManager.getMission] Erro fatal!"); return(null); } }
/// <summary> /// Pesquisa as contas dos amigos na Database e retorna com as informações básicas. /// Retorna: /// Apelido, Id do jogador, Patente, "online" e "status". /// </summary> /// <param name="playerId"></param> /// <returns></returns> public void getFriendlyAccounts(FriendSystem system) { if (system == null || system._friends.Count == 0) { return; } try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); string loaded = ""; List <string> parameters = new List <string>(); for (int idx = 0; idx < system._friends.Count; idx++) { Friend friend = system._friends[idx]; string param = "@valor" + idx; command.Parameters.AddWithValue(param, friend.player_id); parameters.Add(param); } loaded = string.Join(",", parameters.ToArray()); command.CommandText = "SELECT player_name,player_id,rank,online,status FROM contas WHERE player_id in (" + loaded + ") 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 = data.GetBoolean(3); friend.player._status.SetData((uint)data.GetInt64(4), friend.player_id); if (friend.player._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.FriendlyAccounts] Erro fatal!"); } }
public static List <Message> getGifts(long owner_id) { List <Message> gifts = new List <Message>(); if (owner_id == 0) { return(gifts); } try { DateTime today = DateTime.Now; using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.Parameters.AddWithValue("@owner", owner_id); command.CommandText = "SELECT * FROM player_messages WHERE owner_id=@owner"; command.CommandType = CommandType.Text; NpgsqlDataReader data = command.ExecuteReader(); while (data.Read()) { int type = data.GetInt32(6); if (type != 2) { continue; } Message msg = new Message(data.GetInt64(8), today) { id = data.GetInt32(0), sender_id = data.GetInt64(2), clanId = data.GetInt32(3), sender_name = data.GetString(4), text = data.GetString(5), type = type, state = data.GetInt32(7), cB = (NoteMessageClan)data.GetInt32(9), }; gifts.Add(msg); } command.Dispose(); data.Close(); connection.Dispose(); connection.Close(); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[MessageManager] Fatal Error!"); } return(gifts); }
public static List <Account> getClanPlayers(int clanId, long exception, bool isOnline) { List <Account> accountList = new List <Account>(); if (clanId <= 0) { return(accountList); } try { using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn()) { NpgsqlCommand command = npgsqlConnection.CreateCommand(); npgsqlConnection.Open(); command.Parameters.AddWithValue("@clan", (object)clanId); command.Parameters.AddWithValue("@on", (object)isOnline); command.CommandText = "SELECT player_id,player_name,rank,online,status FROM accounts WHERE clan_id=@clan AND online=@on"; command.CommandType = CommandType.Text; NpgsqlDataReader npgsqlDataReader = command.ExecuteReader(); while (npgsqlDataReader.Read()) { long int64 = npgsqlDataReader.GetInt64(0); if (int64 != exception) { Account account = new Account() { player_id = int64, player_name = npgsqlDataReader.GetString(1), _rank = npgsqlDataReader.GetInt32(2), _isOnline = npgsqlDataReader.GetBoolean(3) }; account._status.SetData((uint)npgsqlDataReader.GetInt64(4), int64); if (account._isOnline && !AccountManager.getInstance()._contas.ContainsKey(int64)) { account.setOnlineStatus(false); account._status.ResetData(account.player_id); } accountList.Add(account); } } command.Dispose(); npgsqlDataReader.Close(); npgsqlConnection.Dispose(); npgsqlConnection.Close(); } } catch (Exception ex) { Logger.warning(ex.ToString()); } return(accountList); }
public static bool updateDB(string TABELA, string req1, object valorReq1, string[] COLUNAS, params object[] VALORES) { if (COLUNAS.Length > 0 && VALORES.Length > 0 && COLUNAS.Length != VALORES.Length) { Printf.danger("[updateDB2] Valores invalidos, consulte os logs!"); SaveLog.error("[updateDB2] Valores invalidos! SQL [Table] " + TABELA + " [Column] " + String.Join(",", COLUNAS) + " [VALUES] " + String.Join(",", VALORES) + " [WHERE] " + req1 + " == " + valorReq1); return(false); } else if (COLUNAS.Length == 0 || VALORES.Length == 0) { // Printf.danger("[updateDB2] Table: " + TABELA + " Column: " + String.Join(",", COLUNAS) + " VALUES: " + String.Join(",", VALORES) + " [WHERE] " + req1 + " == " + valorReq1); return(false); } try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.CommandType = CommandType.Text; string loaded = ""; List <string> parameters = new List <string>(); for (int i = 0; i < VALORES.Length; i++) { object obj = VALORES[i]; string column = COLUNAS[i]; string param = "@valor" + i; command.Parameters.AddWithValue(param, obj); parameters.Add(column + "=" + param); } loaded = string.Join(",", parameters.ToArray()); command.Parameters.AddWithValue("@req1", valorReq1); command.CommandText = "UPDATE " + TABELA + " SET " + loaded + " WHERE " + req1 + "=@req1"; command.ExecuteNonQuery(); command.Dispose(); connection.Close(); } return(true); } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[AllUtils.updateDB2] Erro fatal!\n " + ex); return(false); } }
public void get(int item_id, int player_id) { bool flag = AccountManager.getInstance().getCountForItemId(item_id, player_id) == 0; if (flag) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { mySqlConnection.Open(); new MySqlCommand(string.Concat(new object[] { string.Concat(new object[] { "INSERT INTO items(owner_id,item_id,item_name,count,equip,loc_slot)VALUES('", this.p_id, "','", this._item_id, "','", this._item_id_name, "','", this._count, "','", this._equip, "','", this._type, "');" }) }), mySqlConnection).ExecuteNonQuery(); } base.writeC((byte)this._equip); base.writeD(this._count); } else { int num = AccountManager.getInstance().getCountForItemId(item_id, player_id) + this._count; base.writeC((byte)this._equip); base.writeD(num); AccountManager.getInstance().DescontItem(item_id, player_id, num); foreach (ItemsModel current in this.p.getInventory().getItemsAll()) { bool flag2 = current.id == this._item_id; if (flag2) { current.count = num; } } } }
public static Message getMessage(int id, long pId) { Message msg = null; if (pId == 0 || id == 0) { return(null); } try { DateTime today = DateTime.Now; using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@owner", pId); command.CommandText = "SELECT * FROM player_messages WHERE id=@id AND owner_id=@owner"; command.CommandType = CommandType.Text; NpgsqlDataReader data = command.ExecuteReader(); while (data.Read()) { msg = new Message(data.GetInt64(8), today) { id = id, sender_id = data.GetInt64(2), clanId = data.GetInt32(3), sender_name = data.GetString(4), text = data.GetString(5), type = data.GetInt32(6), state = data.GetInt32(7), cB = (NoteMessageClan)data.GetInt32(9) }; } command.Dispose(); data.Close(); connection.Dispose(); connection.Close(); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[MessageManager] Fatal Error!"); return(null); } return(msg); }
public int getFriendForOwnerId(int owner_id) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand command = mySqlConnection.CreateCommand(); mySqlConnection.Open(); command.CommandText = "SELECT friend_id FROM friends WHERE owner_id='" + owner_id + "'';"; command.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = command.ExecuteReader(); if (mySqlDataReader.Read()) { return(mySqlDataReader.GetInt32("friend_id")); } } return(0); }
/*{ * foreach (Account account in AccountManager.getInstance().getAccounts()) * { * if (account.player_id == player_id) * return account; * } * return (Account)null; * }*/ public int getPlayerId(string name) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand command = mySqlConnection.CreateCommand(); mySqlConnection.Open(); command.CommandText = "SELECT player_id FROM accounts WHERE player_name='" + name + "' LIMIT 1;"; command.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = command.ExecuteReader(); if (mySqlDataReader.Read()) { return(mySqlDataReader.GetInt32("player_id")); } } return(-1); }
public int getCountForItemId(int item_id, int owner_id) { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand command = mySqlConnection.CreateCommand(); mySqlConnection.Open(); command.CommandText = "SELECT count FROM items WHERE item_id='" + item_id + "' AND owner_id='" + owner_id + "';"; command.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = command.ExecuteReader(); if (mySqlDataReader.Read()) { return(mySqlDataReader.GetInt32("count")); } } return(0); }
public static void LoadList() { try { using (NpgsqlConnection npgsqlConnection = SQLjec.getInstance().conn()) { NpgsqlCommand command = npgsqlConnection.CreateCommand(); npgsqlConnection.Open(); command.CommandText = "SELECT * FROM tournament_rules"; command.CommandType = CommandType.Text; NpgsqlDataReader npgsqlDataReader = command.ExecuteReader(); while (npgsqlDataReader.Read()) { string str = npgsqlDataReader.GetString(0); string txt = npgsqlDataReader.GetString(1); if (str == "camp") { ShopManager.IsBlocked(txt, TorunamentRulesManager.itemscamp); } if (str == "cnpb") { ShopManager.IsBlocked(txt, TorunamentRulesManager.itemscnpb); } if (str == "79") { ShopManager.IsBlocked(txt, TorunamentRulesManager.items79); } if (str == "lan") { ShopManager.IsBlocked(txt, TorunamentRulesManager.itemslan); } } command.Dispose(); npgsqlDataReader.Close(); npgsqlConnection.Dispose(); npgsqlConnection.Close(); } Logger.warning("Trounament Rules @Camp Count: " + (object)TorunamentRulesManager.itemscamp.Count); Logger.warning("Trounament Rules @Cnpb Count: " + (object)TorunamentRulesManager.itemscnpb.Count); Logger.warning("Trounament Rules @79 Count: " + (object)TorunamentRulesManager.items79.Count); Logger.warning("Trounament Rules @lan Count: " + (object)TorunamentRulesManager.itemslan.Count); } catch (Exception ex) { Logger.error("Ocorreu um problema ao carregar os Tournament Rules!\r\n" + ex.ToString()); } }
public void AddTitleDb(int player_id) { try { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlConnection.Open(); mySqlCommand.CommandText = "INSERT INTO titles (owner_id) VALUES ('" + player_id + "');"; mySqlCommand.CommandType = CommandType.Text; mySqlCommand.ExecuteNonQuery(); } } catch { } }