public void PlayerConnectMessengerServer(GPlayer PL)
        {
            var db = new PangyaEntities();

            try
            {
                var server = db.ProcGetMessengerServer().ToList();
                PL.Response.Write(new byte[] { 0xFC, 0x00 });
                PL.Response.Write((byte)server.Count);
                foreach (var servidor in server)
                {
                    PL.Response.WriteStr(servidor.Name, 40);
                    PL.Response.Write(servidor.ServerID);
                    PL.Response.Write(servidor.MaxUser);        //Max Users
                    PL.Response.Write(PL.Server.Players.Count); //total de players conectados
                    PL.Response.WriteStr(servidor.IP, 18);
                    PL.Response.Write(servidor.Port);
                    PL.Response.Write(4096);//propriedade
                    PL.Response.WriteZero(13);
                }
                PL.SendResponse();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
        }
Exemplo n.º 2
0
        protected override void ServerExpection(Player Client, Exception Ex)
        {
            var player = (GPlayer)Client;
            var _db    = new PangyaEntities();

            try
            {
                var query = $" exec dbo.ProcSaveExceptionLog @UID = '{player.GetUID}', @USER =  '******', @EXCEPTIONMESSAGE= '{Ex.Message}', @SERVER = '{Data.Name}'";

                _db.Database.SqlQuery <PangyaEntities>(query);

                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(Ex, true);
                var FileWrite = new StreamWriter("GameLog.txt", true);
                FileWrite.WriteLine($"--------------------------- PLAYER_EXCEPTION ------------------------------------------");
                FileWrite.WriteLine($"Date: {DateTime.Now}");
                FileWrite.WriteLine($"Server_Info: NAME {Data.Name}, ID {Data.UID}, PORT {Data.Port}");
                FileWrite.WriteLine(trace.GetFrame(0).GetMethod().ReflectedType.FullName);
                FileWrite.WriteLine("Method: " + Ex.TargetSite);
                FileWrite.WriteLine("Line: " + trace.GetFrame(0).GetFileLineNumber());
                FileWrite.WriteLine("Column: " + trace.GetFrame(0).GetFileColumnNumber());
                FileWrite.WriteLine($"--------------------------- END ------------------------------------------");
                FileWrite.Dispose();
                if (player.Connected)
                {
                    DisconnectPlayer(player);
                }
            }
            finally
            {
                _db.Dispose();
            }
            new GameTools.ClearMemory().FlushMemory();
        }
Exemplo n.º 3
0
        // PlayerSave
        public void Save(PangyaEntities _db)
        {
            // # PLAYER TOOLBAR UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_TOOLBAR  @UID = '{UID}', @ITEMSTR = '{GetSqlUpdateToolbar()}'").FirstOrDefault();

            // #PLAYER ITEM UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_ITEM  @UID = '{UID}', @ITEMSTR = '{ItemWarehouse.GetSqlUpdateItems()}'").FirstOrDefault();

            // #PLAYER CADDIE UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CADDIE  @UID = '{UID}', @ITEMSTR = '{ItemCaddie.GetSqlUpdateCaddie()}'").FirstOrDefault();

            // #PLAYER CHARACTER AND EQUIP UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CHARACTER_EQUIP  @UID = '{UID}', @EQUIPSTR = '{ItemCharacter.GetSqlUpdateCharacter()}'").FirstOrDefault();

            // #PLAYER CARD UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CARD  @UID = '{UID}', @ITEMSTR = '{ItemCard.GetSqlUpdateCard()}'").FirstOrDefault();

            // #PLAYER CARD EQUIP UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CARD_EQUIP  @UID = '{UID}', @ITEMSTR = '{ItemCardEquip.GetSqlUpdateCardEquip()}'").FirstOrDefault();

            // #PLAYER MASCOT UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_MASCOT  @UID = '{UID}', @ITEMSTR = '{ItemMascot.GetSqlUpdateMascots()}'").FirstOrDefault();

            _db.Dispose();
        }
Exemplo n.º 4
0
        public void PlayerGetAchievement(GPlayer player, Packet packet)
        {
            PangyaEntities _db = new PangyaEntities();
            int            UID;
            var            Achievements       = new List <TAchievement>();
            var            AchievementQuests  = new List <TAchievementQuest>();
            var            AchievemetCounters = new Dictionary <uint, TAchievementCounter>();

            UID = packet.ReadInt32();

            try
            {
                if (UID == player.GetUID)
                {
                    PlayerSendAchievement(player, player.Achievements, player.AchievementQuests, player.AchievemetCounters);
                }
                else
                {
                    PlayerSendAchievement(player, Achievements, AchievementQuests, AchievemetCounters);
                }
            }
            catch
            {
                if (_db != null)
                {
                    _db.Dispose();
                }
            }
            finally
            {
                if (_db != null)
                {
                    _db.Dispose();
                }
            }
        }
Exemplo n.º 5
0
        public static void PlayerTutorialMission(GPlayer player, Packet packet)
        {
            var data = (Tutorial)packet.Read(new Tutorial());

            var SetTutorial = player.TutorialCompleted;

            if (SetTutorial == false)
            {
                player.SetTutorial(data.Code, data.MissionID);
            }
            var db = new PangyaEntities();

            try
            {
                var GetTutorial = db.ProcGetTutorial((int)player.GetUID).First();

                switch ((TutorialType)data.Code)
                {
                case TutorialType.Rookie:
                case TutorialType.NewRookie:
                {
                    data.Code = 0;
                    switch (data.MissionID)
                    {
                    case 1:            //não é necessario setar, mas eu seto, só por precausao
                    {
                        data.MissionID = 1;
                    }
                    break;

                    case 2:
                    {
                        data.MissionID = 3;
                    }
                    break;

                    case 4:
                    {
                        data.MissionID = (uint)GetTutorial.Rookie;
                    }
                    break;

                    case 8:
                    {
                        data.MissionID = (uint)GetTutorial.Rookie;
                    }
                    break;

                    case 16:
                    {
                        data.MissionID = (uint)GetTutorial.Rookie;
                    }
                    break;

                    case 32:
                    {
                        data.MissionID = (uint)GetTutorial.Rookie;
                    }
                    break;

                    case 64:
                    {
                        data.MissionID = (uint)GetTutorial.Rookie;
                    }
                    break;

                    case 128:
                    {
                        data.MissionID = byte.MaxValue;
                    }
                    break;
                    }
                }
                break;

                case TutorialType.Beginner:
                {
                    data.Code = 1;
                    switch (data.MissionID)
                    {
                    case 256:
                    {
                        data.MissionID = 256;                //missão 10
                    }
                    break;

                    case 512:
                    {
                        data.MissionID = (uint)GetTutorial.Beginner;                //missão 11
                    }
                    break;

                    case 1024:
                    {
                        data.MissionID = (uint)GetTutorial.Beginner;                //missão 12
                    }
                    break;

                    case 2048:
                    {
                        data.MissionID = (uint)GetTutorial.Beginner;                //missão 13
                    }
                    break;

                    case 4096:
                    {
                        data.MissionID = (uint)GetTutorial.Beginner;                //missão 14
                    }
                    break;

                    case 8192:
                    {
                        data.MissionID = (uint)GetTutorial.Beginner;                //missão 15
                    }
                    break;
                    }
                }
                break;
                }
                //1F 01 01 0100 01 00 00
                player.SendResponse(ShowTutorialPlayer(data.Code, data.MissionID));

                //player.SendMailPopup();
            }
            catch
            {
                player.Close();
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }
        }
Exemplo n.º 6
0
        protected void PlayerGetEXP(GPlayer player, uint Total)
        {
            PangyaBinaryWriter Resp;
            bool       IsUpdate = false;
            MailSender MailSender;

            Resp = new PangyaBinaryWriter();
            if (player.Level >= 70)
            {
                player.SendResponse(new byte[] { 0x0F, 0x00, 0x01, 0x00, 0x00, 0x00 });
                return;
            }
            player.Exp = player.Exp += Total;

            while (true)
            {
                if (player.Level >= 70)
                {
                    break;
                }
                EXPList.TryGetValue(player.Level, out uint EXPTotal);
                if (player.Exp >= EXPTotal)
                {
                    player.Level = Convert.ToByte(player.Level + 1);
                    MailSender   = new MailSender();
                    try
                    {
                        MailSender.Sender = "@GM";
                        MailSender.AddItemLevel((TLEVEL)player.Level);
                        MailSender.Send(player.GetUID);
                    }
                    finally
                    {
                        MailSender.Dispose();
                    }
                    player.Exp = player.Exp -= EXPTotal;
                    IsUpdate   = true;
                }
                else
                {
                    break;
                }
            }
            var _db = new PangyaEntities();

            try
            {
                if (IsUpdate)
                {
                    var table1 = $"UPDATE Pangya_User_Statistics SET Game_Point = '{player.Exp}', Game_Level = '{player.Level}'  WHERE UID = '{player.GetUID}'";
                    _db.Database.SqlQuery <PangyaEntities>(table1).FirstOrDefault();
                    player.SendLevelUp();
                }
            }
            finally
            {
                if (Resp != null)
                {
                    Resp.Dispose();
                }
                else if (_db != null)
                {
                    _db.Dispose();
                }
            }

            player.LoadStatistic();
        }