28 ديسمبر، 2016


السلام عليكم ورحمه الله وبركاته 
اليوم معانا شرح طريقه التسيف كامله(100%) لجميع السورسات 
دلـوقتي فـي معظم الـسورسات في كـود بيخلي السيرفر يسيف كـل ثواني و كل دقايق
وده في حد ذاته غلط 


الخطوة الاولى

ادخل علي Program.cs وابحث علي
private static bool Handler(CtrlType sig)
اقفله من السالب وبدله بده
private static bool Handler(CtrlType sig)  
        {  
            
        {              Console.WriteLine("Wait Until Saving Full Data");  
            return !
            return !Save();  
        }  
        }  
وبعين ابحث علي
public static bool Save()
اقـفله من السالب و بدلو بـده
public static bool Save()  
        {  
            try  
            {  

                
        {              try              {  
                Database.JiangHu.SaveJiangHu();  
                
                using (var conn Database.DataHolder.MySqlConnection)  
                {  
                    
                {                      conn.Open();  
                    foreach (
                    foreach (Client.GameState client in Program.Values)  
                    {  
                        
                    {                          InnerPowerTable.Save();  
                        
                        //client.Account.Save();  
                        
                        Database.EntityTable.SaveEntity(clientconn);  
                        
                        Database.SkillTable.SaveProficiencies(clientconn);  
                        
                        Database.SkillTable.SaveSpells(clientconn);  
                        
                        Database.ArenaTable.SaveArenaStatistics(client.ArenaStatisticconn);  
                        
                        Database.TeamArenaTable.SaveArenaStatistics(client.TeamArenaStatisticconn);  
                        
                        Database.ChampionTable.SaveStatistics(client.ChampionStatsconn);  
                    }  
                }  
                
                    }                  }                  Flowers.SaveFlowers();  
                new 
                new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID"ConquerItem.ItemUID.Now).Where("Server"Constants.ServerName).Execute();  
                
                Game.ClanWarArena.Save();  
                
                Console.WriteLine("Saving Server Full Data [ Done ] !");  
            }  
            catch (
            }              catch (Exception e)  
            {  
                
            {                  Console.WriteLine(e.ToString());  
                return 
                return false;  
            }  
            return 
            }              return true;  
        }  
        }  
وبعدين ادخل علي جيم استيت او جيم كلينت وابحث علي
void ShutDown() 
اقفله من السالب و بدلو بـ ده
private void ShutDown()  
        {  

            if (
        {  
            if (Socket.Connector == null) return;  
            
            Socket.Connector null;  
            if (
            if (this.Entity != null)  
            {  
                try  
                {  
                    if (
            {                  try                  {                      if (this.Entity.JustCreated) return;  
                    
                    Time32 now Time32.Now;  
                    
                    Kernel.DisconnectPool.Add(this.Entity.UIDthis);  
                    
                    RemoveScreenSpawn(this.Entityfalse);  

                    

                    using (var conn Database.DataHolder.MySqlConnection)  
                    {  
                        
                    {                          conn.Open();  
                        
                        Database.EntityTable.UpdateOnlineStatus(thisfalseconn);  
                        
                        Database.EntityTable.SaveEntity(thisconn);  
                        if (!
                        if (!TransferedPlayer)  
                            
                            Database.EntityVariableTable.Save(thisconn);  
                        
                        Database.SkillTable.SaveProficiencies(thisconn);  
                        
                        Database.SkillTable.SaveSpells(thisconn);  
                        if (!
                        if (!TransferedPlayer)  
                        {  
                            
                        {                              Database.ArenaTable.SaveArenaStatistics(this.ArenaStatisticconn);  
                            
                            Database.TeamArenaTable.SaveArenaStatistics(this.TeamArenaStatisticconn);  
                            
                            Database.ChampionTable.SaveStatistics(this.ChampionStatsconn);  
                        }  
                    }                     
                    
                        }                      }                                         Kernel.GamePool.Remove(this.Entity.UID);  

                    

                    Fame.Save(this);  

                    if (

                    if (Booth != null)  
                        
                        Booth.Remove();  

                    if (

                    if (Entity.MyClones.Count 0)  
                    {  
                        foreach (var 
                    {                          foreach (var item in Entity.MyClones.Values)  
                        {                              
                            
                        {                                                          Data data = new Data(true);  
                            
                            data.UID item.UID;  
                            
                            data.ID Network.GamePackets.Data.RemoveEntity;  
                            
                            item.MonsterInfo.SendScreen(data);  
                        }  
                        
                        }                          Entity.MyClones.Clear();  
                    }  
                    if (
                    }                      if (Quests != null)  
                        
                        Quests.Save();  

                    if (

                    if (Pet != null)  
                        
                        Pet.ClearAll();  
                    if (
                    if (QualifierGroup != null)  
                        
                        QualifierGroup.End(this);  
                    if (
                    if (TeamQualifierGroup != null)  
                        
                        TeamQualifierGroup.CheckEnd(thistrue);  
                    if (
                    if (Entity.CLanArenaBattleFight != null)  
                        
                        Entity.CLanArenaBattleFight.CheakToEnd(thistrue);  
                    if (
                    if (Entity.GuildArenaBattleFight != null)  
                        
                        Entity.GuildArenaBattleFight.CheakToEnd(thistrue);  
                    if (
                    if (ChampionGroup != null)  
                        
                        ChampionGroup.End(this);  
                    if (
                    if (Challenge != null)  
                        
                        Challenge.End(this);  

                     

                    

                     
                    Game.Arena.Clear(this);  
                    
                    Game.TeamArena.Clear(this);  
                    
                    Game.Champion.Clear(this);  

                    

                    RemoveScreenSpawn(this.Entityfalse);  
                      
                    
                                          #region Friend/TradePartner/Apprentice  
                    
                    Message msg = new Message("Your friend, " Entity.Name ", has logged off."System.Drawing.Color.RedMessage.TopLeft);  
                    if (
                    if (Friends == null)  
                        
                        Friends = new SafeDictionary<uintReverCoGamingServer.Game.ConquerStructures.Society.Friend>(100);  
                    foreach (
                    foreach (Game.ConquerStructures.Society.Friend friend in Friends.Values)  
                    {  
                        if (
                    {                          if (friend.IsOnline)  
                        {  
                            var 
                        {                              var packet = new ReverCoGamingServer.Network.GamePackets.KnownPersons(true)  
                            {  
                                
                            {                                  UID Entity.UID,  
                                
                                Type Network.GamePackets.KnownPersons.RemovePerson,  
                                
                                Name Entity.Name,  
                                
                                Online false  
                            
                            };  
                            
                            friend.Client.Send(packet);  
                            
                            packet.Type Network.GamePackets.KnownPersons.AddFriend;  
                            if (
                            if (friend != null)  
                            {  
                                if (
                            {                                  if (friend.Client != null)  
                                {  
                                    
                                {                                      friend.Client.Send(packet);  
                                    
                                    friend.Client.Send(msg);  
                                }  
                            }  
                        }  
                    }  
                    
                                }                              }                          }                      }                      Message msg2 = new Message("Your partner, " Entity.Name ", has logged off."System.Drawing.Color.RedMessage.TopLeft);  

                    if (

                    if (Partners != null)  
                    {  
                        foreach (
                    {                          foreach (Game.ConquerStructures.Society.TradePartner partner in Partners.Values)  
                        {  
                            if (
                        {                              if (partner.IsOnline)  
                            {  
                                var 
                            {                                  var packet = new TradePartner(true)  
                                {  
                                    
                                {                                      UID Entity.UID,  
                                    
                                    Type TradePartner.BreakPartnership,  
                                    
                                    Name Entity.Name,  
                                    
                                    HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),  
                                    
                                    Online false  
                                
                                };  
                                
                                partner.Client.Send(packet);  
                                
                                packet.Type TradePartner.AddPartner;  
                                if (
                                if (partner != null)  
                                {  
                                    if (
                                {                                      if (partner.Client != null)  
                                    {  
                                        
                                    {                                          partner.Client.Send(packet);  
                                        
                                        partner.Client.Send(msg2);  
                                    }  
                                }  
                            }  
                        }  
                    }  
                    
                                    }                                  }                              }                          }                      }                      MentorInformation Information = new MentorInformation(true);  
                    
                    Information.Mentor_Type 1;  
                    
                    Information.Mentor_ID Entity.UID;  
                    
                    Information.Mentor_Level Entity.Level;  
                    
                    Information.Mentor_Class Entity.Class;  
                    
                    Information.Mentor_PkPoints Entity.PKPoints;  
                    
                    Information.Mentor_Mesh Entity.Mesh;  
                    
                    Information.Mentor_Online false;  
                    
                    Information.String_Count 3;  
                    
                    Information.Mentor_Name Entity.Name;  
                    
                    Information.Mentor_Spouse_Name Entity.Spouse;  
                    if (
                    if (Apprentices == nullApprentices = new SafeDictionary<uintGame.ConquerStructures.Society.Apprentice>();  
                    foreach (var 
                    foreach (var appr in Apprentices.Values)  
                    {  
                        if (
                    {                          if (appr.IsOnline)  
                        {  
                            
                        {                              Information.Apprentice_ID appr.ID;  
                            
                            Information.Enrole_Date appr.EnroleDate;  
                            
                            Information.Apprentice_Name appr.Name;  
                            
                            appr.Client.Send(Information);  
                            
                            appr.Client.ReviewMentor();  
                        }  
                    }  
                    if (
                        }                      }                      if (Mentor != null)  
                    {  
                        if (
                    {                          if (Mentor.IsOnline)  
                        {  
                            
                        {                              ApprenticeInformation AppInfo = new ApprenticeInformation();  
                            
                            AppInfo.Apprentice_ID Entity.UID;  
                            
                            AppInfo.Apprentice_Level Entity.Level;  
                            
                            AppInfo.Apprentice_Name Entity.Name;  
                            
                            AppInfo.Apprentice_Online false;  
                            
                            AppInfo.Apprentice_Spouse_Name Entity.Spouse;  
                            
                            AppInfo.Enrole_date Mentor.EnroleDate;  
                            
                            AppInfo.Mentor_ID Mentor.Client.Entity.UID;  
                            
                            AppInfo.Mentor_Mesh Mentor.Client.Entity.Mesh;  
                            
                            AppInfo.Mentor_Name Mentor.Client.Entity.Name;  
                            
                            AppInfo.Type 2;  
                            
                            Mentor.Client.Send(AppInfo);  
                        }  
                    }  

                    
                        }                      }  
                    #endregion  
                    #region Team  
                   /* if (Team != null)  
                    {  
                        if (Team.TeamLeader)  
                        {  
                            Network.GamePackets.Team team = new Network.GamePackets.Team();  
                            team.UID = Account.EntityID;  
                            team.Type = Network.GamePackets.Team.Dismiss;  
                            foreach (Client.GameState Teammate in Team.Teammates)  
                            {  
                                if (Teammate != null)  
                                {  
                                    if (Teammate.Entity.UID != Account.EntityID)  
                                    {  
                                        Teammate.Send(team);  
                                        Teammate.Team = null;  
                                    }  
                                }  
                            }  
                        }  
                        else  
                        {  
                            Network.GamePackets.Team team = new Network.GamePackets.Team();  
                            team.UID = Account.EntityID;  
                            team.Type = Network.GamePackets.Team.ExitTeam;  
                            foreach (Client.GameState Teammate in Team.Teammates)  
                            {  
                                if (Teammate != null)  
                                {  
                                    if (Teammate.Entity.UID != Account.EntityID)  
                                    {  
                                        Teammate.Send(team);  
                                        Teammate.Team.Remove(this);  
                                    }  
                                }  
                            }  
                        }  
                    }*/  
                    #endregion  
                    
                    #region Team                     /* if (Team != null)                      {                          if (Team.TeamLeader)                          {                              Network.GamePackets.Team team = new Network.GamePackets.Team();                              team.UID = Account.EntityID;                              team.Type = Network.GamePackets.Team.Dismiss;                              foreach (Client.GameState Teammate in Team.Teammates)                              {                                  if (Teammate != null)                                  {                                      if (Teammate.Entity.UID != Account.EntityID)                                      {                                          Teammate.Send(team);                                          Teammate.Team = null;                                      }                                  }                              }                          }                          else                          {                              Network.GamePackets.Team team = new Network.GamePackets.Team();                              team.UID = Account.EntityID;                              team.Type = Network.GamePackets.Team.ExitTeam;                              foreach (Client.GameState Teammate in Team.Teammates)                              {                                  if (Teammate != null)                                  {                                      if (Teammate.Entity.UID != Account.EntityID)                                      {                                          Teammate.Send(team);                                          Teammate.Team.Remove(this);                                      }                                  }                              }                          }                      }*/                      #endregion                      if (Team != null)  
                    {  
                        
                    {                          Team.Remove(thistrue);  
                    }  
                }  
                catch (
                    }                  }                  catch (Exception e)  
                {  
                    
                {                      Program.SaveException(e);  
                }  
                
                }                  finally  
                
                {  
                    
                    Kernel.DisconnectPool.Remove(this.Entity.UID);  
                    
                    Console.WriteLine(this.Entity.Name " has logged off! Ip:[" this.Account.IP "]"ConsoleColor.Green);  
                    
                    Console.WriteLine("Done Saved [ " this.Entity.Name " ] Data"ConsoleColor.White);  
                    new 
                    new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("LastPlayer"Entity.Name).Set("login""has logged off").Execute();  

                }  
            }  
        } 

                }              }          } 

الخطوة الثانيه

وروح علي program.cs وضيف ده
[DllImport("Kernel32")]  
        private static 
        private static extern bool SetConsoleCtrlHandler(EventHandler handlerbool add);  
        private 
        private delegate bool EventHandler(CtrlType sig);  
        static 
        static EventHandler _handler;  
        
        enum CtrlType  
        
        {  
            
            CTRL_C_EVENT 0,  
            
            CTRL_BREAK_EVENT 1,  
            
            CTRL_CLOSE_EVENT 2,  
            
            CTRL_LOGOFF_EVENT 5,  
            
            CTRL_SHUTDOWN_EVENT 6  
        
        }  
وابحث علي
case "@exit"
وبدل الكيس بـ ده
case "@exit":  
                        {  
                            
                        {                              GameServer.Disable();  
                            
                            AuthServer.Disable();  

                            new 

                            new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID"ConquerItem.ItemUID.Now).Where("Server"Constants.ServerName).Execute();  
                            
                            Database.EntityVariableTable.Save(0Vars);  

                            var 

                            var WC Program.Values.ToArray();  
                            
                            // foreach (Client.GameState client in WC)  
                            
                            Parallel.ForEach(Program.Valuesclient =>  
                           {  
                               
                           {                                 client.Send("Server will exit for 5 min to fix some bugs, please be paitent !");  
                               
                               client.Disconnect();  
                           });  

                            
                           });  
                            Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { "Server will exit for 5 min to fix some bugs, please be paitent" }), System.Drawing.Color.Black0x7db), Program.Values);  
                            
                            CommandsAI("@save");  

                            if (

                            if (GuildWar.IsWar)  
                                
                                GuildWar.End();  
                            new 
                            new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID"ConquerItem.ItemUID.Now).Where("Server"Constants.ServerName).Execute();  
                            
                            //  new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID", Program._NextItemID).Where("Server", Constants.ServerName).Execute();  
                            
                            Environment.Exit(0);  
                        }  
                        break;  
                        }                          break;  

الخطوة الاخيره

وابحث علي 
case "@restart":
وبدلو الكيس ب ده
case "@restart":  
                        {  
                            try  
                            {  
                                
                        {                              try                              {                                  Kernel.SendWorldMessage(new Network.GamePackets.Message(string.Concat(new object[] { "Server Will Be Restart Now !" }), System.Drawing.Color.Black0x7db), Program.Values);  
                                
                                CommandsAI("@save");  
                                new 
                                new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID"ConquerItem.ItemUID.Now).Where("Server"Constants.ServerName).Execute();  
                                
                                //new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID", Program._NextItemID).Where("Server", Constants.ServerName).Execute();  

                                

                                var WC Program.Values.ToArray();  
                                foreach (
                                foreach (Client.GameState client in WC)  
                                {  
                                    
                                {                                      client.Send("Server Will Be Restart Now !");  
                                    
                                    client.Disconnect();  
                                }  
                                
                                }                                  GameServer.Disable();  
                                 
                                 AuthServer.Disable();  

                                if (

                                if (GuildWar.IsWar)  
                                    
                                    GuildWar.End();  
                                new 
                                new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID"ConquerItem.ItemUID.Now).Where("Server"Constants.ServerName).Execute();  
                                
                                Application.Restart();  
                                
                                Environment.Exit(0);  
                            }  
                            catch (
                            }                              catch (Exception e)  
                            {  
                                
                            {                                  Console.WriteLine(e);  
                                
                                Console.ReadLine();  
                            }  
                        }  
                        break;
                            }                          }                          break;
وابحث علي
case "@save"
بدلو بـ ده
case "@save":  
                        {  
                            
                        {                              SaveTranslate();  
                            
                            Save();  
                        }  
                        break;  
                        }                          break;