public static void saveTrampasSala() { mysql client = new mysql(); foreach (DataRow trampa in client.ExecuteQueryTable("SELECT * FROM trampas_publicas").Rows) { trampasPublicas.Add(new TrampaInstance(trampa)); } foreach (DataRow trampa in client.ExecuteQueryTable("SELECT * FROM trampas_privadas").Rows) { trampasPrivadas.Add(new TrampaInstance(trampa)); } }
private static void compartir(SessionInstance Session, string[,] Parameters) { try { mysql client = new mysql(); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM bpad_amigos WHERE ID_1 = '" + Session.User.id + "'").Rows) { UserInstance amigo = UserManager.ObtenerUsuario((int)row["ID_2"]); SessionInstance SessionFriend = UserManager.ObtenerSession(amigo.id); string Fecha = Convert.ToString(DateTime.Now).Substring(0, 16); client.SetParameter("Emisor", Session.User.id); client.SetParameter("Receptor", amigo.id); client.SetParameter("Mensaje", Session.User.levelup); client.SetParameter("Fecha", Fecha); client.SetParameter("Tipo", 3); client.ExecuteNonQuery("INSERT INTO bpad_mensajes (`Emisor`, `Mensaje`, `Receptor`, `Tipo`, `Fecha`) VALUES (@Emisor, @Mensaje, @Receptor, @Tipo, @Fecha)"); client.SetParameter("UserID", Session.User.id); int GetMessageID = Convert.ToInt32(client.ExecuteScalar("SELECT MAX(id) FROM bpad_mensajes WHERE Emisor = @UserID")); ServerMessage server = new ServerMessage(); server.AddHead(132); server.AddHead(127); server.AppendParameter(GetMessageID); server.AppendParameter(Session.User.id); server.AppendParameter(Fecha); server.AppendParameter(Session.User.levelup); server.AppendParameter(3); SessionFriend.SendData(server); } Session.User.levelup = ""; } catch (Exception e) { Console.WriteLine(e); Program.EditorialResponse(e); } }
static ServerMessage Cargar_Bpad(SessionInstance Session) { ServerMessage server = new ServerMessage(); server.AddHead(132); server.AddHead(120); using (mysql client = new mysql()) { int NumeroAmigos = Convert.ToInt32(client.ExecuteScalar("SELECT COUNT(*) FROM bpad_amigos WHERE (ID_1 = '" + Session.User.id + "')")); server.AppendParameter(NumeroAmigos); List <int> ID_amigos = new List <int>(); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM bpad_amigos WHERE ID_1 = '" + Session.User.id + "'").Rows) { //if (!ID_amigos.Contains((int)row[""])) UserInstance UserFriend = UserManager.ObtenerUsuario((int)row["ID_2"]); if (UserFriend != null) { server.AppendParameter(UserFriend.id); server.AppendParameter(UserFriend.nombre); server.AppendParameter(UserFriend.bocadillo); server.AppendParameter(UserFriend.avatar); server.AppendParameter(UserFriend.colores); server.AppendParameter(UserFriend.edad); server.AppendParameter("BurBian"); server.AppendParameter((string)row["Nota"]); server.AppendParameter((int)row["Marquilla"]); server.AppendParameter((int)row["Solicitud"]); } } } return(server); }
static void npc_packet_manager(SessionInstance Session, int function) { mysql client = new mysql(); ServerMessage server = new ServerMessage(); server.AddHead(123); server.AddHead(120); server.AppendParameter(function); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM object_npc WHERE sala_id = '" + Session.User.Sala.Escenario.id + "'").Rows) { server.AppendParameter((int)row["id"]); server.AppendParameter(0); server.AppendParameter((int)row["gold"]); server.AppendParameter((int)row["silver"]); server.AppendParameter((int)row["obj_id"]); string sk_obj_id = ""; string obj_cantidad = ""; mysql client2 = new mysql(); foreach (DataRow row_2 in client2.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { sk_obj_id += (int)row_2["sk_obj_id"] + "³"; obj_cantidad += (int)row_2["obj_cantidad"] + "³"; } if (sk_obj_id.Length != 0) { sk_obj_id = sk_obj_id.Remove(sk_obj_id.Length - 1, 1); } server.AppendParameter(sk_obj_id); server.AppendParameter(obj_cantidad); } Session.SendDataProtected(server); }
static void cargar_diccionarios(mysql client) { int key = 0; foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos_comprados WHERE objeto_id = 871").Rows)//Diccionario Loteria { key++; int id_user = (int)row["usuario_id"]; int numero_loteria = (int)row["loteria_numero"]; loteriaSemanal.Add(key, new int[] { id_user, numero_loteria }); } foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM bpad_amigos").Rows)//Diccionario bpadAmigos { bpadAmigos.Add((int)row["id"], new BPamigosInstance(row)); } }
public static void dictionary_manager() { mysql client = new mysql(); foreach (DataRow objetos in client.ExecuteQueryTable("SELECT * FROM objetos").Rows) { Catalago.Add((int)objetos["id"], new CatalogObjectInstance(objetos)); } }
public static void obtenerUsuariosRegistrados() { mysql client = new mysql(); foreach (DataRow usuario in client.ExecuteQueryTable("SELECT * FROM usuarios").Rows) { int userID = (int)usuario["id"]; usuariosRegistrados.Add(userID, new UserInstance(usuario)); } }
public static void automatic_lists_row() { int Contrador_Goldens = 0; for (int x = 0; x < 1000; x++) { Contrador_Goldens += 10; InterfazHandler.Cada_X_Goldens.Add(Contrador_Goldens); } mysql client = new mysql(); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE tipo_rare = 4").Rows) { Lista_Objetos_Rare.Add((int)row["id"]); Lista_Todos_Objetos_Oro.Add((int)row["id"]); } ///Objetos Muy Rare foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE tipo_rare = 3").Rows) { Lista_Objetos_MR.Add((int)row["id"]); Lista_Todos_Objetos_Oro.Add((int)row["id"]); } ///Objetos Casi Unico foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE tipo_rare = 2").Rows) { Lista_Objetos_CU.Add((int)row["id"]); Lista_Todos_Objetos_Oro.Add((int)row["id"]); } ///Objetos Unico foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE tipo_rare = 1").Rows) { Lista_Objetos_Unicos.Add((int)row["id"]); Lista_Todos_Objetos_Oro.Add((int)row["id"]); } foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE Especial = 'pocion'").Rows) { Pociones_Cajas.Add((int)row["id"]); } foreach (DataRow Row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE limitado = 1").Rows) { Catalago_Viernes.Add((int)Row["id"]); } foreach (DataRow Row in client.ExecuteQueryTable("SELECT * FROM objetos WHERE precio_plata > 1 AND visible = 1").Rows) { Lista_Todos_Objetos_Plata.Add((int)Row["id"]); } foreach (DataRow Row in client.ExecuteQueryTable("SELECT * FROM escenarios_publicos").Rows) { Areas_Id.Add((int)Row["id"]); } BoomBang_Managers(client); }
public static void Initialize() { using (mysql client = new mysql()) { foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_publicos").Rows) { CrearSala(new EscenarioInstance(row)); } } Output.WriteLine("Se han registrado " + Salas_Publicas.Count + " salas públicas."); }
public static int getTotalElements(int salaId) { int count = 0; mysql client = new mysql(); client.SetParameter("Id", salaId); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos_comprados WHERE sala_id = @Id").Rows) { count++; } return(count); }
public static List <CatalogObjectInstance> ObtenerCatalogo() { List <CatalogObjectInstance> Objetos = new List <CatalogObjectInstance>(); using (mysql client = new mysql()) { foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos").Rows) { Objetos.Add(new CatalogObjectInstance(row)); } } return(Objetos); }
public static void EliminarEscenario(EscenarioInstance Escenario) { using (mysql client = new mysql()) { client.SetParameter("id", Escenario.id); if (Escenario.es_categoria == 0) { client.ExecuteNonQuery("DELETE FROM escenarios_privados WHERE id = @id"); client.SetParameter("id", Escenario.id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos_comprados WHERE sala_id = @id").Rows) { BuyObjectInstance Compra = new BuyObjectInstance(row); SessionInstance Session = UserManager.ObtenerSession(Compra.usuario_id); if (Session != null) { ServerMessage añadir_mochila = new ServerMessage(); añadir_mochila.AddHead(189); añadir_mochila.AddHead(139); añadir_mochila.AppendParameter(Compra.id); añadir_mochila.AppendParameter(Compra.objeto_id); añadir_mochila.AppendParameter(Compra.colores_hex); añadir_mochila.AppendParameter(Compra.colores_rgb); añadir_mochila.AppendParameter(0); añadir_mochila.AppendParameter(0); añadir_mochila.AppendParameter(Compra.tam); añadir_mochila.AppendParameter(0); añadir_mochila.AppendParameter(0); añadir_mochila.AppendParameter(0); añadir_mochila.AppendParameter(1);//CantidadObjetos Session.SendData(añadir_mochila); } else { break; } } client.SetParameter("id", Escenario.id); client.ExecuteNonQuery("UPDATE objetos_comprados SET sala_id = '0' WHERE sala_id = @id"); } if (Escenario.es_categoria == 1) { client.ExecuteNonQuery("DELETE FROM escenarios_publicos WHERE id = @id"); } } SalaInstance Sala = SalasManager.ObtenerSala(Escenario); if (Sala != null) { SalasManager.EliminarSala(Sala); } }
private void LoadObjects() { using (mysql client = new mysql()) { ObjetosEnSala.Clear(); client.SetParameter("Id", Escenario.id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM objetos_comprados WHERE sala_id = @Id").Rows) { BuyObjectInstance Item = new BuyObjectInstance(row); ObjetosEnSala.Add(Item.id, Item); FijarChutas(Item); } } }
public static List <EscenarioInstance> ZonasIsla(IslaInstance Isla) { List <EscenarioInstance> Escenarios = new List <EscenarioInstance>(); using (mysql client = new mysql()) { client.SetParameter("id", Isla.id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_privados WHERE IslaID = @id").Rows) { Escenarios.Add(new EscenarioInstance(row)); } } return(Escenarios); }
public static List <IslaInstance> ObtenerIslas(int id) { List <IslaInstance> Islas = new List <IslaInstance>(); using (mysql client = new mysql()) { client.SetParameter("id", id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM islas WHERE CreadorID = @id").Rows) { Islas.Add(new IslaInstance(row)); } } return(Islas); }
public static ServerMessage ObtenerNPC(ServerMessage server, int Modelo) { mysql client = new mysql(); client.SetParameter("modelo", Modelo); server.AppendParameter(client.ExecuteScalar("SELECT COUNT(id) FROM escenarios_npc WHERE EscenarioID = @modelo")); client.SetParameter("modelo", Modelo); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_npc WHERE EscenarioID = @modelo").Rows) { npcInstance NpcData = new npcInstance(row); server.AppendParameter(new object[] { NpcData.ID, NpcData.dialogo, NpcData.modelo, NpcData.Nombre, NpcData.Pos.x, NpcData.Pos.y, NpcData.Pos.z, NpcData.Funcion, NpcData.Funcion_value }); } return(server); }
private static void Packet_208_120(SessionInstance Session, string[,] Parameters) { mysql client = new mysql(); int page = int.Parse(Parameters[1, 0]); ServerMessage server = new ServerMessage(); server.AddHead(208); server.AddHead(120); server.AppendParameter(new object[] { 1 }); server.AppendParameter(new object[] { Session.User.novedades_noticias }); server.AppendParameter(new object[] { 8 }); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM noticias ORDER BY `noticias`.`id` DESC LIMIT " + page + ",8").Rows) { server.AppendParameter(new object[] { (int)row["id"], (string)row["titulo"], (string)row["fecha"], 13 }); } Session.SendData(server); }
public static List <IslaInstance> ObtenerIslas(string nombre) { List <IslaInstance> Islas = new List <IslaInstance>(); using (mysql client = new mysql()) { UserInstance User = UserManager.ObtenerUsuario(nombre); if (User != null) { client.SetParameter("id", User.id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM islas WHERE CreadorID = @id").Rows) { Islas.Add(new IslaInstance(row)); } } } return(Islas); }
public static List <IslaInstance> ObtenerIslasNombre(string nombre) { List <IslaInstance> Islas = new List <IslaInstance>(); using (mysql client = new mysql()) { IslaInstance Isla = IslasManager.ObtenerIsla(nombre); if (Isla != null) { client.SetParameter("id", Isla.nombre); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM islas WHERE nombre = @id").Rows) { Islas.Add(new IslaInstance(row)); } } } return(Islas); }
public static List <IslaInstance> ObtenerIslasFavoritos(int id) { List <IslaInstance> Islas = new List <IslaInstance>(); using (mysql client = new mysql()) { client.SetParameter("id", id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_favoritos WHERE user_id = @id").Rows) { client.SetParameter("id", row["sala_id"]); DataRow row2 = client.ExecuteQueryRow("SELECT * FROM islas WHERE id = @id"); if (row2 != null) { Islas.Add(new IslaInstance(row2)); } } } return(Islas); }
public static List <EscenarioInstance> ObtenerCasas(string nombre) { List <EscenarioInstance> Casas = new List <EscenarioInstance>(); using (mysql client = new mysql()) { UserInstance User = UserManager.ObtenerUsuario(nombre); if (User != null) { client.SetParameter("id", User.id); client.SetParameter("modelo", 25); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_privados WHERE CreadorID = @id AND modelo = @modelo").Rows) { Casas.Add(new EscenarioInstance(row)); } } } return(Casas); }
public static List <EscenarioInstance> ObtenerCasasNombre(string nombre) { List <EscenarioInstance> Casas = new List <EscenarioInstance>(); using (mysql client = new mysql()) { EscenarioInstance Casa = ObtenerCasa(nombre); if (Casa != null) { client.SetParameter("id", Casa.nombre); client.SetParameter("modelo", 25); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_privados WHERE nombre = @id AND modelo = @modelo").Rows) { Casas.Add(new EscenarioInstance(row)); } } } return(Casas); }
static ServerMessage Cargar_Mensajes(SessionInstance Session) { ServerMessage server = new ServerMessage(); server.AddHead(132); server.AddHead(121); using (mysql client = new mysql()) { client.SetParameter("UserID", Session.User.id); int NumeroMensajes = Convert.ToInt32(client.ExecuteScalar("SELECT COUNT(*) FROM bpad_mensajes WHERE (Receptor = @UserID AND Leido = 0)")); server.AppendParameter(NumeroMensajes); client.SetParameter("UserID", Session.User.id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM bpad_mensajes WHERE (Receptor = @UserID AND Leido = 0)").Rows) { server.AppendParameter((int)row["id"]); server.AppendParameter((int)row["Emisor"]); server.AppendParameter((string)row["Fecha"]); server.AppendParameter((string)row["Mensaje"]); server.AppendParameter((int)row["Tipo"]); } } return(server); }
private static void Packet_154_32(SessionInstance Session) { mysql client = new mysql(); Dictionary <int, int> areas = new Dictionary <int, int>(); ServerMessage server = new ServerMessage(); server.AddHead(154); server.AddHead(32); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM escenarios_publicos WHERE visible = '1' ORDER BY prioridad ASC").Rows) { areas.Add((int)row["id"], SalasManager.UsuariosEnSala(new EscenarioInstance(row))); } foreach (var escenario in areas.OrderByDescending(x => x.Value)) { client.SetParameter("id", escenario.Key); DataRow row = client.ExecuteQueryRow("SELECT * FROM escenarios_publicos WHERE id = @id"); server.AppendParameter(row["categoria"]); server.AppendParameter(row["es_categoria"]); server.AppendParameter(row["id"]); server.AppendParameter(row["nombre"]); server.AppendParameter(SalasManager.UsuariosEnSala(new EscenarioInstance(row))); } Session.SendDataProtected(server); }
public static void armarioLooks(SessionInstance Session, int opcion, string nombre, string rename_look) { mysql client = new mysql(); string titulo = "Hola " + Session.User.nombre + " bienvenido a tu armario de looks :)\r"; string l1 = ""; string l2 = "Para crear nuevo look usa comando /savelook # El(#) indica el nombre que quieres poner a tu look.\r"; string l3 = "Para carga tu look del armario usa comando /setlook # El(#) indica el nombre de look que desas cargar.\r"; if (opcion == 1) { int count = 0; foreach (DataRow armario in client.ExecuteQueryTable("SELECT * FROM user_armario WHERE user_id = " + Session.User.id + "").Rows) { count++; l1 = l1 + "Look " + count + " > '" + (string)armario["nombre"] + "' "; } if (l1 == "") { l1 = "Ups! Tu armario esta vacio. No tienes look's registrados."; } l1 = l1 + "\r"; packetAlerta(Session, (titulo + l1 + l2 + l3)); } else if (opcion == 2) { int key = 0; if (rename_look != "") { client.SetParameter("nombre", nombre); client.SetParameter("user_id", Session.User.id); DataRow comprobar_nombre = client.ExecuteQueryRow("SELECT * FROM user_armario WHERE nombre = @nombre AND user_id = @user_id"); if (comprobar_nombre != null) { client.SetParameter("nombre", rename_look); client.SetParameter("avatar", Session.User.avatar); client.SetParameter("colores", Session.User.colores); client.SetParameter("id", (int)comprobar_nombre["id"]); client.ExecuteNonQuery("UPDATE user_armario SET nombre = @nombre, avatar_id = @avatar, colores = @colores WHERE id = @id"); NotificacionesManager.NotifiChat(Session, "Sabio: has cambiado look " + nombre + " por " + rename_look + "."); return; } NotificacionesManager.NotifiChat(Session, "Sabio: no tienes este look en armario."); return; } else { foreach (DataRow armario in client.ExecuteQueryTable("SELECT * FROM user_armario WHERE user_id = " + Session.User.id + "").Rows) { key++; } client.SetParameter("nombre", nombre); client.SetParameter("user_id", Session.User.id); DataRow comprobar_nombre = client.ExecuteQueryRow("SELECT * FROM user_armario WHERE nombre = @nombre AND user_id = @user_id"); if (comprobar_nombre != null) { NotificacionesManager.NotifiChat(Session, "Sabio: ya tienes un look registrador con el mismo nombre."); return; } if (key < 3) { client.SetParameter("id", Session.User.id); client.SetParameter("avatar", Session.User.avatar); client.SetParameter("colores", Session.User.colores); client.SetParameter("nombre", nombre); client.ExecuteNonQuery("INSERT INTO user_armario (user_id,nombre,colores,avatar_id) VALUES (@id, @nombre, @colores, @avatar)"); NotificacionesManager.NotifiChat(Session, "Sabio: has añadido nuevo look al armario."); } else { NotificacionesManager.NotifiChat(Session, "Sabio: tu armario esta llendo."); } } } else if (opcion == 3) { client.SetParameter("nombre", nombre); client.SetParameter("user_id", Session.User.id); DataRow ver_armario = client.ExecuteQueryRow("SELECT * FROM user_armario WHERE nombre = @nombre AND user_id = @user_id"); if (ver_armario != null) { int id_avatar = (int)ver_armario["avatar_id"]; string colores = (string)ver_armario["colores"]; if (Session.User.avatar == id_avatar && Session.User.colores == colores) { NotificacionesManager.NotifiChat(Session, "Sabio: ya tienes este look puesto !"); return; } Session.User.avatar = id_avatar; Session.User.colores = colores; Packet_125_120(Session, Session.User.id, Session.User.avatar, Session.User.colores, true); client.SetParameter("id", Session.User.id); client.SetParameter("avatar", Session.User.avatar); client.SetParameter("colores", Session.User.colores); client.ExecuteNonQuery("UPDATE usuarios SET avatar = @avatar, colores = @colores WHERE id = @id"); return; } NotificacionesManager.NotifiChat(Session, "Sabio: no tienes este look en armario."); } }
static void ComprarObjetosNPC(SessionInstance Session, string[,] Parameters) { int createID = int.Parse(Parameters[0, 0]); Console.WriteLine(createID); mysql client = new mysql(); DataRow row = client.ExecuteQueryRow("SELECT * FROM object_npc WHERE id = '" + createID + "'"); bool permitir_compra = true; if ((int)row["gold"] > 0 && Session.User.oro >= (int)row["gold"]) { Console.WriteLine("Objeto vale oro"); foreach (DataRow r in client.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { if ((int)r["sk_obj_id"] > 0) { int objeto_en_muchila = int.Parse(Convert.ToString(client.ExecuteScalar("select count(objeto_id)from objetos_comprados where objeto_id = '" + (int)r["sk_obj_id"] + "' and usuario_id = '" + Session.User.id + "'"))); if (objeto_en_muchila < (int)r["obj_cantidad"]) { permitir_compra = false; } } } if (permitir_compra == true) { foreach (DataRow r in client.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { if ((int)r["sk_obj_id"] > 0) { Com_Obj_Much(Session, (int)r["sk_obj_id"], (int)r["obj_cantidad"], false); } } UserManager.Creditos(Session.User, true, false, (int)row["gold"]); Com_Obj_Much(Session, (int)row["obj_id"], 0, true); } else { cancel_packet_buy(Session); } } else if ((int)row["silver"] > 0 && Session.User.plata >= (int)row["silver"]) { foreach (DataRow r in client.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { if ((int)r["sk_obj_id"] > 0) { int objeto_en_muchila = int.Parse(Convert.ToString(client.ExecuteScalar("select count(objeto_id)from objetos_comprados where objeto_id = '" + (int)r["sk_obj_id"] + "' and usuario_id = '" + Session.User.id + "'"))); if (objeto_en_muchila < (int)r["obj_cantidad"]) { permitir_compra = false; } } } if (permitir_compra == true) { foreach (DataRow r in client.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { if ((int)r["sk_obj_id"] > 0) { Com_Obj_Much(Session, (int)r["sk_obj_id"], (int)r["obj_cantidad"], false); } } UserManager.Creditos(Session.User, false, false, (int)row["silver"]); Com_Obj_Much(Session, (int)row["obj_id"], 0, true); } else { cancel_packet_buy(Session); } } else if ((int)row["gold"] == 0 && (int)row["silver"] == 0) { foreach (DataRow r in client.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { if ((int)r["sk_obj_id"] > 0) { int objeto_en_muchila = int.Parse(Convert.ToString(client.ExecuteScalar("select count(objeto_id)from objetos_comprados where objeto_id = '" + (int)r["sk_obj_id"] + "' and usuario_id = '" + Session.User.id + "'"))); if (objeto_en_muchila < (int)r["obj_cantidad"]) { permitir_compra = false; } } } if (permitir_compra == true) { foreach (DataRow r in client.ExecuteQueryTable("SELECT * FROM object_npc_id WHERE obj_id = '" + (int)row["obj_id"] + "'").Rows) { if ((int)r["sk_obj_id"] > 0) { Com_Obj_Much(Session, (int)r["sk_obj_id"], (int)r["obj_cantidad"], false); } } Com_Obj_Much(Session, (int)row["obj_id"], 0, true); } else { cancel_packet_buy(Session); } } else { cancel_packet_buy(Session); } }
private static void Method_132_122(SessionInstance Session, string[,] Parameters) { Thread.Sleep(100); Cargar_Bpad(Session); ServerMessage server = new ServerMessage(); server.AddHead(132); server.AddHead(122); using (mysql client = new mysql()) { client.SetParameter("UserID", Session.User.id); foreach (DataRow row in client.ExecuteQueryTable("SELECT * FROM bpad_amigos WHERE ID_1 = @UserID AND Solicitud = '0'").Rows) { UserInstance FriendUser = UserManager.ObtenerUsuario((int)row["ID_2"]); if (FriendUser != null) { server.AppendParameter(FriendUser.id); if (UserManager.UsuariosOnline.ContainsKey(FriendUser.id)) { SessionInstance SessionAmigo = UserManager.ObtenerSession(FriendUser.id); if (SessionAmigo != null) { if (SessionAmigo.User.Sala != null) { if (SessionAmigo.User.Sala.Escenario.id == 70)//Las areas del bosque nevada { server.AppendParameter(1); server.AppendParameter(-1); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(-1); server.AppendParameter(-1); server.AppendParameter(Session.User.Sala.Escenario.id); } else if (SessionAmigo.User.Sala.Escenario.id == 2 && SessionAmigo.User.Sala.Escenario.es_categoria == 2 && SessionAmigo.User.Sala.Escenario.categoria == 5) { server.AppendParameter(1); server.AppendParameter(-1); server.AppendParameter(SessionAmigo.User.Sala.Escenario.es_categoria);//ES_CATEGORIA server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(SessionAmigo.User.Sala.id); server.AppendParameter(0); server.AppendParameter(SessionAmigo.User.Sala.Escenario.nombre); } else { server.AppendParameter(1); server.AppendParameter(-1); server.AppendParameter(SessionAmigo.User.Sala.Escenario.es_categoria);//ES_CATEGORIA server.AppendParameter(0); server.AppendParameter(0); if (Session.User.Sala != null) { if (Session.User.Sala.Escenario.IrAlli == 0) { Thread.Sleep(new TimeSpan(0, 0, 0, 0, 500)); server.AppendParameter(-1); } else { if (Session.User.Sala.Escenario.es_categoria == SessionAmigo.User.Sala.Escenario.es_categoria && Session.User.Sala.id == SessionAmigo.User.Sala.id || SessionAmigo.User.Sala.Escenario.es_categoria == 2) { server.AppendParameter(-1); } else { server.AppendParameter(SessionAmigo.User.Sala.id); } } } else { server.AppendParameter(SessionAmigo.User.Sala.id); } server.AppendParameter(0); server.AppendParameter(SessionAmigo.User.Sala.Escenario.nombre); } } else { server.AppendParameter(1); server.AppendParameter(-1); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(-1); server.AppendParameter(-1); server.AppendParameter("Flower Power"); } } } else { server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(0); server.AppendParameter(-1); server.AppendParameter(FriendUser.ultima_conexion); } } } } Session.SendData(server); }