Register for your free account! | Forgot your password?

You last visited: Today at 15:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



restart

Discussion on restart within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
daniel7851109's Avatar
 
elite*gold: 0
Join Date: Feb 2009
Posts: 84
Received Thanks: 14
restart

how can i make my server auto restart i already tried i made and effort

Code:
public static void RSSTART()
        {
            MyThread CompanionThread = new MyThread();
            CompanionThread.Execute += new Execute(CompanionThread_Execute);
            CompanionThread.Start(100);
            MyThread ServerStuff = new MyThread();
            ServerStuff.Execute += new Execute(ServerStuff_Execute);
            ServerStuff.Start(100);
            MyThread MobThread = new MyThread();
            MobThread.Execute += new Execute(MobThread_Execute);
            MobThread.Start(100);
            World.MobsStart = true;
            Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
            World.H_Chars.Values.CopyTo(BaseCharacters, 0);

            NewestCOServer.Main.AuthWorker.Listener.Close();
            NewestCOServer.Main.GameWorker.Listener.Close();
            EndSession = true;
            try
            {
                foreach (Game.Character C in BaseCharacters)
                {
                    try
                    {
                        if (C.Loc.Map == 1021)
                        {
                            C.Teleport(1021, 50, 50);
                            C.MyClient.Disconnect();
                            Console.WriteLine(C.Name + " has logged off successfuly.");
                        }
                        else
                        {
                            C.Teleport(1002, 400, 400);
                            C.MyClient.Disconnect();
                            Console.WriteLine(C.Name + " has logged off successfuly.");
                        }
                    }
                    catch { continue; }
                }
            }
            catch { }
            Database.SaveKOs();
            Console.WriteLine("KOs saved.");
            Database.SaveEmpire();
            Console.WriteLine("Empire saved.");
            Features.Guilds.SaveGuilds();
            Console.WriteLine("Guilds saved.");
            Features.SkillsClass.Save();
            Console.WriteLine("Skills saved.");

            MobThread.Close();
            ServerStuff.Close();
            CompanionThread.Close();
            Database.Dispose();
            Console.WriteLine("Database disposed.");
            System.Diagnostics.Process.Start("CoSX.exe");
            Environment.Exit(0);
        }

Now open mythread.cs
find:
            interval = Interval;
            T = new Thread(new ThreadStart(Run));
            T.Start();

under it put:
System.Timers.Timer RSTimer = new System.Timers.Timer(1000.0);
                RSTimer.Start();
                RSTimer.Elapsed += delegate { RStart(); };
                System.Timers.Timer ARSTimer = new System.Timers.Timer(1000.0);
                ARSTimer.Start();
                ARSTimer.Elapsed += delegate { ARStart(); };
                System.Timers.Timer BRSTimer = new System.Timers.Timer(1000.0);
                BRSTimer.Start();
                BRSTimer.Elapsed += delegate { BRStart(); };
                System.Timers.Timer CRSTimer = new System.Timers.Timer(1000.0);
                CRSTimer.Start();
                CRSTimer.Elapsed += delegate { CRStart(); };
                System.Timers.Timer GWTimer = new System.Timers.Timer(1000.0);
                GWTimer.Start();

Now any place in the mythread.cs put:
        public static bool RSend = false;
        public static bool ARSend = false;
        public static bool BRSend = false;
        public static bool CRSend = false;
        public static bool DRSend = false;
        public static bool ERSend = false;
        public static bool RESTARTEREN = false;

