Anyone know any program or how to code into the database how to do a server restart ever hour?
Printable View
Anyone know any program or how to code into the database how to do a server restart ever hour?
.....
Its not for freezing its juts for lag.How do i add it into the database?
You can't code into the db without writing a parser class to read the commands in the database.
Database is not something you can make functions as server restart.
Database is a program that holds DATA, lets data to be read and lets another program to write in it.
You need to code it in SOURCE. If you still use a coemu source, then you could code it into frmMain.cs for example, i don't know about restarting a server, but if you can find any information about it, then just every time the game starts, create a timer:
Code:Timer ServerRestartTimer = new Timer();
ServerRestartTimer.Interval = 3600000;//1 hour
ServerRestartTimer.Elapsed += new ElapsedEventHandler(ServerRestart);
ServerRestartTimer.Start();
void ServerRestart(object source, ElapsedEventArgs e)
{
//Do stuff for restarting server
}
Server restart should go something like this.
[code]
using System.Diagnostics;
void resServer()
{
Process nServ = new Process();
nServ.StartInfo.FileName = "Whatever your server is.exe";
nServ.Start();
Environment.Exit(0);
}
Thanks for correcting. Too lazy to open my IDE... Anyway, you get the point.
Lol thanks for that! :)
Edit: BTW there is no Process.Settings, its Process.StartInfo. :P
I get it, but I get a slew of errors when I insert both in.
You don't just throw it into some file and assume it will work.
For example put the timer part into your frmMain.cs -> public frmMain()
And the void just somewhere in frmMain.cs
I think it should work then.
Oh and change one of the names, i wrote void ServerRestart, shiro wrote resServer().
They must be same.
Scroll to the bottom of frmMain, untill you see the 2-} paste it above them two and do the corrections hadeset said to-do.
@hadeset
Thanks a lot for helping me with the code. >_<