public static void Initialize() { TickRate = Shared.Settings.TickRate; if (!System.IO.File.Exists("serverconfig.xml")) { Console.WriteLine("Config file not found..."); System.Threading.Thread.Sleep(5000); System.Diagnostics.Process.GetCurrentProcess().Kill(); } XmlDocument Config = new XmlDocument(); Config.Load("serverconfig.xml"); Port = int.Parse(Config.DocumentElement.SelectSingleNode("/config/serverport").InnerText); MaxPlayers = int.Parse(Config.DocumentElement.SelectSingleNode("/config/maxplayers").InnerText); XmlNodeList Resources = Config.DocumentElement.SelectNodes("/config/resource"); NetPeerConfiguration NetConfig = new NetPeerConfiguration("ivmp"); NetConfig.MaximumConnections = MaxPlayers; NetConfig.Port = Port; NetConfig.ConnectionTimeout = 50; NetConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval); NetConfig.EnableMessageType(NetIncomingMessageType.StatusChanged); NetServer = new NetServer(NetConfig); NetServer.Start(); PlayersController = new PlayersController(); VehiclesController = new VehiclesController(); ResourcesManager = new Shared.Scripting.ResourcesManager(); EventsManager = new Shared.Scripting.EventsManager(); Engine = new Jint.Engine(); // load resources foreach (XmlNode Resource in Resources) { try { ResourcesManager.Load(Resource.Attributes["name"].InnerText); ResourcesManager.Start(Resource.Attributes["name"].InnerText); } catch (Exception) { } } Timer tick = new Timer(); tick.Elapsed += OnTick; tick.Interval = TickRate; tick.Enabled = true; tick.Start(); Console.WriteLine("Started game server on Port " + Port); Console.WriteLine("Max Players: " + MaxPlayers); }
public static void Initialize() { TickRate = Shared.Settings.TickRate; if (!System.IO.File.Exists("serverconfig.xml")) { Console.WriteLine("Config file not found..."); System.Threading.Thread.Sleep(5000); System.Diagnostics.Process.GetCurrentProcess().Kill(); } XmlDocument Config = new XmlDocument(); Config.Load("serverconfig.xml"); Port = int.Parse(Config.DocumentElement.SelectSingleNode("/config/serverport").InnerText); MaxPlayers = int.Parse(Config.DocumentElement.SelectSingleNode("/config/maxplayers").InnerText); XmlNodeList Resources = Config.DocumentElement.SelectNodes("/config/resource"); NetPeerConfiguration NetConfig = new NetPeerConfiguration("ivmp"); NetConfig.MaximumConnections = MaxPlayers; NetConfig.Port = Port; NetConfig.ConnectionTimeout = 50; NetConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval); NetConfig.EnableMessageType(NetIncomingMessageType.StatusChanged); NetServer = new NetServer(NetConfig); NetServer.Start(); PlayersController = new PlayersController(); VehiclesController = new VehiclesController(); ResourcesManager = new Shared.Scripting.ResourcesManager(); EventsManager = new Shared.Scripting.EventsManager(); Engine = new Jint.Engine(); // load resources foreach (XmlNode Resource in Resources) { try { ResourcesManager.Load(Resource.Attributes["name"].InnerText); ResourcesManager.Start(Resource.Attributes["name"].InnerText); } catch(Exception) { } } Timer tick = new Timer(); tick.Elapsed += OnTick; tick.Interval = TickRate; tick.Enabled = true; tick.Start(); Console.WriteLine("Started game server on Port " + Port); Console.WriteLine("Max Players: " + MaxPlayers); }