under that u putted put:
        private static void CTFBCast(string msg)
        {
            foreach (Character Char in World.H_Chars.Values)
            {
                Char.MyClient.AddSend(Packets.ChatMessage(0, "[CTF]", "All", msg, 2011, 0));
                Char.MyClient.EndSend();
            }
        }
        public static void RStart()
        {
            if (DateTime.Now.Minute == 02 && RSend == false && DateTime.Now.Hour == 03 || DateTime.Now.Minute == 02 && RSend == false && DateTime.Now.Hour == 15 || DateTime.Now.Minute == 02 && RSend == false && DateTime.Now.Hour == 09 || DateTime.Now.Minute == 02 && RSend == false && DateTime.Now.Hour == 21)
            {
                CTFBCast("[AUTORESTART]Server Restart in 3Minutes.");
                RSend = true;
            }
        }
        public static void ARStart()
        {
            if (DateTime.Now.Minute == 03 && ARSend == false && DateTime.Now.Hour == 03 || DateTime.Now.Minute == 03 && ARSend == false && DateTime.Now.Hour == 15 || DateTime.Now.Minute == 03 && ARSend == false && DateTime.Now.Hour == 09 || DateTime.Now.Minute == 03 && ARSend == false && DateTime.Now.Hour == 21)
            {
                CTFBCast("[AUTORESTART]Server Restart in 2Minutes.");
                ARSend = true;
            }
        }
        public static void BRStart()
        {
            if (DateTime.Now.Minute == 04 && DateTime.Now.Hour == 03 && BRSend == false || DateTime.Now.Minute == 04 && DateTime.Now.Hour == 15 && BRSend == false || DateTime.Now.Minute == 04 && DateTime.Now.Hour == 09 && BRSend == false || DateTime.Now.Minute == 04 && DateTime.Now.Hour == 21 && BRSend == false)
            {
                CTFBCast("[AUTORESTART]Server Restart in 1Minute.");
                BRSend = true;
            }
        }
        public static void CRStart()
        {
            if (DateTime.Now.Minute == 05 && DateTime.Now.Hour == 03 && RESTARTEREN == false || DateTime.Now.Minute == 05 && DateTime.Now.Hour == 15 && RESTARTEREN == false || DateTime.Now.Minute == 05 && DateTime.Now.Hour == 09 && RESTARTEREN == false || DateTime.Now.Minute == 05 && DateTime.Now.Hour == 21 && RESTARTEREN == false)
            {
                RESTARTEREN = true;
                CTFBCast("[AUTORESTART]Restart have started. All things will be closed in 120 Seconds. Restart takes 2-5Minutes.");
                Thread.Sleep(120000);
                Program.RSSTART();
            }
        }
        public static void RRRStart()
        {
                RESTARTEREN = true;
                CTFBCast("Restart have started. All things will be closed in 65 Seconds. The server thread will sleep untill. Restart takes 2-5Minutes.");
                Thread.Sleep(65000);
                Program.RSSTART();
        }
daniel7851109 is offline  
Old 06/28/2010, 00:52   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Umm well ideallly i'd do a seperate program so you can reopen the program after.


What i would do is write a BASIC connection system. Have the new restarter program connect to the mmain server whenever you want the restart code to run. Then in gserver have the connection code for on client connect to save everything, disconect ppll (maybe warn them too) and then close the server.

Restarter side, confirmm it's been closed (by attempting a connection to it) and then either

A: if closed, start it up again

B: if not closed (con responds and or proc shows in list of running processes) force a close (no save remember so be generous with your times) and then restart it after.


It's not a big project to code but something you may want to research just a tad first so you do it properly.

i'd suggest googling sockets in c# (sync would mae sense) and some on closing/finding running processes and launching programs. It's all quite basic though.
pro4never is offline  
Reply


Similar Threads Similar Threads
d2nt bluebird - restart restart restart
06/15/2010 - Diablo 2 - 7 Replies
yo, ich hab schon länger 4 bots am laufen, hat auch immer alles relativ gut geklappt, auf 50 runs meist so 3-4 restarts, also ganz in ordnung, und wie ichs so mitbekommen hab waren die meist eh schon gegen ende des games (ja gut, kein baal kill,aber was solls) seit 2 tagen allerdings funktioniert da überhaupt nix mehr einer läuft "ziemlich" normal, 8 runs 2 restarts der nächste 9 runs 7 restarts dann 19 runs 19 restarts und 47 runs 47 restarts dann is natürlich realm down bei allen,...
KTS restart?
05/05/2010 - Rappelz - 15 Replies
Anybody knows when it will be, and what will be added after restart? Only dates from trust-able sources please.
D2 Restart, Yep^^
04/20/2010 - Diablo 2 - 12 Replies
Hallo Alle Zusammen Wie Einer Von Vielen Hats Mich Auch Erwischt, Wurde Banned, Hab Meine Lektion Gelernt Und Nun Versuche Ich So Gut Wie Es Geht Legit Zu Gamen. Deshalb Möchte Ich In Hardcore Ladder Neu Anfangen und Durchspielen und Deshalb Such Ich Auch Leute Postet Einfach Charname, Erreichen Unter Jsp Bin Ich: [email protected] Greets Enis =)
Restart PC
06/23/2008 - Dekaron - 2 Replies
My problem, i play and restart PC:(((((( Help me, THX
my pc restart
09/15/2006 - Conquer Online 2 - 1 Replies
wen i use 3 or more CO my pc restart can someone help me..



All times are GMT +1. The time now is 15:37.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.