コード例 #1
0
        private void btn_user_save_Click(object sender, EventArgs e)
        {
            String  newparam  = "";
            Boolean separator = false;

            for (int i = 0; i < listParam.Length; i++)
            {
                if (listParam[i] != null)
                {
                    if (separator == true)
                    {
                        newparam = "|" + newparam;
                    }
                    newparam  = listParam[i] + newparam;
                    separator = true;
                }
            }
            String kunci;

            if (in_user_pass.Text.Length > 0)
            {
                kunci = enc.encstr(in_user_name.Text + in_user_pass.Text);
            }
            else
            {
                kunci = "";
            }
            String sql = "EXEC insertUser @name = '" + in_user_name.Text + "', @pass = '******', @perm = '" + newparam + "'";

            Console.WriteLine(sql);
            MsSQL.kuerisql(sql, "Simpan Permission", "Simpan Data Berhasil");
            MsSQL.insertLog(auth.authID, namaModul, "Menyimpan data SQL = " + sql, nett[0], nett[1], auth.LogId);
            loadgridUserlist();
        }
コード例 #2
0
ファイル: Jobs.cs プロジェクト: CarlosX/DarkEmu
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Create Job Alias
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void MakeAlias()
 {
     try
     {
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         int id = Reader.Int32();
         byte type = Reader.Byte();
         short nLenght = Reader.Int16();
         string name = Reader.String(nLenght);
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         Console.WriteLine(name);
         MsSQL ms = new MsSQL("SELECT * FROM character_jobs WHERE job_alias='" + name + "'");
         int checkjob = ms.Count();
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         client.Send(Packet.MakeAlias(name, type));
         if (checkjob == 0)
         {
             client.Send(Packet.MakeAlias(name, type));
             MsSQL.UpdateData("UPDATE character_jobs SET job_alias='" + name + "' WHERE character_name='" + Character.Information.Name + "'");
         }
         else if (checkjob >= 0)
         {
             client.Send(Packet.MakeAliasError(name, type));
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
コード例 #3
0
        public override bool alterar(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Append("UPDATE MODELO SET DESCRICAO='" +
                            ((Modelo)obj).Descricao.ToUpper() + "', " +
                            "ID_MARCA=" + ((Modelo)obj).Marca.ID.ToString() +
                            "WHERE ID=" + ((Modelo)obj).ID);
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao alterar o modelo. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #4
0
ファイル: Grabpet.cs プロジェクト: uvbs/DarkEmu
 void UnSummonPetLogoff(int petid)
 {
     try
     {
         //First we close the pet by calling closepet void.
         if (petid == Character.Grabpet.Grabpetid)
         {
             ClosePet(petid, Character.Grabpet.Details);
             Character.Grabpet.Active  = false;
             Character.Grabpet.Spawned = false;
             Character.Grabpet.Details = null;
         }
         else if (petid == Character.Attackpet.Uniqueid)
         {
             ClosePet(petid, Character.Attackpet.Details);
             Character.Attackpet.Active  = false;
             Character.Attackpet.Spawned = false;
             Character.Attackpet.Details = null;
         }
         //Update database information
         MsSQL.UpdateData("UPDATE pets SET pet_active='0' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'");
         //Set active to false so the user can spawn another pet.
         Character.Grabpet.Active = false;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Pet despawn error: " + ex);
     }
 }
コード例 #5
0
        public override bool buscarID(ClasseBase obj)
        {
            SqlDataReader reader;
            bool          erro = true;

            try
            {
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Append("SELECT ID,ID_VEICULO,ID_FORNECEDOR,ID_FUNCIONARIO,DATA_ABASTEC,KM,QUANTIDADE,PRECO FROM ABASTECIMENTO ");
                vsql.Append("WHERE ID=" + ((Abastecimento)obj).ID.ToString());
                command.CommandText = command.CommandText + vsql.ToString();
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    ((Abastecimento)obj).Veiculo.ID     = Convert.ToInt32(reader["ID_VEICULO"]);
                    ((Abastecimento)obj).Fornecedor.ID  = Convert.ToInt32(reader["ID_FORNECEDOR"]);
                    ((Abastecimento)obj).Funcionario.ID = Convert.ToInt32(reader["ID_FUNCIONARIO"]);
                    ((Abastecimento)obj).Dt_abastec     = Convert.ToDateTime(reader["DATA_ABASTEC"]);
                    ((Abastecimento)obj).Km             = Convert.ToInt32(reader["KM"]);
                    ((Abastecimento)obj).Quantidade     = Convert.ToDouble(reader["QUANTIDADE"]);
                    ((Abastecimento)obj).Quantidade     = Convert.ToDouble(reader["PRECO"]);
                }
                else
                {
                    erro = false;
                }
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #6
0
ファイル: Deletion.cs プロジェクト: uvbs/DarkEmu
 //Void character delete
 void CharacterDelete()
 {
     //Wrap our function in a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Skip one not used byte
         Reader.Skip(1);
         //Get character name information
         string CharacterName = Reader.Text();
         //Close packet reader
         Reader.Close();
         //Update and set time + deletion state into the database
         MsSQL.InsertData("UPDATE character SET deletedtime=dateadd(dd,7,getdate()),deleted='1' WHERE name='" + CharacterName + "'");
         //Send visual state of character on screen sit down
         client.Send(Packet.ScreenSuccess(3));
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Character deletion error {0}", ex);
         //Write information to debug logger
         Systems.Debugger.Write(ex);
     }
 }
コード例 #7
0
        public override bool alterar(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Append("UPDATE ABASTECIMENTO ");
                vsql.Append("SET ID_VEICULO = " + ((Abastecimento)obj).Funcionario.ID.ToString());
                vsql.Append(",ID_FORNECEDOR = " + ((Abastecimento)obj).Fornecedor.ID.ToString());
                vsql.Append(",ID_FUNCIONARIO = " + ((Abastecimento)obj).Funcionario.ID.ToString());
                vsql.Append(",DATA_ABASTEC = '" + ((Abastecimento)obj).Dt_abastec.ToString());
                vsql.Append("',KM = " + ((Abastecimento)obj).Km.ToString());
                vsql.Append(",QUANTIDADE = " + ((Abastecimento)obj).Quantidade.ToString());
                vsql.Append(",PRECO = " + ((Abastecimento)obj).Preco.ToString().Replace(',', '.'));
                vsql.Append(",ID_COMBUSTIVEL = " + ((Abastecimento)obj).Tipo_Combustivel.ID.ToString());
                vsql.Append(" WHERE ID=" + ((Abastecimento)obj).ID);
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao alterar o lançamento do abastecimento. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #8
0
ファイル: Framework.MSSQL.cs プロジェクト: uvbs/DarkEmu
            public static int CharacterDataInt(string charname, string toGet)
            {
                int result;

                result = MsSQL.GetDataInt("SELECT * FROM karakterler WHERE name='" + charname + "'", toGet);
                return(result);
            }
コード例 #9
0
        public override bool buscarID(ClasseBase obj)
        {
            bool          erro = true;
            SqlDataReader reader;

            try
            {
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = "SELECT ID,NOME FROM FUNCAO " +
                                      "WHERE ID=" + ((Funcao)obj).ID.ToString();
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    ((Funcao)obj).Nome = reader["NOME"].ToString();
                }
                else
                {
                    erro = false;
                }
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #10
0
ファイル: Blues.cs プロジェクト: CarlosX/DarkEmu
        public static void LoadBlues(character c)
        {
            try
            {
                MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='"+ c.Information.CharacterID +"'");
                using (SqlDataReader reader = ms.Read())
                {
                    while (reader.Read())
                    {
                        int a = 10;
                        int b = 11;

                        int id = reader.GetInt32(0);
                        Global.itemblue it = new Global.itemblue();
                        it.blue = new ArrayList();
                        it.blueamount = new ArrayList();
                        it.totalblue = reader.GetInt32(9);
                        for (int i = 0; i <= it.totalblue; i++)
                        {
                            it.blue.Add(reader.GetString(a));
                            it.blueamount.Add(reader.GetInt32(b));
                            a += 2;
                            b += 2;
                        }

                        Data.ItemBlue[id] = it;

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Blue error: {0}",ex);
            }
        }
コード例 #11
0
        public override bool inserir(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Append("INSERT INTO USUARIO ");
                vsql.Append("(LOGIN,NOME,SENHA,ATIVO,ID_PERFIL) ");
                vsql.Append("VALUES ");
                vsql.Append("('" + ((Usuario)obj).Login.ToLower() + "','" + ((Usuario)obj).Nome.ToUpper() +
                            "','" + ((Usuario)obj).Senha + "','" + ((Usuario)obj).Ativo + "'," +
                            ((Usuario)obj).perfil.ID.ToString() + ")");
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao inserir o usuário. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #12
0
        public override bool buscarID(ClasseBase obj)
        {
            SqlDataReader reader;
            bool          erro = true;

            try
            {
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Append("SELECT ID,ID_FUNCIONARIO,MES,ANO,QUANTIDADE FROM COTA_MENSAL");
                vsql.Append(" WHERE ID=" + ((Cota_mensal)obj).ID.ToString());
                command.CommandText = command.CommandText + vsql.ToString();
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    ((Cota_mensal)obj).Funcionario.ID = Convert.ToInt32(reader["ID_FUNCIONARIO"]);
                    ((Cota_mensal)obj).Mes            = Convert.ToInt32(reader["MES"]);
                    ((Cota_mensal)obj).Ano            = Convert.ToInt32(reader["ANO"]);
                    ((Cota_mensal)obj).Qtde           = Convert.ToInt32(reader["QUANTIDADE"]);
                }
                else
                {
                    erro = false;
                }
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #13
0
        public bool buscarLogin(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                SqlDataReader reader;
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = "SELECT ID,LOGIN,NOME,SENHA,ID_PERFIL,ATIVO FROM USUARIO " +
                                      "WHERE LOGIN='******'";
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    ((Usuario)obj).ID        = Convert.ToInt32(reader["ID"]);
                    ((Usuario)obj).Nome      = reader["NOME"].ToString();
                    ((Usuario)obj).Senha     = reader["SENHA"].ToString();
                    ((Usuario)obj).perfil.ID = Convert.ToInt32(reader["ID_PERFIL"]);
                    ((Usuario)obj).Ativo     = reader["ATIVO"].ToString();
                    ((Usuario)obj).Estado    = Stateobj.stLimpo;
                }
                else
                {
                    erro = false;
                }
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #14
0
        public List <Usuario> listar()
        {
            SqlDataReader  reader;
            List <Usuario> listaUsuario = new List <Usuario>();
            Int32          x            = 0;

            try
            {
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Append("SELECT A.ID, A.LOGIN, A.NOME FROM USUARIO A ");
                vsql.Append("ORDER BY A.NOME ");
                command.CommandText = vsql.ToString();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    listaUsuario.Add(new Usuario());
                    listaUsuario[x].ID    = Convert.ToInt32(reader["ID"]);
                    listaUsuario[x].Login = reader["LOGIN"].ToString();
                    listaUsuario[x].Nome  = reader["NOME"].ToString();
                    x++;
                }
                return(listaUsuario);
            }
            catch (Exception e)
            {
                throw new Exception("Erro ao montar a lista de usuários. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
        }
コード例 #15
0
ファイル: GuildData.cs プロジェクト: CarlosX/DarkEmu
 public void LoadGuildMemberIds(int guildid, ref List<int> MemberIDs)
 {
     try
     {
         //Make sure we start with a clean list
         if (MemberIDs != null)
             //If not null clear the list
             MemberIDs.Clear();
         //Create new query to get guild member information
         MsSQL ms = new MsSQL("SELECT * FROM guild_members WHERE guild_id='" + guildid + "'");
         //Create sql data reader to read database content
         using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
         {
             //While the reader is reading
             while (reader.Read())
             {
                 //Add member id to the list
                 MemberIDs.Add(reader.GetInt32(2));
             }
         }
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write information to debug log
         Systems.Debugger.Write(ex);
     }
 }
コード例 #16
0
ファイル: TEST.cs プロジェクト: ibeae/ThinkAway.net
        public void MsSqlTest()
        {
            DbHelper dbHelper = new MsSQL("test");

            using (TransactionScope transactionScope = new TransactionScope())
            {
                for (int i = 0; i < 10; i++)
                {
                    ContentValues contentValues = new ContentValues();
                    contentValues.Add("Name", "lsong");
                    contentValues.Add("Password", "123456");
                    dbHelper.Insert("myTable", contentValues);
                }
                transactionScope.Complete();
            }


            using (Cursor cursor = dbHelper.Query("myTable", null, null, null))
            {
                while (cursor.Next())
                {
                    System.Console.Write(cursor[0] + "    ");
                    System.Console.Write(cursor[1] + "    ");
                    System.Console.Write(cursor[2]);
                    System.Console.WriteLine();
                }
            }


            System.Console.ReadKey(true);
        }
コード例 #17
0
        public override bool buscarID(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                SqlDataReader reader;
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = "SELECT ID,DESCRICAO,ID_MARCA FROM MODELO " +
                                      "WHERE ID=" + ((Modelo)obj).ID.ToString();
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    ((Modelo)obj).Descricao = reader["DESCRICAO"].ToString();
                    ((Modelo)obj).Marca.ID  = Convert.ToInt32(reader["ID_MARCA"]);
                }
                else
                {
                    erro = false;
                }
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #18
0
        public override bool inserir(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Remove(0, vsql.Length);
                vsql.Append("INSERT INTO COTA_MENSAL ");
                vsql.Append("(ID_FUNCIONARIO,");
                vsql.Append("MES,");
                vsql.Append("ANO,");
                vsql.Append("QUANTIDADE)");
                vsql.Append("VALUES ");
                vsql.Append("(" + ((Cota_mensal)obj).Funcionario.ID.ToString() + ",");
                vsql.Append(((Cota_mensal)obj).Mes.ToString() + ",");
                vsql.Append(((Cota_mensal)obj).Ano.ToString() + ",");
                vsql.Append(((Cota_mensal)obj).Qtde.ToString() + ")");
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao inserir a cota mensal do funcionário. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #19
0
        public override bool alterar(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Append("UPDATE USUARIO SET LOGIN='******', NOME='" + ((Usuario)obj).Nome.ToUpper() + "', SENHA='" + ((Usuario)obj).Senha +
                            "', ATIVO='" + ((Usuario)obj).Ativo.ToUpper() + "', ID_PERFIL=" + ((Usuario)obj).perfil.ID.ToString() + " " +
                            "WHERE ID=" + ((Usuario)obj).ID);
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao alterar o usuário. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #20
0
        public override bool alterar(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Remove(0, vsql.Length);
                vsql.Append("UPDATE COTA_MENSAL ");
                vsql.Append("SET ID_FUNCIONARIO = " + ((Cota_mensal)obj).Funcionario.ID.ToString());
                vsql.Append(",MES = " + ((Cota_mensal)obj).Mes.ToString());
                vsql.Append(",ANO = " + ((Cota_mensal)obj).Ano.ToString());
                vsql.Append(",QUANTIDADE = " + ((Cota_mensal)obj).Qtde.ToString());
                vsql.Append("WHERE ID=" + ((Cota_mensal)obj).ID);
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao alterar a cota mensal do funcionário. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #21
0
ファイル: Restore.cs プロジェクト: uvbs/DarkEmu
 void CharacterRestore()
 {
     //Wrap our function in a catcher
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Skip one byte
         Reader.Skip(1);
         //Read charactername to be restored
         string CharacterName = Reader.Text();
         Reader.Close();
         //Update database information set deleted state to 0
         MsSQL.InsertData("UPDATE character SET deleted='0' WHERE name='" + CharacterName + "'");
         //Send state packet to client character standing up
         client.Send(Packet.ScreenSuccess(5));
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Character restore error {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
コード例 #22
0
ファイル: Pvpsystem.cs プロジェクト: uvbs/DarkEmu
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Pvp Base
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void Pvpsystem()
        {
            try
            {
                byte pvptype = Character.Information.Pvptype;
                if (Character.Information.Pvpstate == pvptype)
                {
                    return;
                }

                if (pvptype > 0)
                {
                    MsSQL.UpdateData("UPDATE character SET Pvpstate='" + pvptype + "' WHERE name='" + Character.Information.Name + "'");
                    Character.Information.PvpWait = false;
                    Character.Information.PvP     = true;
                    Send(Packet.PvpSystemData(Character.Information.UniqueID, pvptype));
                    StopPvpTimer();
                }
                else
                {
                    MsSQL.UpdateData("UPDATE character SET Pvpstate='" + pvptype + "' WHERE name='" + Character.Information.Name + "'");
                    Character.Information.PvpWait = false;
                    Character.Information.PvP     = false;
                    Send(Packet.PvpSystemData(Character.Information.UniqueID, 0));
                    StopPvpTimer();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #23
0
 /////////////////////////////////////////////////////////////////////////////////
 // Save guide
 /////////////////////////////////////////////////////////////////////////////////
 #region Save guide
 public void SaveGuideInfo()
 {
     //Wrap our function inside a catcher
     try
     {
         //Set default value for guidehex
         string GuideHex = "";
         //For 8 repeating
         for (int i = 0; i < 8; ++i)
         {
             //Num lenght for guideinfo
             string Numlen = String.Format("{0:X}", Character.Guideinfo.G1[i]);
             //If lenght is 1, we set the string to 0 + lenght
             if (Numlen.Length == 1)
             {
                 Numlen = "0" + Numlen;
             }
             //Set total
             GuideHex = GuideHex + Numlen;
         }
         //Update database information
         MsSQL.UpdateData("update character set GuideData='" + GuideHex + "' where id='" + Character.Information.CharacterID + "'");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Saving Guide error: {0}", ex);
         Console.WriteLine(ex);
     }
 }
コード例 #24
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Player Berserk Add
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void Player_Berserk_Up()
        {
            try
            {
                if (!Character.Information.Berserking)
                {
                    Character.Information.BerserkBar = 0;
                    client.Send(Packet.InfoUpdate(4, 0, Character.Information.BerserkBar));
                    Character.Information.Berserking = true;

                    if (Character.Information.Title != 0)
                    {
                        Character.Information.BerserkOran = 230;
                    }
                    else
                    {
                        Character.Information.BerserkOran = 200;
                    }
                    Send(Packet.StatePack(Character.Information.UniqueID, 4, 1, false));

                    //20.slot bersek speed slot
                    Character.Speed.Updateded[20] = 100;
                    Character.Speed.RunSpeed     += Character.Speed.Updateded[20];
                    //Player_SetNewSpeed();
                    Send(Packet.SetSpeed(Character.Information.UniqueID, Character.Speed.WalkSpeed, Character.Speed.RunSpeed));

                    MsSQL.UpdateData("update character set berserkbar='" + Character.Information.BerserkBar + "' where id='" + Character.Information.CharacterID + "'");
                    StartBerserkerTimer(60000);
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #25
0
 /////////////////////////////////////////////////////////////////////////////////
 // Save position
 /////////////////////////////////////////////////////////////////////////////////
 #region Save position
 protected void SavePlayerPosition()
 {
     //Wrap our function inside a catcher
     try
     {
         //Update database
         if (!File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
         {
             MsSQL.UpdateData("update character set xsect='" + Character.Position.xSec +
                              "', ysect='" + Character.Position.ySec +
                              "', xpos='" + Math.Round(Formule.packetx(Character.Position.x, Character.Position.xSec)) +
                              "', ypos='" + Math.Round(Formule.packety(Character.Position.y, Character.Position.ySec)) +
                              "', zpos='" + Math.Round(Character.Position.z) +
                              "' where id='" + Character.Information.CharacterID + "'");
         }
         else
         {
             MsSQL.UpdateData("update character set xsect='" + Character.Position.xSec +
                              "', ysect='" + Character.Position.ySec +
                              "', xpos='" + Math.Round(Formule.cavepacketx(Character.Position.x)) +
                              "', ypos='" + Math.Round(Formule.cavepackety(Character.Position.y)) +
                              "', zpos='" + Math.Round(Character.Position.z) +
                              "' where id='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Save position error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
コード例 #26
0
        public static bool Copy(int id)
        {
            bool copied = false;

            MsSQL.Prepare(conn =>
            {
                DataSet ds = MsSQL.RunDataSetQuery(ref conn, "report_copy",
                                                   new List <object> {
                    id
                });

                if (!Utils.IsDataSetValid(ds))
                {
                    return;
                }

                int resultCode = Convert.ToInt32(ds.Tables[0].Rows[0]["ResultCode"]);

                if (resultCode == 200)
                {
                    var config      = Extend.GetConfig();
                    int newReportId = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"]);

                    if (System.IO.File.Exists(config.ReportPath + "/" + id + ".frx"))
                    {
                        System.IO.File.Copy(config.ReportPath + "/" + id + ".frx", config.ReportPath + "/" + newReportId + ".frx");
                    }

                    copied = true;
                }
            });

            return(copied);
        }
コード例 #27
0
        public override bool inserir(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Remove(0, vsql.Length);
                vsql.Append("INSERT INTO FUNCAO ");
                vsql.Append("(NOME) ");
                vsql.Append("VALUES ");
                vsql.Append("('" + ((Funcao)obj).Nome.ToUpper() + "')");
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao inserir a função. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #28
0
        public Double verifAbastecido(Funcionario obj, Int32 pmes, Int32 pano)
        {
            SqlDataReader reader;
            Double        qtde_abastecido;

            try
            {
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Append("SELECT SUM(QUANTIDADE) as QUANTIDADE FROM ABASTECIMENTO ");
                vsql.Append("WHERE ID_FUNCIONARIO= " + obj.ID.ToString());
                vsql.Append(" AND MONTH(DATA_ABASTEC)=" + pmes.ToString());
                vsql.Append(" AND YEAR(DATA_ABASTEC)=" + pano.ToString());
                command.CommandText = command.CommandText + vsql.ToString();
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    qtde_abastecido = Convert.ToInt32(((reader["QUANTIDADE"].ToString() == "")?0:reader["QUANTIDADE"]));
                }
                else
                {
                    qtde_abastecido = 0;
                }
            }
            finally
            {
                command.Connection.Close();
            }
            return(qtde_abastecido);
        }
コード例 #29
0
        public override bool alterar(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Remove(0, vsql.Length);
                vsql.Append("UPDATE FUNCAO SET NOME='" + ((Funcao)obj).Nome.ToUpper() + "' " +
                            " WHERE ID=" + ((Funcao)obj).ID);
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (System.Exception e)
            {
                erro = false;
                throw new Exception("Erro ao alterar a função. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #30
0
        public override bool inserir(ClasseBase obj)
        {
            bool erro = true;

            try
            {
                vsql.Append("INSERT INTO MODELO ");
                vsql.Append("(DESCRICAO,ID_MARCA) ");
                vsql.Append("VALUES ");
                vsql.Append("('" + ((Modelo)obj).Descricao.ToUpper() + "'," +
                            ((Modelo)obj).Marca.ID.ToString() + ")");
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                command.CommandText = vsql.ToString();
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                erro = false;
                throw new Exception("Erro ao inserir o modelo. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
            return(erro);
        }
コード例 #31
0
        public List <Funcao> listar()
        {
            List <Funcao> lista = new List <Funcao>();

            System.Data.DataSet ds = new System.Data.DataSet();
            Int32 x = 0;

            try
            {
                SqlDataReader reader;
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Remove(0, vsql.Length);
                vsql.Append("SELECT ID, NOME FROM FUNCAO ");
                vsql.Append("ORDER BY NOME");
                command.CommandText = vsql.ToString();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    lista.Add(new Funcao());
                    lista[x].ID   = Convert.ToInt32(reader["ID"]);
                    lista[x].Nome = reader["NOME"].ToString();
                    x++;
                }
                return(lista);
            }
            catch (Exception e)
            {
                throw new Exception("Erro ao montar a lista de Funcao. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
        }
コード例 #32
0
        /// <summary>
        /// tcode 테이블에 데이터 존재 여부를 체크한다.
        /// </summary>
        public static void code_chk()
        {
            MsSQL sql = new MsSQL(vari.conn);

            string qry = string.Format("SELECT COUNT(*) CNT FROM T_CODE WHERE COMPANY_ID = 'GM' AND PROG_ID = 'TORQUE' AND CODE = 'TOOL_NAME'");

            using (DataSet ds = sql.Excute_Query(qry, "cnt"))
            {
                if (Fnc.obj2int(ds.Tables[0].Rows[0]["cnt"]) < 1)
                {
                    qry = "Insert into T_CODE (COMPANY_ID, PROG_ID, CODE, CODENAME, CODETYPE ) values ( 'GM', 'TORQUE', 'TOOL_NAME', '툴 이름', 'S')";
                    sql.Excute_Query(qry, "");
                }
            }

            qry = string.Format("SELECT COUNT(*) CNT FROM T_CODE WHERE COMPANY_ID = 'GM' AND PROG_ID = 'TORQUE' AND CODE = 'RST_NAME'");

            using (DataSet ds = sql.Excute_Query(qry, "cnt"))
            {
                if (Fnc.obj2int(ds.Tables[0].Rows[0]["cnt"]) < 1)
                {
                    qry = "Insert into T_CODE (COMPANY_ID, PROG_ID, CODE, CODENAME, CODETYPE ) values ( 'GM', 'TORQUE', 'RST_NAME', '결과 이름', 'S')";
                    sql.Excute_Query(qry, "");
                }
            }
        }
コード例 #33
0
        public List <Modelo> listar(Marca obj)
        {
            SqlDataReader reader;
            List <Modelo> lista = new List <Modelo>();
            Int32         x     = 0;

            try
            {
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Append("SELECT ID, DESCRICAO, ID_MARCA FROM MODELO ");
                vsql.Append("WHERE ID_MARCA=" + obj.ID);
                vsql.Append("ORDER BY DESCRICAO ");
                command.CommandText = vsql.ToString();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    lista.Add(new Modelo());
                    lista[x].ID        = Convert.ToInt32(reader["ID"]);
                    lista[x].Descricao = reader["DESCRICAO"].ToString();
                    lista[x].Marca.ID  = Convert.ToInt32(reader["ID_MARCA"]);
                    x++;
                }
                return(lista);
            }
            catch (Exception e)
            {
                throw new Exception("Erro ao montar a lista de modelo. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
        }
コード例 #34
0
ファイル: Ranks.cs プロジェクト: CarlosX/DarkEmu
 /////////////////////////////////////////////////////////////////////////////////////
 // Honor rank
 /////////////////////////////////////////////////////////////////////////////////////
 void HonorRank()
 {
     /////////////////////////////////////////////////////////////////////////////////////
     MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_honor");
     int count = readsql.Count();
     /////////////////////////////////////////////////////////////////////////////////////
     if (count > 0)
     {
         client.Send(Packet.HonorRank(Character));
     }
 }
コード例 #35
0
ファイル: UpdateServer.cs プロジェクト: CarlosX/DarkEmu
        /////////////////////////////////////////////////////////////////////////////////
        // Login user
        /////////////////////////////////////////////////////////////////////////////////
        public static int LoginUser(string aID, ref string aPass, ref DarkEmu_GameServer.player aPlayer, bool localConnect)
        {
            //Console.WriteLine("Login User: {0} - {1}",aID,aPass);

            MsSQL ms = new MsSQL("SELECT * FROM users WHERE password='******'");
            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {

                if (Systems.clients.Count>=Systems.maxSlots)
                {
                    ms.Close();
                    return 2; // crowded
                }

                while (reader.Read())
                {
                    if (reader.GetString(1).ToLower() == aID.ToLower()) // id
                    {
                        if (reader.GetByte(3) == 1) // online
                        {
                            ms.Close();
                            return 3; // already online
                        }

                        if (reader.GetInt32(5) == 1) // banned
                        {
                            aPass = reader.GetString(4);
                            ms.Close();
                            return 4; // banned
                        }

                        if (aPlayer == null && localConnect) MsSQL.UpdateData("UPDATE users SET online=1 WHERE userid='" + reader.GetInt32(0) + "'");
                        aPlayer = new player();
                        aPlayer.AccountName = aID;
                        aPlayer.Password = aPass; // Nukei: ?? whats the reason for saving password in memory ?
                        aPlayer.ID = reader.GetInt32(0);
                        aPlayer.pGold = reader.GetInt64(7);
                        aPlayer.Silk = reader.GetInt32(6);
                        aPlayer.SilkPrem = reader.GetInt32(9);
                        aPlayer.wSlots = reader.GetByte(11);
                        ms.Close();
                        //Console.WriteLine("Login..!!");
                        return 0;
                    }
                }
            }
            ms.Close();
            return 1; // not found
        }
コード例 #36
0
ファイル: CharacterLoading.cs プロジェクト: CarlosX/DarkEmu
 void LoadGrabPet()
 {
     //Wrap our function inside a catcher
     try
     {
         //Query check
         MsSQL ms = new MsSQL("SELECT * FROM pets WHERE playerid='" + Character.Information.CharacterID + "' AND pet_active='1'");
         //Get active pet count
         int checkactive = ms.Count();
         //If the player has an active grabpet
         if (checkactive > 0)
         {
             //Set new pet object
             pet_obj o = new pet_obj();
             //Create new data reader for mssql
             using (SqlDataReader reader = ms.Read())
             {
                 //While the sql data reader is reading
                 while (reader.Read())
                 {
                     //Get pet location inside the player inventory
                     string slot = reader.GetString(12);
                     //Check our slot inside the database
                     int slotcheck = MsSQL.GetDataInt("SELECT * FROM char_items WHERE itemnumber='" + slot + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'", "slot");
                     //Set slot item information (item).
                     Global.slotItem item = GetItem((uint)Character.Information.CharacterID, Convert.ToByte(slotcheck), 0);
                     //Set model information of the pet
                     int model = Global.objectdata.GetItem(Data.ItemBase[item.ID].ObjectName);
                     //Set id for the pet (First database value is always unique).
                     Character.Grabpet.Grabpetid = item.dbID;
                     //Set unique id
                     o.UniqueID = Character.Grabpet.Grabpetid;
                     //Pet object model
                     o.Model = model;
                     //Spawning location of the pet
                     o.x = Character.Position.x + rnd.Next(1, 3);
                     o.z = Character.Position.z;
                     o.y = Character.Position.y + rnd.Next(1, 3);
                     o.xSec = Character.Position.xSec;
                     o.ySec = Character.Position.ySec;
                     //Owner id information
                     o.OwnerID = Character.Information.CharacterID;
                     //Owner name information
                     o.OwnerName = Character.Information.Name;
                     //Set walking state
                     o.Walking = Character.Position.Walking;
                     //Set petname
                     o.Petname = reader.GetString(3);
                     //Set our switch case
                     o.Named = 2;
                     //Set speed of pet (Need to check speed on official).
                     o.Run = Character.Speed.RunSpeed - 3;
                     o.Walk = Character.Speed.WalkSpeed - 3;
                     o.Zerk = Character.Speed.BerserkSpeed - 3;
                     //Set grabpet as active so there cant be double spawns
                     Character.Grabpet.Active = true;
                     //Set object information to true
                     o.Information = true;
                     //Spawn the pet
                     Systems.HelperObject.Add(o);
                     //Set global information for the pet
                     Character.Grabpet.Details = o;
                     //Send the visual packet for details of the pet management
                     client.Send(Packet.Pet_Information_grab(o, Convert.ToByte(slotcheck)));
                     //Spawn
                     o.SpawnMe();
                     //Update state into database
                     MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
                 }
                 //Close sql reader
                 ms.Close();
             }
             //Set state
             Character.Grabpet.Active = true;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Grab pet player load error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
コード例 #37
0
ファイル: CharacterLoading.cs プロジェクト: CarlosX/DarkEmu
 void LoadJobData()
 {
     //Wrap our function inside a catcher
     try
     {
         //Get jobtype information from database
         int jobtype = MsSQL.GetDataInt("SELECT * FROM users WHERE id='" + Player.AccountName + "'", "jobtype");
         //If we have a job so not 0 value
         if (jobtype > 0)
         {
             //Create our query to get all job information
             MsSQL ms = new MsSQL("SELECT * FROM character_jobs WHERE character_name='" + Character.Information.Name + "'");
             //Open new sql data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //While sql data reader is reading
                 while (reader.Read())
                 {
                     //Set global job name
                     Character.Job.Jobname = reader.GetString(2);
                     //Set global job type
                     Character.Job.type = reader.GetByte(3);
                     //Set global job exp
                     Character.Job.exp = reader.GetInt32(4);
                     //Set global job rank
                     Character.Job.rank = reader.GetByte(5);
                     //Set global job state
                     Character.Job.state = reader.GetInt32(6);
                     //Set global job level
                     Character.Job.level = reader.GetByte(7);
                 }
             }
             //Close our sql data reader.
             ms.Close();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Job load error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
コード例 #38
0
ファイル: CharacterLoading.cs プロジェクト: CarlosX/DarkEmu
        void LoadTicket(character c)
        {
            //We wrap our function inside a catcher
            try
            {
                //First we get our data from the database.
                MsSQL ms = new MsSQL("SELECT * FROM character_tickets WHERE owner ='" + c.Information.CharacterID + "' AND active='1'");
                //Check if we have a active ticket
                int CheckActive = ms.Count();

                //Now if we have one active we continue
                if (CheckActive == 1)
                {
                    //Open new sql data reader
                    using (SqlDataReader reader = ms.Read())
                    {
                        //While sql data reader is reading
                        while (reader.Read())
                        {
                            //Set our ticket to active so they cannot use double premium tickets
                            Character.Premium.Active = true;
                            //We can use Character.Information.CharacterID but on safe side we read from db to make sure.
                            Character.Premium.OwnerID = reader.GetInt32(1);
                            //Get the id information to calculate the % gaining and type etc etc..
                            Character.Premium.TicketItemID = reader.GetInt32(2);
                            //Get unique id (incase we need it).
                            Character.Premium.TicketID = reader.GetInt32(0);
                            //Get the start time of the ticket
                            Character.Premium.StartTime = reader.GetDateTime(3);
                        }
                    }
                    //Close our data reader
                    ms.Close();
                    //Calculate remaining time left.
                    TimeSpan Timecheck = Convert.ToDateTime(Character.Premium.StartTime) - DateTime.Now;
                    double TimeRemaining = Timecheck.TotalMinutes;
                    //Finally we send our packet to the user (Icon).
                    client.Send(Packet.PremiumTicketData(Character.Premium.TicketItemID, Convert.ToInt32(TimeRemaining)));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Premium ticket loading error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
コード例 #39
0
ファイル: Mastery.cs プロジェクト: CarlosX/DarkEmu
        void Mastery_Skill_Up()
        {
            try
            {
                if (!Character.Action.upskilltimer)
                {
                    Character.Action.upskilltimer = true;
                    SkillUpTimer(250);

                    PacketReader Reader = new PacketReader(PacketInformation.buffer);
                    int skillid = Reader.Int32();
                    if (!(Character.Information.SkillPoint < Data.SkillBase[skillid].SkillPoint))
                    {
                        Character.Information.SkillPoint -= Data.SkillBase[skillid].SkillPoint;
                        client.Send(Packet.InfoUpdate(2, Character.Information.SkillPoint, 0));
                        client.Send(Packet.SkillUpdate(skillid));
                        client.Send(Packet.PlayerStat(Character));

                        SaveSkill(skillid);

                        MsSQL ms = new MsSQL("SELECT * FROM saved_skills WHERE owner='" + Character.Information.CharacterID + "'");
                        using (SqlDataReader reader = ms.Read())
                            Character.Stat.Skill.AmountSkill = ms.Count();
                        int i = 1;
                        using (SqlDataReader reader = ms.Read())
                        {
                            while (reader.Read())
                            {
                                Character.Stat.Skill.Skill[i] = reader.GetInt32(2);
                                i++;
                            }
                        }
                        ms.Close();

                        SkillGetOpened(skillid);

                    }
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #40
0
ファイル: Timer.cs プロジェクト: CarlosX/DarkEmu
        public void PingTimerCallBack(object e)
        {
            try
            {
                TimeSpan t = DateTime.Now - lastPing;
                if (client.State) Ping();
                if (!client.State && Player != null)
                {
                    Console.BackgroundColor = ConsoleColor.Black;
                    MsSQL.UpdateData("UPDATE users SET online='" + 0 + "' WHERE id='" + Player.AccountName + "'");
                    MsSQL.UpdateData("UPDATE character SET online='0' WHERE id='" + Character.Information.CharacterID + "'");

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("@Evo-Debug :         Srevo has debugged: {0}", Character.Information.Name);
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]");
                    Console.ForegroundColor = ConsoleColor.Green;
                    if (Character.Grabpet.Active) UnSummonPetLogoff(Character.Grabpet.Details.UniqueID);
                    if (Character.Attackpet.Active) UnSummonPetLogoff(Character.Attackpet.Details.UniqueID);
                    if (Character.Network.Party != null)
                    {
                        LeaveParty();
                    }

                    if (Character.Network.Guild.Guildid != 0)
                    {
                        Character.Information.Online = 0;
                        //Send packets to network and spawned players
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //We dont send this info to the invited user.
                                if (member != Character.Information.CharacterID)
                                {
                                    //If the user is not the newly invited member get player info
                                    Systems tomember = GetPlayerMainid(member);
                                    //Send guild update packet
                                    if (tomember != null)
                                    {
                                        tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0,0));
                                    }
                                }
                            }
                        }
                        Character.Network.Guild.Members.Remove(Character.Information.CharacterID);
                        Character.Network.Guild.MembersClient.Remove(this.client);
                    }

                    if (this.Character.Transport.Right) this.Character.Transport.Horse.DeSpawnMe();
                    if (this.Character.Grabpet.Active) this.Character.Grabpet.Details.DeSpawnMe();
                    if (this.Character.Network.Exchange.Window) this.Exchange_Close();

                    #region Friend list
                    MsSQL ms = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
                    int count = ms.Count();
                    if (count >= 0)
                    {
                        using (SqlDataReader reader = ms.Read())
                        {
                            while (reader.Read())
                            {
                                int getid = reader.GetInt32(2);
                                Systems sys = GetPlayerid(getid);
                                if (sys != null)
                                {
                                    sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, true));
                                }
                            }
                        }
                    }
                    else
                    {
                        client.Send(Packet.SendFriendListstatic());
                    }
                    #endregion
                    BuffAllClose();
                    DeSpawnMe();
                    SavePlayerPosition();
                    SavePlayerInfo();
                    this.client.Close();
                    this.Character.Dispose();
                    this.Dispose();
                    Character.InGame = false;
                    Disconnect("normal");
                    lock (Systems.clients)
                    {
                        Systems.clients.Remove(this);
                    }
                }
            }
            catch (NullReferenceException nex)
            {
                Console.WriteLine("Timer.PingTimerCallBack: {0}", nex);
                PingStop();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Debug error: {0}", ex);
            }
        }
コード例 #41
0
ファイル: Playerinventory.cs プロジェクト: CarlosX/DarkEmu
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Repair Items
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void HandleRepair(byte slot, int itemid)
 {
     try
     {
         //Here we use 2nd check for item durability to be sure the item repair is needed.
         //Check max durability on items < Need to check later for stats
         double checkdurability = Data.ItemBase[itemid].Defans.Durability;
         //Load our items
         MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "'");
         using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
         {
             while (reader.Read())
             {
                 //Read durability from db
                 int currentdurability = reader.GetInt32(7);
                 //If durability is lower then item durability
                 if (currentdurability < checkdurability)
                 {
                     //Send repair packet to client
                     client.Send(Packet.RepairItems(slot, checkdurability));
                     //Update database information
                     MsSQL.UpdateData("UPDATE char_items SET durability='" + checkdurability + "' WHERE id='" + itemid + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'");
                 }
             }
         }
         ms.Close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Repair item error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
コード例 #42
0
ファイル: CharacterLoading.cs プロジェクト: CarlosX/DarkEmu
 public void PlayerDataLoad()
 {
     //Wrap our function inside a catcher
     try
     {
         //////////////////////////////////////////////////////////////////////////////////////
         // Load Character Data
         //////////////////////////////////////////////////////////////////////////////////////
         #region Character Data
         //If Character is null we return
         if (Character == null) return;
         //Set new sql query for character information
         MsSQL ms = new MsSQL("SELECT * FROM character WHERE name='" + Character.Information.Name + "'");
         //Open new sql data reader
         using (SqlDataReader reader = ms.Read())
         {
             //While our reader is reading the information
             while (reader.Read())
             {
                 // Character id information
                 Character.Information.CharacterID = reader.GetInt32(0);
                 Character.Ids = new Global.ID(Character.Information.CharacterID, Global.ID.IDS.Player);
                 Character.Information.UniqueID = Character.Ids.GetUniqueID;
                 Character.Account.ID = Player.ID;
                 // Character model information
                 Character.Information.Model = reader.GetInt32(3);
                 Character.Information.Race = Data.ObjectBase[Character.Information.Model].Race;
                 Character.Information.Volume = reader.GetByte(4);
                 // Character base stats
                 Character.Information.Level = reader.GetByte(5);
                 Character.Stat.Strength = reader.GetInt16(6);
                 Character.Stat.Intelligence = reader.GetInt16(7);
                 Character.Information.Attributes = reader.GetInt16(8);
                 Character.Stat.Hp = reader.GetInt32(9);
                 Character.Stat.Mp = reader.GetInt32(10);
                 // Character gold information
                 Character.Information.Gold = reader.GetInt64(11);
                 // Character Points
                 Character.Information.XP = reader.GetInt64(12);
                 Character.Information.SpBar = reader.GetInt32(13);
                 Character.Information.SkillPoint = reader.GetInt32(14);
                 // Character GM information
                 Character.Information.GM = reader.GetByte(15);
                 // Character Location
                 Character.Position.xSec = reader.GetByte(16);
                 Character.Position.ySec = reader.GetByte(17);
                 Character.Position.x = reader.GetInt32(19);
                 Character.Position.y = reader.GetInt32(20);
                 Character.Position.z = reader.GetInt32(21);
                 Character.Information.Place = reader.GetByte(40);
                 // Character Main Stats
                 Character.Stat.SecondHp = reader.GetInt32(22);
                 Character.Stat.SecondMP = reader.GetInt32(23);
                 Character.Stat.MinPhyAttack = reader.GetInt32(24);
                 Character.Stat.MaxPhyAttack = reader.GetInt32(25);
                 Character.Stat.MinMagAttack = reader.GetInt32(26);
                 Character.Stat.MaxMagAttack = reader.GetInt32(27);
                 Character.Stat.PhyDef = reader.GetInt16(28);
                 Character.Stat.MagDef = reader.GetInt16(29);
                 Character.Stat.Hit = reader.GetInt16(30);
                 Character.Stat.Parry = reader.GetInt16(31);
                 Character.Speed.WalkSpeed = reader.GetInt32(33);
                 Character.Speed.RunSpeed = reader.GetInt32(34);
                 Character.Speed.BerserkSpeed = reader.GetInt32(35);
                 Character.Information.BerserkBar = reader.GetByte(36);
                 Character.Speed.DefaultSpeed = Character.Speed.RunSpeed;
                 Character.Stat.mag_Absorb = reader.GetInt16(38);
                 Character.Stat.phy_Absorb = reader.GetInt16(39);
                 // Character Other information
                 Character.Information.Pvpstate = reader.GetByte(45);
                 Character.Account.StorageGold = Player.pGold;
                 Character.Account.StorageSlots = Player.wSlots;
                 Character.Information.ExpandedStorage = reader.GetByte(53);
                 Character.LogNum = 53;
                 Character.Information.Slots = reader.GetInt32(44);
                 Character.Information.Title = reader.GetByte(41);
                 Character.Information.Online = reader.GetInt32(47);
                 Character.Information.StallModel = reader.GetInt32(52);
                 // Character Guide Info
                 Character.Guideinfo.G1 = new int[8];//Main Int Array Fro Guide Packet
                 Character.Guideinfo.Gchk = new int[8];//Main Guide Check Packet Array
                 //Read guide information
                 string Guideread = reader.GetString(51);
                 int t = 0;
                 for (int g = 0; g < 8; ++g)
                 {
                     Character.Guideinfo.G1[g] = int.Parse(Guideread.Substring(t, 2), System.Globalization.NumberStyles.HexNumber, null);
                     t = t + 2;
                 }
                 for (int gc = 0; gc < 8; ++gc)
                 {
                     Character.Guideinfo.Gchk[gc] = 0;
                 }
                 //Get guild joinable bool information
                 Character.Information.JoinGuildWait = Convert.ToBoolean(reader.GetByte(54));
                 //Get date time information and timespan information
                 DateTime WaitTime = reader.GetDateTime(55);
                 //Set timespan information
                 TimeSpan Timespan = WaitTime - DateTime.Now;
                 //If total minutes wait time is lower then 0
                 if (Timespan.TotalMinutes <= 0)
                 {
                     //Update database
                     MsSQL.UpdateData("UPDATE character SET GuildJoining='0' WHERE name='"+ Character.Information.Name +"'");
                     //Set bool to false so player can join a guild again
                     Character.Information.JoinGuildWait = false;
                 }
             }
         }
         //Close our sql data reader
         ms.Close();
         #endregion
         //////////////////////////////////////////////////////////////////////////////////////
         // Set Skill And Mastery Information Max
         //////////////////////////////////////////////////////////////////////////////////////
         #region Set Skill / Mastery
         Character.Stat.Skill.Mastery = new int[9];
         Character.Stat.Skill.Mastery_Level = new byte[9];
         Character.Stat.Skill.Skill = new int[50000];
         #endregion
         //////////////////////////////////////////////////////////////////////////////////////
         // Load Mastery Data
         //////////////////////////////////////////////////////////////////////////////////////
         #region Load Mastery Data
         //New sql query to get mastery information
         ms = new MsSQL("SELECT * FROM mastery WHERE owner='" + Character.Information.CharacterID + "'");
         //Open new sql data reader
         using (SqlDataReader reader = ms.Read())
         {
             //Set byte to 1 default
             byte c = 1;
             //While sql data reader is reading
             while (reader.Read())
             {
                 //We add the mastery information and level
                 Character.Stat.Skill.Mastery[c] = reader.GetInt32(1);
                 Character.Stat.Skill.Mastery_Level[c] = reader.GetByte(2);
                 c++;
             }
         }
         //Close our sql data reader
         ms.Close();
         #endregion
         //////////////////////////////////////////////////////////////////////////////////////
         // Load Skill Data
         //////////////////////////////////////////////////////////////////////////////////////
         #region Load Skill Data
         //Create new query to get skill data
         ms = new MsSQL("SELECT * FROM saved_skills WHERE owner='" + Character.Information.CharacterID + "'");
         //Get skill count from reader
         using (SqlDataReader reader = ms.Read())
             Character.Stat.Skill.AmountSkill = ms.Count();
         //Set default i to 1
         int i = 1;
         //Open new sql data reder
         using (SqlDataReader reader = ms.Read())
         {
             //While the reader is reading
             while (reader.Read())
             {
                 //Add the skill id
                 Character.Stat.Skill.Skill[i] = reader.GetInt32(2);
                 i++;
             }
         }
         //Close the sql data reader
         ms.Close();
         #endregion
         //////////////////////////////////////////////////////////////////////////////////////
         // Load Remaining information
         //////////////////////////////////////////////////////////////////////////////////////
         #region Load Remaining Data
         //Update x / y
         UpdateXY();
         //If character's current hp is lower then 1
         if (Character.Stat.SecondHp < 1)
         {
             //Reset player location to return point, and fill the hp half of the max.
             Character.Stat.SecondHp = (Character.Stat.Hp / 2);
             Teleport_UpdateXYZ(Character.Information.Place);
         }
         //Set balande for player
         SetBalance();
         //Check our file information
         CheckFile();
         //Set stats for player
         SetStat();
         #endregion
     }
     catch (Exception ex)
     {
         Console.WriteLine("Player Data Load Error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
コード例 #43
0
ファイル: ItemChecks.cs プロジェクト: CarlosX/DarkEmu
 /////////////////////////////////////////////////////////////////////////////////
 // Get Max Slots
 /////////////////////////////////////////////////////////////////////////////////
 public byte GetFreeSlotMax()
 {
     #region Get Max Slots Available
     List<byte> ListSlot = new List<byte>(Character.Information.Slots);
     MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0'");
     using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
     {
         while (reader.Read())
         {
             ListSlot.Add(reader.GetByte(5));
         }
     }
     ms.Close();
     byte add = 0;
     for (byte i = 13; i < Character.Information.Slots; i++)
     {
         if (!GetCheckFreeSlot(ListSlot, i)) add++;
     }
     return add;
     #endregion
 }
コード例 #44
0
ファイル: ItemChecks.cs プロジェクト: CarlosX/DarkEmu
 /////////////////////////////////////////////////////////////////////////////////
 // Get player inventory items (We will use this for stacking and checking).
 // So herer's the simple one ive made we can use to check player inventory
 /////////////////////////////////////////////////////////////////////////////////
 public static List<byte> GetPlayerItems(character c)
 {
     List<byte> items = new List<byte>();
     MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "'");
     using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
     {
         while (reader.Read())
         {
             items.Add(reader.GetByte(5));
         }
     }
     ms.Close();
     return items;
 }
コード例 #45
0
ファイル: ItemChecks.cs プロジェクト: CarlosX/DarkEmu
 public static byte GetAmmoSlot(character ch)
 {
     MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + ch.Information.CharacterID + "' AND (itemid='62' OR itemid='3655' OR itemid='10376' OR itemid='10727')");
     byte ammo = 0;
     using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
     {
         while (reader.Read())
         {
             ammo = reader.GetByte(5);
         }
         ms.Close();
         return Convert.ToByte(ammo);
     }
 }
コード例 #46
0
ファイル: AttackPet.cs プロジェクト: CarlosX/DarkEmu
 void HandleAttackPet(byte slot, int ItemID)
 {
     try
     {
         //Check if player level is high enough to spawn.
         if (!CheckItemLevel(Character.Information.Level, ItemID))
         {
             client.Send(Packet.MoveItemError(0x6C, 0x18));
         }
         //If ok we continue to spawn the attack pet.
         else
         {
             //Our sql query
             MsSQL ms = new MsSQL("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
             //Create new pet object.
             pet_obj o = new pet_obj();
             //Open our data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //Start reading data from the query above.
                 while (reader.Read())
                 {
                     Character.Attackpet.Uniqueid = reader.GetInt32(11);
                     Character.Attackpet.Spawned = true;
                     o.UniqueID                  = Character.Attackpet.Uniqueid;
                     o.Model                     = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName);                            o.Level                     = reader.GetByte(13);
                     o.exp                       = reader.GetInt64(14);
                     o.x                         = Character.Position.x + rnd.Next(1, 3);
                     o.z                         = Character.Position.z;
                     o.y                         = Character.Position.y + rnd.Next(1, 3);
                     o.xSec                      = Character.Position.xSec;
                     o.ySec                      = Character.Position.ySec;
                     o.OwnerID                   = Character.Information.CharacterID;
                     o.OwnerName                 = Character.Information.Name;
                     o.Walking                   = Character.Position.Walking;
                     o.Petname                   = reader.GetString(3);
                     o.Named                     = 3;
                     o.Run                       = Character.Speed.RunSpeed;
                     o.Walk                      = Character.Speed.WalkSpeed;
                     o.Zerk                      = Character.Speed.BerserkSpeed;
                 }
                 ms.Close();
             }
             //We set our pet active bool, so user cannot spawn multiple.
             Character.Attackpet.Active = true;
             o.Information = true;
             //Set all details above to definitions
             Character.Attackpet.Details = o;
             //Global spawn the pet
             Systems.HelperObject.Add(o);
             //Spawn ourselfs
             o.SpawnMe();
             //Send then packet required (Pet information block).
             client.Send(Packet.AttackPetStats(o, slot));
             client.Send(Packet.AttackPetHGP(o));
             //Update pet status to active (For relog purposes).
             MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Attack pet spawn error : " + ex);
     }
 }
コード例 #47
0
ファイル: Teleporting.cs プロジェクト: CarlosX/DarkEmu
        //###########################################################################################
        // Reverse scrolls
        //###########################################################################################
        void HandleReverse(int itemid ,byte select, int objectlocationid)
        {
            try
            {
                //Remove loc // add loc to case 7
                if (Character.Position.Walking) StopMovementTimer();
                if (Character.Action.PickUping) return;
                if (Character.Stall.Stallactive) return;
                Character.Information.Scroll = true;
                StopTimers();
                switch (select)
                {
                    //Move to return point
                    case 2:
                        Send(Packet.StatePack(Character.Information.UniqueID, 0x0B, 0x01, false));
                        StartScrollTimer(1000);
                        SavePlayerReturn();
                        break;
                    //Move to last recall point
                    case 3:
                        MsSQL ms = new MsSQL("SELECT * FROM character_rev WHERE charname='" + Character.Information.Name + "'");
                        using (SqlDataReader reader = ms.Read())
                        {
                            while (reader.Read())
                            {
                                byte xSec = reader.GetByte(2);
                                byte ySec = reader.GetByte(3);
                                float x = reader.GetInt32(4);
                                float z = reader.GetInt32(6);
                                float y = reader.GetInt32(5);

                                BuffAllClose();
                                DeSpawnMe();
                                ObjectDeSpawnCheck();
                                client.Send(Packet.TeleportOtherStart());
                                //Set state
                                this.Character.InGame = false;
                                Character.Position.xSec = xSec;
                                Character.Position.ySec = ySec;
                                Character.Position.x = x;
                                Character.Position.z = z;
                                Character.Position.y = y;

                                client.Send(Packet.TeleportImage(xSec, ySec));
                                Character.Teleport = true;
                                Timer.Scroll = null;
                                Character.Information.Scroll = false;
                            }
                        }
                        ms.Close();
                        break;
                    //Teleport to map location
                    case 7:
                        BuffAllClose();
                        ObjectDeSpawnCheck();
                        DeSpawnMe();

                        client.Send(Packet.TeleportOtherStart());

                        Character.Position.xSec = Data.ReverseData[objectlocationid].xSec;
                        Character.Position.ySec = Data.ReverseData[objectlocationid].ySec;
                        Character.Position.x = (float)Data.ReverseData[objectlocationid].x;
                        Character.Position.z = (float)Data.ReverseData[objectlocationid].z;
                        Character.Position.y = (float)Data.ReverseData[objectlocationid].y;
                        //Set state
                        this.Character.InGame = false;

                        client.Send(Packet.TeleportImage(Data.ReverseData[objectlocationid].xSec, Data.ReverseData[objectlocationid].ySec));
                        Character.Teleport = true;
                        Timer.Scroll = null;
                        Character.Information.Scroll = false;
                        break;
                }
            }

            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #48
0
ファイル: PrivateMessages.cs プロジェクト: CarlosX/DarkEmu
 void PrivateMessageSend()
 {
     try
     {
         //Create new packet reader for reading packet data
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read lenght of charactername we send the message to
         short ToCharacterLen = Reader.Int16();
         //Read the name of the character we send the message to
         string ToCharacter = Reader.String(ToCharacterLen);
         //Read lenght of message characters
         short MessageLen = Reader.Int16();
         //Read message
         string Message = Reader.String(MessageLen);
         //Close packet reader
         Reader.Close();
         //Create new mssql query for sending and checking
         MsSQL ms = new MsSQL("SELECT * FROM character WHERE name='" + ToCharacter + "'");
         //Check if the player exists
         int PlayerExists = ms.Count();
         //If the player exists
         if (PlayerExists > 0)
         {
             //First get details of the player we send the message to.
             Systems sys = GetPlayerName(ToCharacter);
             //Make sure we dont get a null error
             if (sys.Character != null)
             {
                 //Check how many messages the player has if inbox is full or not
                 int TargetMessageCount = MsSQL.GetRowsCount("SELECT * FROM message WHERE receiver='" + sys.Character.Information.CharacterID + "'");
                 //If less then 50 we continue
                 if (TargetMessageCount < 50)
                 {
                     //Set temp int to character data for new message order
                     sys.Character.Information.MessageCount = TargetMessageCount;
                     //Insert new message into the database
                     MsSQL.InsertData("INSERT INTO message (sender, receiver, message, status, time) VALUES ('" + Character.Information.Name + "','" + ToCharacter + "','" + Message + "','0','" + DateTime.Now + "')");
                     //Send packet message has been send to our client
                     client.Send(PrivateMessageRespond(2));
                     //Send packet to receiver information new message has arrived
                     sys.Send(Packet.FriendData(sys.Character.Information.UniqueID, 5, ToCharacter, Character, false));
                 }
                 //If inbox is full
                 else
                 {
                     //Send message to sender and receiver inbox full
                     client.Send(PrivateMessageRespond(3));
                     sys.client.Send(PrivateMessageRespond(3));
                 }
             }
         }
         //If player doesn't exist
         else
         {
             //Send packet message failed to send to our client.
             client.Send(PrivateMessageRespond(1));
         }
     }
     //Catch any bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Error sending messages : {0}" + ex);
         //Write info to the debug logger.
         Systems.Debugger.Write(ex);
     }
 }
コード例 #49
0
ファイル: CharacterLoading.cs プロジェクト: CarlosX/DarkEmu
        public void LoadUnions()
        {
            try
            {
                //First clear out the guild union info (will clean this later).
                if (Character.Network.Guild.Unions != null)
                {
                    Character.Network.Guild.Unions = null;
                    Character.Network.Guild.UnionMembers = null;
                    Character.Network.Guild.UnionLeader = 0;
                    Character.Network.Guild.UniqueUnion = 0;
                }
                //Then we query the row guildid
                int my_union = MsSQL.GetDataInt("SELECT union_unique_id FROM guild_unions WHERE union_guildid='" + Character.Network.Guild.Guildid + "'", "union_unique_id");
                //If 0 means we check if we are the union leaders
                if (my_union == 0)
                {
                    //Check for union leader
                    my_union = MsSQL.GetDataInt("SELECT union_unique_id FROM guild_unions WHERE union_leader='" + Character.Network.Guild.Guildid + "'", "union_unique_id");
                    //If we are the union leader
                    if (my_union > 0)
                        Character.Network.Guild.UnionLeader = Character.Network.Guild.Guildid;
                }

                //If union is active so count higher then 0
                if (my_union > 0)
                {
                    MsSQL unions = new MsSQL("SELECT * FROM guild_unions WHERE union_unique_id='" + my_union + "'");
                    //Open new sql data reader
                    using (SqlDataReader reader = unions.Read())
                    {
                        //While our reader is reading the information
                        while (reader.Read())
                        {
                            //Check if we allready have main info loaded
                            //If the union leader isnt the loading guild
                            if (Character.Network.Guild.UnionLeader == 0)
                                Character.Network.Guild.UnionLeader = reader.GetInt32(1);
                            //Add union to the listening
                            Character.Network.Guild.Unions.Add(reader.GetInt32(2));
                            //Set union active
                            Character.Network.Guild.UnionActive = true;
                        }
                        // Repeat for each guild in our union
                        foreach (int guild in Character.Network.Guild.Unions)
                        {
                            //Make sure the guild isnt 0
                            if (guild != 0)
                            {
                                //Get guildplayer details
                                Systems unionmember = GetGuildPlayer(guild);
                                //Make sure the player isnt null
                                if (unionmember != null)
                                {
                                    //Then add our character id to the member list.
                                    Character.Network.Guild.UnionMembers.Add(Character.Information.CharacterID);
                                }
                            }
                        }
                        //Close our sql reader.
                        reader.Close();
                    }
                    //Finally send packet for union listening
                    client.Send(Packet.UnionInfo(this));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Union Load Error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
コード例 #50
0
ファイル: ItemChecks.cs プロジェクト: CarlosX/DarkEmu
        /////////////////////////////////////////////////////////////////////////////////
        // Get Slot Item Information
        /////////////////////////////////////////////////////////////////////////////////
        static Global.slotItem GetItem(uint id, byte slot, int type)
        {
            #region Slot item info

            try
            {
                if (id != 0)
                {
                    Global.slotItem slotItem = new Global.slotItem();
                    int row = type;

                    MsSQL ms;
                    if (row == 1)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storageacc='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else if (row == 3)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND owner='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }

                    using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                    {
                        while (reader.Read())
                        {
                            slotItem.dbID = reader.GetInt32(0);
                            slotItem.ID = reader.GetInt32(2);
                            slotItem.PlusValue = reader.GetByte(4);
                            slotItem.Amount = reader.GetInt16(6);
                            slotItem.Durability = reader.GetInt32(7);
                            slotItem.Slot = slot;
                            LoadBluesid(slotItem.dbID);
                        }
                    }
                    ms.Close();
                    return slotItem;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Data item load error {0}", ex);
                Systems.Debugger.Write(ex);
            }
            return null;
            #endregion
        }
コード例 #51
0
ファイル: CharacterLoading.cs プロジェクト: CarlosX/DarkEmu
 void GetFriendsList()
 {
     //Wrap our function inside a catcher
     try
     {
         //Set new sql query to get friend information
         MsSQL ms = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
         //Count our friends
         int count = ms.Count();
         //If we have a friend in the list
         if (count > 0)
         {
             //Send our packet
             client.Send(Packet.SendFriendList(Convert.ToByte(count), Character));
             //Open new sql data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //While our sql data reader is reading
                 while (reader.Read())
                 {
                     //Get player id information of friend
                     int getid = reader.GetInt32(2);
                     //Get detailed information for our friend
                     Systems sys = GetPlayerid(getid);
                     //If the character is online
                     if (sys != null)
                     {
                         //We send online state change packet
                         sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, false));
                     }
                 }
             }
             //Close our sql reader
             ms.Close();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error loading friends list {0} ", ex);
         Systems.Debugger.Write(ex);
     }
 }
コード例 #52
0
ファイル: ItemChecks.cs プロジェクト: CarlosX/DarkEmu
        /////////////////////////////////////////////////////////////////////////////////
        // Arrow Item Check
        /////////////////////////////////////////////////////////////////////////////////
        bool ItemCheckArrow()
        {
            #region Check Arrow
            MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='62' AND storagetype='0'");
            if (ms.Count() == 0)
            {
                ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='3823' AND storagetype='0'");
            }
            else if (ms.Count() == 0)
            {
                ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='10302' AND storagetype='0'");
            }
            else if (ms.Count() == 0)
            {
                ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='10487' AND storagetype='0'");
            }
            if (ms.Count() == 0) return false;
            else
            {
                Global.slotItem items = null;
                using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                {
                    while (reader.Read())
                        items = ConvertToItem(reader.GetInt32(2), reader.GetByte(5), reader.GetInt16(6), 1);
                }
                ms.Close();
                MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE itemnumber='" + "item" + items.Slot + "' AND owner='" + Character.Information.CharacterID + "' AND itemid='" + items.ID + "'");
                client.Send(Packet.MoveItem(0, items.Slot, 7, items.Amount, 0, "MOVE_INSIDE_INVENTORY"));

                Character.Information.Item.sAmount = items.Amount;
                Character.Information.Item.sID = items.ID;
                ;
                return true;
            }
            #endregion
        }
コード例 #53
0
ファイル: GuildData.cs プロジェクト: CarlosX/DarkEmu
        public void LoadPlayerGuildInfo(bool logon)
        {
            try
            {
                MsSQL ms = new MsSQL("SELECT * FROM guild_members WHERE guild_member_id='" + Character.Information.CharacterID + "'");
                using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                {
                    while (reader.Read())
                    {
                        Character.Network.Guild.Guildid = reader.GetInt32(1);
                        Character.Network.Guild.GrantName = reader.GetString(5);
                        Character.Network.Guild.FWrank = reader.GetByte(6);
                        Character.Network.Guild.DonateGP = reader.GetInt32(4);
                        Character.Network.Guild.LastDonate = Character.Network.Guild.DonateGP;
                        Character.Network.Guild.joinRight = (reader.GetByte(7) == 1);
                        Character.Network.Guild.withdrawRight = (reader.GetByte(8) == 1);
                        Character.Network.Guild.unionRight = (reader.GetByte(9) == 1);
                        Character.Network.Guild.guildstorageRight = (reader.GetByte(10) == 1);
                        Character.Network.Guild.noticeeditRight = (reader.GetByte(11) == 1);
                    }
                }

                ms = new MsSQL("SELECT * FROM guild WHERE id='" + Character.Network.Guild.Guildid + "'");
                using (System.Data.SqlClient.SqlDataReader reader2 = ms.Read())
                {
                    while (reader2.Read())
                    {
                        Character.Network.Guild.Name = reader2.GetString(1);
                        Character.Network.Guild.Level = reader2.GetByte(2);
                        Character.Network.Guild.PointsTotal = reader2.GetInt32(3);
                        Character.Network.Guild.NewsTitle = reader2.GetString(4);
                        Character.Network.Guild.NewsMessage = reader2.GetString(5);
                        Character.Network.Guild.StorageSlots = reader2.GetInt32(7);
                        Character.Network.Guild.Wargold = reader2.GetInt32(8);
                        Character.Network.Guild.StorageGold = reader2.GetInt64(11);
                        Character.Network.Guild.GuildOwner = reader2.GetInt32(9);
                    }
                }

                ms = new MsSQL("SELECT * FROM guild_members WHERE guild_id='" + Character.Network.Guild.Guildid + "'");
                Character.Network.Guild.TotalMembers = Convert.ToByte(ms.Count());

                ms.Close();
                //Set max players allowed in guild
                switch (Character.Network.Guild.Level)
                {
                    case 1:
                        Character.Network.Guild.MaxMembers = 20;
                        break;
                    case 2:
                        Character.Network.Guild.MaxMembers = 25;
                        break;
                    case 3:
                        Character.Network.Guild.MaxMembers = 30;
                        break;
                    case 4:
                        Character.Network.Guild.MaxMembers = 35;
                        break;
                    case 5:
                        Character.Network.Guild.MaxMembers = 50;
                        break;
                }

                //Only load on player login
                if (logon)
                {
                    LoadGuildMembers();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
                Console.WriteLine("LoadPlayerGuildInfo error {0}", ex);
            }
        }
コード例 #54
0
ファイル: Mastery.cs プロジェクト: CarlosX/DarkEmu
        public void Mastery_Up()
        {
            try
            {
                List<byte> Masteries = new List<byte>();
                MsSQL mastery = new MsSQL("SELECT * FROM mastery WHERE owner='"+Character.Information.CharacterID+"'");
                 using (SqlDataReader reader = mastery.Read())
                    {
                        while (reader.Read())
                        {
                            Masteries.Add(reader.GetByte(2));
                        }

                 }
                int totalmastery = 0;
                int masterylimit = 360;
                bool euchar = false;
                if (Character.Information.Model >= 10000 && Character.Information.Model <= 16000)
                {
                    masterylimit = 239;
                    euchar = true;
                }

                for(int i = 0;i < Masteries.Count;i++)
                {
                    totalmastery += Masteries[i];
                }
                if (totalmastery <= masterylimit)
                {
                    if (!Character.Action.upmasterytimer)
                    {
                        Character.Action.upmasterytimer = true;
                        MasteryupTimer(150);

                        PacketReader Reader = new PacketReader(PacketInformation.buffer);
                        int masteryid = Reader.Int32();
                        byte level = Reader.Byte();
                        byte m_index = MasteryGet(masteryid);

                        if (m_index == 0)
                        {
                            return;
                        }

                        if (!(Character.Information.SkillPoint < Data.MasteryBase[Character.Stat.Skill.Mastery_Level[m_index]]))
                        {
                            if (euchar == true)
                            {
                                if (Character.Stat.Skill.Mastery_Level[m_index] < Character.Information.Level)
                                {

                                    Character.Stat.Skill.Mastery_Level[m_index]++;
                                    Character.Information.SkillPoint -= Data.MasteryBase[Character.Stat.Skill.Mastery_Level[m_index]];

                                    client.Send(Packet.InfoUpdate(2, Character.Information.SkillPoint, 0));
                                    client.Send(Packet.MasteryUpPacket(masteryid, Character.Stat.Skill.Mastery_Level[m_index]));

                                    SaveMaster();

                                }
                            }
                            else
                            {
                                if (Character.Stat.Skill.Mastery_Level[m_index] < Character.Information.Level)
                                {
                                    if (!(Character.Stat.Skill.Mastery_Level[m_index] == 120))
                                    {
                                        Character.Stat.Skill.Mastery_Level[m_index]++;
                                        Character.Information.SkillPoint -= Data.MasteryBase[Character.Stat.Skill.Mastery_Level[m_index]];

                                        client.Send(Packet.InfoUpdate(2, Character.Information.SkillPoint, 0));
                                        client.Send(Packet.MasteryUpPacket(masteryid, Character.Stat.Skill.Mastery_Level[m_index]));

                                        SaveMaster();
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //client.Send(Packet.IngameMessages(SERVER_ACTIONSTATE, IngameMessages.UIIT_STT_SKILL_LEARN_MASTERY_TOTAL_LIMIT));
                    return;
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #55
0
ファイル: Grabpet.cs プロジェクト: CarlosX/DarkEmu
 ///////////////////////////////////////////////////////////////////////////
 // Load grabpet
 ///////////////////////////////////////////////////////////////////////////
 public void HandleGrabPet(byte slot, int ItemID)
 {
     try
     {
         //Checks before we continue (Level check).
         if (!CheckItemLevel(Character.Information.Level, ItemID))
         {
             client.Send(Packet.MoveItemError(0x6C, 0x18));
         }
         //Else we continue
         else
         {
             //Our database query for loading pet information.
             MsSQL ms = new MsSQL("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
             //Get detailed item information.
             Global.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0);
             //Get item model information
             int model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName);
             //Create new pet object
             pet_obj o = new pet_obj();
             //Our sql data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //While our reader is open we read all info below.
                 while (reader.Read())
                 {
                     int itemid                  = reader.GetInt32(7);
                     Character.Grabpet.Grabpetid = item.dbID;
                     o.UniqueID                  = Character.Grabpet.Grabpetid;
                     o.Model                     = model;
                     o.Slots                     = reader.GetByte(8);
                     o.x                         = Character.Position.x + rnd.Next(1, 3);
                     o.z                         = Character.Position.z;
                     o.y                         = Character.Position.y + rnd.Next(1, 3);
                     o.xSec                      = Character.Position.xSec;
                     o.ySec                      = Character.Position.ySec;
                     o.OwnerID                   = Character.Information.CharacterID;
                     o.OwnerName                 = Character.Information.Name;
                     o.Walking                   = Character.Position.Walking;
                     o.Petname                   = reader.GetString(3);
                     o.Named                     = 2;
                     o.Run                       = Character.Speed.RunSpeed;
                     o.Walk                      = Character.Speed.WalkSpeed;
                     o.Zerk                      = Character.Speed.BerserkSpeed;
                 }
                 ms.Close();
             }
             //We set our pet active bool, so user cannot spawn multiple.
             Character.Grabpet.Active    = true;
             o.Information               = true;
             //Set all details above to definitions
             Character.Grabpet.Details   = o;
             //Global spawn the pet
             Systems.HelperObject.Add(o);
             //Spawn ourselfs
             o.SpawnMe();
             //Send then packet required (Pet information block).
             client.Send(Packet.Pet_Information_grab(o, slot));
             //Update pet status to active (For relog purposes).
             MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Grab pet spawn error : " + ex);
     }
 }
コード例 #56
0
ファイル: Timer.cs プロジェクト: CarlosX/DarkEmu
 void Player_Wait_CallBack(object e)
 {
     try
     {
         if (Character.Information.Quit)
         {
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Position.Walking)
             {
                 Character.Position.RecordedTime = 0;
                 Timer.Movement.Dispose();
                 Timer.Movement = null;
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Information.CheckParty)
             {
                 LeaveParty();
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Network.Guild.Guildid != 0)
             {
                 Character.Information.Online = 0;
                 //Send packets to network and spawned players
                 foreach (int member in Character.Network.Guild.Members)
                 {
                     //Make sure the member is there
                     if (member != 0)
                     {
                         //We dont send this info to the invited user.
                         if (member != Character.Information.CharacterID)
                         {
                             //If the user is not the newly invited member get player info
                             Systems tomember = GetPlayerMainid(member);
                             //Send guild update packet
                             if (tomember != null)
                             {
                                 tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0,0));
                             }
                         }
                     }
                 }
                 Character.Network.Guild.Members.Remove(Character.Information.CharacterID);
                 Character.Network.Guild.MembersClient.Remove(this.client);
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Transport.Right) Character.Transport.Horse.DeSpawnMe();
             if (Character.Grabpet.Active) UnSummonPetLogoff(Character.Grabpet.Details.UniqueID);
             if (Character.Attackpet.Active) UnSummonPetLogoff(Character.Attackpet.Details.UniqueID);
             if (Character.Network.Exchange.Window) Exchange_Close();
             //##############################################
             // checks before logout
             //##############################################
             MsSQL ms = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
             int count = ms.Count();
             if (count >= 0)
             {
                 using (SqlDataReader reader = ms.Read())
                 {
                     while (reader.Read())
                     {
                         int getid = reader.GetInt32(2);
                         Systems sys = GetPlayerid(getid);
                         if (sys != null)
                         {
                             sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, true));
                         }
                     }
                 }
             }
             //##############################################
             // Send packet leave game
             //##############################################
             client.Send(Packet.EndLeaveGame());
             //##############################################
             // Updated database
             //##############################################
             MsSQL.UpdateData("UPDATE character SET online='0' WHERE id='" + Character.Information.CharacterID + "'");
             //##############################################
             // Remove all remaining parts
             //##############################################
             BuffAllClose();
             DeSpawnMe();
             SavePlayerPosition();
             SavePlayerInfo();
             this.client.Close();
             this.Character.Dispose();
             this.Dispose();
             Character.InGame = false;
             Disconnect("normal");
         }
         Timer.Logout.Dispose();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Logout error: {0}", ex);
     }
 }
コード例 #57
0
ファイル: ItemAdding.cs プロジェクト: CarlosX/DarkEmu
        /////////////////////////////////////////////////////////////////////////////////
        // Add items to database
        /////////////////////////////////////////////////////////////////////////////////
        public void AddItem(int itemid, short prob, byte slot, int id, int modelid)
        {
            #region Add item to db
            try
            {
                if (Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BLADE ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_SHIELD ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BOW ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_AXE ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_HARP ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.GLAVIE ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.SPEAR ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.SWORD ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EARRING ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.RING ||
                     Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.NECKLACE ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.ARMOR ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.GARMENT ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.GM ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.HEAVY ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.LIGHT ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.PROTECTOR ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.AVATAR ||
                     Data.ItemBase[itemid].Type == Global.item_database.ArmorType.ROBE)
                {
                    MsSQL.UpdateData("Insert Into char_items (itemid,plusvalue,durability,owner,itemnumber,slot,storageacc,inavatar,storagetype,charbound) VALUES ('" + itemid + "','" + prob + "','" + Data.ItemBase[itemid].Defans.Durability + "','" + id + "','item" + slot + "','" + slot + "','" + Player.ID + "','0','0','" + Data.ItemBase[itemid].SoulBound + "' )");

                }
                else if (Data.ItemBase[itemid].Pettype == Global.item_database.PetType.GRABPET)
                {
                    MsSQL.UpdateData("Insert Into char_items (itemid,plusvalue,durability,owner,itemnumber,slot,storageacc,charbound) VALUES ('" + itemid + "','" + 0 + "','" + Data.ItemBase[itemid].Defans.Durability + "','" + id + "','item" + slot + "','" + slot + "','" + Player.ID + "','" + Data.ItemBase[itemid].SoulBound + "')");

                    MsSQL ms = new MsSQL("SELECT TOP 1 * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' ORDER BY id DESC");
                    using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                    {
                        while (reader.Read())
                        {
                            int idinfo = reader.GetInt32(0);
                            MsSQL.UpdateData("Insert Into pets (playerid, pet_type, pet_name, pet_state, pet_itemid, pet_active, pet_check, pet_unique) VALUES ('" + Character.Information.CharacterID + "','4','No name','1','" + itemid + "','0','item" + slot + "','" + idinfo + "')");
                        }
                    }
                    ms.Close();
                }
                else if (Data.ItemBase[itemid].Pettype == Global.item_database.PetType.ATTACKPET)
                {
                    MsSQL.UpdateData("Insert Into char_items (itemid,plusvalue,durability,owner,itemnumber,slot,storageacc,charbound) VALUES ('" + itemid + "','" + 0 + "','" + Data.ItemBase[itemid].Defans.Durability + "','" + id + "','item" + slot + "','" + slot + "','" + Player.ID + "','" + Data.ItemBase[itemid].SoulBound + "')");

                    MsSQL ms = new MsSQL("SELECT TOP 1 * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' ORDER BY id DESC");
                    using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                    {
                        while (reader.Read())
                        {
                            int idinfo = reader.GetInt32(0);
                            MsSQL.UpdateData("Insert Into pets (playerid, pet_type, pet_name, pet_state, pet_itemid, pet_active, pet_check, pet_unique) VALUES ('" + Character.Information.CharacterID + "','2','No name','1','" + itemid + "','0','item" + slot + "','" + idinfo + "')");
                        }
                    }
                    ms.Close();
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.STONES)
                {
                    MsSQL.UpdateData("Insert Into char_items (itemid,plusvalue,durability,owner,itemnumber,slot,storageacc,inavatar,storagetype,charbound) VALUES ('" + itemid + "','" + 0 + "','" + 0 + "','" + id + "','item" + slot + "','" + slot + "','" + Player.ID + "','0','0','" + Data.ItemBase[itemid].SoulBound + "' )");
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.MONSTERMASK)
                {
                    MsSQL.UpdateData("Insert Into char_items (itemid,plusvalue,durability,owner,itemnumber,slot,storageacc,modelid,charbound) VALUES ('" + itemid + "','" + 0 + "','" + 0 + "','" + id + "','item" + slot + "','" + slot + "','" + Player.ID + "','" + modelid + "','" + Data.ItemBase[itemid].SoulBound + "' )");
                }
                else
                {
                    if (prob < 2) prob = 1;
                    MsSQL.UpdateData("Insert Into char_items (itemid,quantity,owner,itemnumber,slot,storageacc,charbound) VALUES ('" + itemid + "','" + prob + "','" + id + "','item" + slot + "','" + slot + "','" + Player.ID + "','" + Data.ItemBase[itemid].SoulBound + "' )");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("DB Item add error: ", ex);
            }
            #endregion
        }
コード例 #58
0
ファイル: PrivateMessages.cs プロジェクト: CarlosX/DarkEmu
 void PrivateMessageDelete()
 {
     try
     {
         //Create new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read message selected id
         byte SelectedMessageID = Reader.Byte();
         //Close packet reader
         Reader.Close();
         //Create new integer to get message id
         int Messageid = -1;
         //Create new mssql query
         MsSQL ms = new MsSQL("SELECT * FROM message WHERE receiver='" + Character.Information.Name + "' ORDER BY time DESC");
         //Create new sql data reader for reading column information
         using (SqlDataReader reader = ms.Read())
         {
             //While our sql data reader is reading
             while (reader.Read())
             {
                 //Read message content
                 string MessageContent = reader.GetString(3);
                 //Increase our message id integer
                 Messageid += 1;
                 //Check if the messageid equals to our selected message
                 if (Messageid == SelectedMessageID)
                 {
                     //Create new packet writer
                     PacketWriter Writer = new PacketWriter();
                     //Add opcode for deleting message
                     Writer.Create(Systems.SERVER_PM_DELETE);
                     //Write static byte 1
                     Writer.Byte(0x01);
                     //Write byte selected message id
                     Writer.Byte(SelectedMessageID);
                     //Send packet to client
                     client.Send(Writer.GetBytes());
                     //Update database
                     MsSQL.DeleteData("DELETE FROM message WHERE message='" + reader.GetString(3) + "' AND receiver='"+ Character.Information.CharacterID +"'");
                 }
             }
         }
         //Close mssql
         ms.Close();
     }
     //If an error happens
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Delete private message error: " + ex);
         //Write info to debugger
         Systems.Debugger.Write(ex);
     }
 }
コード例 #59
0
ファイル: Ranks.cs プロジェクト: CarlosX/DarkEmu
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Job Ranks
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void RankList()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                /////////////////////////////////////////////////////////////////////////////////////
                int Notneeded = Reader.Int32();
                byte Type = Reader.Byte();
                byte Choice = Reader.Byte();
                /////////////////////////////////////////////////////////////////////////////////////

                /////////////////////////////////////////////////////////////////////////////////////
                // Rank Trader
                /////////////////////////////////////////////////////////////////////////////////////
                if (Type == 1)
                {
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank Trader Merchant Activity
                    /////////////////////////////////////////////////////////////////////////////////////
                    if (Choice == 0)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_activity WHERE job_type='1'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsActivityTrader());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Rank Trader Merchant Activity error: " + ex);
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank Trader Weekly Donation
                    /////////////////////////////////////////////////////////////////////////////////////
                    else if (Choice == 1)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='1'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsDonateTrader());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Rank Trader Weekly Donation: " + ex);
                        }
                    }
                }
                /////////////////////////////////////////////////////////////////////////////////////
                // Rank List Thief
                /////////////////////////////////////////////////////////////////////////////////////
                else if (Type == 3)
                {
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Thief Activity
                    /////////////////////////////////////////////////////////////////////////////////////
                    if (Choice == 0)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_activity WHERE job_type='3'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsActivityThief());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Thief rank activity error: " + ex);
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Thief Weekly Donation
                    /////////////////////////////////////////////////////////////////////////////////////
                    else if (Choice == 1)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='2'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsDonateThief());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Rank List Thief Weekly Donation: " + ex);
                        }
                    }
                }
                /////////////////////////////////////////////////////////////////////////////////////
                // Rank List Hunter
                /////////////////////////////////////////////////////////////////////////////////////
                else if (Type == 2) //Type 2 = Hunter
                {
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Hunter Activity
                    /////////////////////////////////////////////////////////////////////////////////////
                    if (Choice == 0)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_activity WHERE job_type='2'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsActivityHunter());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Hunter rank activity error: " + ex);
                        }
                    }
                    /////////////////////////////////////////////////////////////////////////////////////
                    // Rank List Hunter Weekly Contribution
                    /////////////////////////////////////////////////////////////////////////////////////
                    else if (Choice == 1)
                    {
                        try
                        {
                            MsSQL readsql = new MsSQL("SELECT TOP 50 * FROM rank_job_donate WHERE job_type='3'");
                            int begin = 0;
                            int count = readsql.Count();
                            using (SqlDataReader readinfo = readsql.Read())
                            {
                                while (readinfo.Read())
                                {
                                    for (begin = 0; begin < count; )
                                    {
                                        begin++;
                                        if (begin.Equals(count))
                                        {
                                            client.Send(Packet.RankListsDonateHunter());
                                            return;
                                        }
                                    }
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Hunter Weekly Contribution error: " + ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Job rank loading error : " + ex);
            }
        }
コード例 #60
0
ファイル: Grabpet.cs プロジェクト: CarlosX/DarkEmu
 ///////////////////////////////////////////////////////////////////////////
 // Rename grab pet
 ///////////////////////////////////////////////////////////////////////////
 void RenamePet()
 {
     try
     {
         //Start reading packet data
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Pet id
         int petid           = Reader.Int32();
         //Pet name lenght
         short petnamel      = Reader.Int16();
         //Pet name
         string petname      = Reader.String(petnamel);
         //Check availability for pet name.
         int nameavailable   = MsSQL.GetRowsCount("SELECT pet_name FROM pets WHERE pet_name='" + petname + "'");
         //If available (Row count is zero).
         if (nameavailable == 0)
         {
             //Create the query we will use
             MsSQL ms = new MsSQL("SELECT * FROM pets WHERE playerid='" + Character.Information.CharacterID + "' AND pet_unique='" + petid + "'");
             //Open our data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //While the reader is reading from database
                 while (reader.Read())
                 {
                     //First we check the lenght of the name.
                     if (petnamel < 3)
                     {
                         client.Send(Packet.IngameMessages(SERVER_PET_RENAME_MSG, IngameMessages.UIIT_MSG_COSPETERR_PETNAME_NOTPUT));
                     }
                     //Check if renamed allready. (Should not be needed just extra check)
                     if (Character.Grabpet.Details != null)
                     {
                         if (petid == Character.Grabpet.Details.UniqueID)
                         {
                             if (Character.Grabpet.Details.Petname == "No name")
                             {
                                 //Update name in database
                                 MsSQL.UpdateData("UPDATE pets SET pet_state='2',pet_name='" + petname + "' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'");
                                 //Send needed packets to update name (Official sends 2 times)...
                                 client.Send(Packet.PetSpawn(petid, 2, Character.Grabpet.Details));
                                 //Send to all currently in spawn range
                                 Send(Packet.PetSpawn(petid, 2, Character.Grabpet.Details));
                             }
                         }
                     }
                     //Check if renamed allready. (Should not be needed just extra check)
                     if (Character.Attackpet.Details != null)
                     {
                         if (petid == Character.Attackpet.Details.UniqueID)
                         {
                             if (Character.Attackpet.Details.Petname == "No name")
                             {
                                 //Update name in database
                                 MsSQL.UpdateData("UPDATE pets SET pet_state='2',pet_name='" + petname + "' WHERE pet_unique='" + petid + "' AND playerid='" + Character.Information.CharacterID + "'");
                                 //Send needed packets to update name (Official sends 2 times)...
                                 client.Send(Packet.PetSpawn(petid, 2, Character.Attackpet.Details));
                                 //Send to all currently in spawn range
                                 Send(Packet.PetSpawn(petid, 2, Character.Attackpet.Details));
                             }
                         }
                     }
                 }
             }
         }
         //If name has been taken
         else
         {
             //Not sure if correct msg.
             client.Send(Packet.IngameMessages(SERVER_PET_RENAME_MSG, IngameMessages.UIIT_MSG_COSPETERR_PETNAME_NOTPUT));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Grab pet renaming error : " + ex);
     }
 }