Saving things on 5165

02/12/2010 22:40 copz1337#1
Where can I add this in my 5165 source? (what it does is it saves everything every 60 seconds and on the console it says "Game Saved Automatically")
Code:
                Thread.Sleep(60 * 1000);
                Database.SaveKOs();
                Database.SaveEmpire();
                Features.Guilds.SaveGuilds();
                Features.SkillsClass.Save();
                Console.WriteLine("Game Saved automatically.");
02/12/2010 22:49 Arcо#2
Quote:
Originally Posted by copz1337 View Post
Where can I add this in my 5165 source? (what it does is it saves everything every 60 seconds and on the console it says "Game Saved Automatically")
Code:
                Thread.Sleep(60 * 1000);
                Database.SaveKOs();
                Database.SaveEmpire();
                Features.Guilds.SaveGuilds();
                Features.SkillsClass.Save();
                Console.WriteLine("Game Saved automatically.");
Lmao your console will get spammed like shiz, but wouldn't you have to make a completely new thread for it?
02/12/2010 22:51 Nullable#3
Thread.Sleep? this will lag up the main thread unless you're doing this in a different thread(which i doubt you do), use a timer..
02/12/2010 22:52 copz1337#4
ok how can i change it then x.x and yea im debating on the console msg.

can this work?

Code:
(Tick + (60 * 1000) < (uint)Environment.TickCount)
02/12/2010 22:56 Arcо#5
Quote:
Originally Posted by copz1337 View Post
ok how can i change it then x.x and yea im debating on the console msg.

can this work?

Code:
(Tick + (60 * 1000) < (uint)Environment.TickCount)
Just go with what nullable said, make a timer for it.
02/12/2010 23:02 copz1337#6
Quote:
Originally Posted by .Arco View Post
Just go with what nullable said, make a timer for it.
i dont know how to make a timer >.>
02/14/2010 07:12 LegalConquer#7
we coem back to the question where would u put the timer XD
02/14/2010 12:12 Korvacs#8
In Program.cs:

Find:

Code:
        public static System.Timers.Timer DropEventTimer = null;
Place bellow:

Code:
        public static System.Timers.Timer RandomEvent = null;
Find:

Code:
World.MobsStart = true;
Place bellow:

Code:
                RandomEvent = new System.Timers.Timer(60000);
                RandomEvent.Elapsed += new System.Timers.ElapsedEventHandler(RandomEvent_Elapsed);
                RandomEvent.Start();
Find:

Code:
        static void MobThread_Execute()
Place above:

Code:
        static void RandomEvent_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            throw new NotImplementedException();
        }
Replace:

Code:
throw new NotImplementedException();
With:

Code:
                Database.SaveKOs();
                Database.SaveEmpire();
                Features.Guilds.SaveGuilds();
                Features.SkillsClass.Save();
                Console.WriteLine("Game Saved automatically.");
Done.
02/14/2010 13:33 salem rey#9
Thanks i will try this, hope it works......
02/14/2010 14:41 LegalConquer#10
Sick Sounds Good But will it spam Cmd console?
02/14/2010 15:15 Korvacs#11
It will, you can remove the Console.WriteLine("Game Saved automatically."); line and it wont.
02/14/2010 15:23 salem rey#12
I got a problem when i add this monster didnt spawn.
02/14/2010 17:00 LegalConquer#13
works fine for me its been on an hour now and i asked people on my server and they say all spawns are working fine.
02/15/2010 11:17 salem rey#14
Ill double check mine :D
02/15/2010 17:19 copz1337#15
Quote:
Originally Posted by Korvacs View Post
In Program.cs:

Find:

Code:
        public static System.Timers.Timer DropEventTimer = null;
Place bellow:

Code:
        public static System.Timers.Timer RandomEvent = null;
Find:

Code:
World.MobsStart = true;
Place bellow:

Code:
                RandomEvent = new System.Timers.Timer(60000);
                RandomEvent.Elapsed += new System.Timers.ElapsedEventHandler(RandomEvent_Elapsed);
                RandomEvent.Start();
Find:

Code:
        static void MobThread_Execute()
Place above:

Code:
        static void RandomEvent_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            throw new NotImplementedException();
        }
Replace:

Code:
throw new NotImplementedException();
With:

Code:
                Database.SaveKOs();
                Database.SaveEmpire();
                Features.Guilds.SaveGuilds();
                Features.SkillsClass.Save();
                Console.WriteLine("Game Saved automatically.");
Done.
Alright thanks alot.