- Joined
- May 19, 2007
- Messages
- 141
- Reaction score
- 0
This guide is not mine i take no credits for it ! I just helpe some people here to get their server more better !
Usage:
/autosave off
To disable autosaving or
/autosave on
to enable autosaving.
First, Let's begin with frmMain.cs. Open up the code of frmMain.cs.
Above line 13, add the following:
Around line 36, there should be something that looks like this:
Below that, add:
Replace the X with the wait time in seconds x 1000.
Search for private void PingLoop(). Above that, add:
Then, within PingLoop(), add this:
Finally, open up World.cs.
Go into ParseString, and within the GM-only commands, add:
Usage:
/autosave off
To disable autosaving or
/autosave on
to enable autosaving.
First, Let's begin with frmMain.cs. Open up the code of frmMain.cs.
Above line 13, add the following:
Code:
using System.Timers;
Code:
public const int MINTHREADS = 15;
Code:
public static System.Timers.Timer saveTimer = new System.Timers.Timer();
public const int TimerInterval = X;
Search for private void PingLoop(). Above that, add:
Code:
public void SaveChar(object source, ElapsedEventArgs e)
{
COClient Client = null;
foreach (AuthBinder AB in m_GameConnectedClients.Values)
{
Client = AB.Client;
Console.WriteLine("Now Running Save Loop!");
if (Client.Char != null)
{
Console.WriteLine("Saving Character {0}", Client.Char.Name);
BackendDB.SynchronizeCharacter(Client.Char);
}
}
}
Code:
private void PingLoop()
{
saveTimer.AutoReset = true;
saveTimer.Elapsed += new System.Timers.ElapsedEventHandler(SaveChar);
saveTimer.Interval = TimerInterval;
saveTimer.Start();
try
{
Go into ParseString, and within the GM-only commands, add:
Code:
else if (Splitter[0] == "/autosave")
{
if (Splitter[1] == "on")
{
Client.SendData(PacketBuilder.Message(Client.MessageID, "System", "All", "Auto Save On!", World.ChatType.Center));
Chat sm = new Chat(Client.MessageID, Client.Char.Name, "ALL", "Server AutoSave Is Enabled.", ChatType.Center);
byte[] test = sm.writeImpl();
SendMessageServer(test);
frmMain.saveTimer.Interval = 15000;
frmMain.saveTimer.Start();
}
else if (Splitter[1] == "off")
{
Client.SendData(PacketBuilder.Message(Client.MessageID, "System", "All", "Auto Save Off!", World.ChatType.Center));
frmMain.saveTimer.Stop();
Chat sm = new Chat(Client.MessageID, Client.Char.Name, "ALL", "Server AutoSave is disabled.", ChatType.Center);
byte[] test = sm.writeImpl();
SendMessageServer(test);
Console.WriteLine("Auto Save is now disabled. Current Status of Timer is {0}.", frmMain.saveTimer.Enabled);
}
else
{
Client.SendData(PacketBuilder.Message(Client.MessageID, "System", "All", "Usage: /save on or /save off", World.ChatType.Talk));
}
}