|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace UnturnedSL
|
|
|
|
|
{
|
|
|
|
@ -27,6 +28,8 @@ namespace UnturnedSL
|
|
|
|
|
settings.Close();
|
|
|
|
|
Validation(name, map, welcome, port, data, extralo, path, out bool valid);
|
|
|
|
|
Run(valid, name, map, welcome, port, data, extralo, path);
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Validation(string name, string map, string welcome, string port, string data, string extralo, string path, out bool valid)
|
|
|
|
@ -132,11 +135,11 @@ namespace UnturnedSL
|
|
|
|
|
{
|
|
|
|
|
string displaytext =
|
|
|
|
|
"Server info:" + Environment.NewLine + Environment.NewLine +
|
|
|
|
|
"Server Name:" + "\t" + "\t" + name + Environment.NewLine +
|
|
|
|
|
"Server Name:" + "\t" + "\t" + "\"" + name + "\"" + Environment.NewLine +
|
|
|
|
|
"Running Map:" + "\t" + "\t" + map + Environment.NewLine +
|
|
|
|
|
"Welcome Msg:" + "\t" + "\t" + welcome + Environment.NewLine +
|
|
|
|
|
"Data folder:" + "\t" + "\t" + data + Environment.NewLine +
|
|
|
|
|
"Welcome Msg:" + "\t" + "\t" + "\"" + welcome + "\"" + Environment.NewLine +
|
|
|
|
|
"Running port:" + "\t" + "\t" + port + Environment.NewLine +
|
|
|
|
|
"Data folder:" + "\t" + "\t" + data + Environment.NewLine +
|
|
|
|
|
"Extra options:" + "\t" + "\t" + extralo + Environment.NewLine +
|
|
|
|
|
"Path to Game:" + "\t" + "\t" + path + Environment.NewLine;
|
|
|
|
|
Console.WriteLine(displaytext);
|
|
|
|
@ -161,23 +164,40 @@ namespace UnturnedSL
|
|
|
|
|
Console.WriteLine("Oh, noes! Seems like the settings file contains wrong info." + Environment.NewLine +
|
|
|
|
|
"Try deleting it or correcting it!" + Environment.NewLine + Environment.NewLine +
|
|
|
|
|
"If you still get the problem, report it on GitHub!");
|
|
|
|
|
DisplayText(name, map, welcome, data, port, extralo, path);
|
|
|
|
|
DisplayText(name, map, welcome, port, data, extralo, path);
|
|
|
|
|
Console.Beep(2300, 250);
|
|
|
|
|
Console.WriteLine(Environment.NewLine + "Press any key to exit...");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
Environment.Exit(1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Green;
|
|
|
|
|
Console.WriteLine("Welcome!" + Environment.NewLine);
|
|
|
|
|
DisplayText(name, map, welcome, data, port, extralo, path);
|
|
|
|
|
Console.WriteLine("Server is up and running." + Environment.NewLine);
|
|
|
|
|
DisplayText(name, map, welcome, port, data, extralo, path);
|
|
|
|
|
string launchop = "-nographics -batchmode -name " + "\"" + name + "\"" + " -map " + map + " -welcome " + "\"" + welcome + "\"" + " -port:" + port + " " + extralo + " +secureserver/" + data;
|
|
|
|
|
var proc = Process.Start(path + @"\Unturned.exe ", launchop);
|
|
|
|
|
proc.WaitForExit(600000);
|
|
|
|
|
Process proc = new Process();
|
|
|
|
|
proc.StartInfo.FileName = path + @"\Unturned.exe ";
|
|
|
|
|
proc.StartInfo.Arguments = launchop;
|
|
|
|
|
proc.Start();
|
|
|
|
|
Process[] procstat = Process.GetProcessesByName("Unturned");
|
|
|
|
|
Console.WriteLine("Started at: " + "\t" + "\t" + System.DateTime.Now);
|
|
|
|
|
while (procstat.Length != 0)
|
|
|
|
|
{
|
|
|
|
|
Console.Write("\r{0}", "Current time: " + "\t" + "\t" + System.DateTime.Now.ToLongTimeString());
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
procstat = Process.GetProcessesByName("Unturned");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
int loop = 5;
|
|
|
|
|
Console.WriteLine(Environment.NewLine + Environment.NewLine + "Seems like the Unturned server was closed!" + Environment.NewLine);
|
|
|
|
|
while (loop >= 1) {
|
|
|
|
|
Console.Write("\r{0}","Exiting... [" + loop + "]");
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
loop--;
|
|
|
|
|
}
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MkDirIfNotExist(string name)
|
|
|
|
|
/*This method name explains itself*/
|
|
|
|
|
{
|
|
|
|
|