Compare commits

...
This repository has been archived on 2019-12-08. You can view files and clone it, but cannot push or open issues or pull requests.

4 Commits
release ... dev

Author SHA1 Message Date
Alex D. d565aa4690 Fixed few stuff 2018-04-15 16:34:56 +02:00
Alex D. 5d685930ca Moved stuff around 2018-04-05 18:21:27 +02:00
Alex D. 8bf77d43dc Fixed Mismatch 2018-03-09 20:41:53 +01:00
Alex D. f9cfa242f2 Added Timer and Timeout 2018-03-09 20:11:41 +01:00
1 changed files with 30 additions and 10 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Threading;
namespace UnturnedSL namespace UnturnedSL
{ {
@ -27,6 +28,8 @@ namespace UnturnedSL
settings.Close(); settings.Close();
Validation(name, map, welcome, port, data, extralo, path, out bool valid); Validation(name, map, welcome, port, data, extralo, path, out bool valid);
Run(valid, name, map, welcome, port, data, extralo, path); 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) 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 = string displaytext =
"Server info:" + Environment.NewLine + Environment.NewLine + "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 + "Running Map:" + "\t" + "\t" + map + Environment.NewLine +
"Welcome Msg:" + "\t" + "\t" + welcome + Environment.NewLine + "Welcome Msg:" + "\t" + "\t" + "\"" + welcome + "\"" + Environment.NewLine +
"Data folder:" + "\t" + "\t" + data + Environment.NewLine +
"Running port:" + "\t" + "\t" + port + Environment.NewLine + "Running port:" + "\t" + "\t" + port + Environment.NewLine +
"Data folder:" + "\t" + "\t" + data + Environment.NewLine +
"Extra options:" + "\t" + "\t" + extralo + Environment.NewLine + "Extra options:" + "\t" + "\t" + extralo + Environment.NewLine +
"Path to Game:" + "\t" + "\t" + path + Environment.NewLine; "Path to Game:" + "\t" + "\t" + path + Environment.NewLine;
Console.WriteLine(displaytext); Console.WriteLine(displaytext);
@ -161,23 +164,40 @@ namespace UnturnedSL
Console.WriteLine("Oh, noes! Seems like the settings file contains wrong info." + Environment.NewLine + Console.WriteLine("Oh, noes! Seems like the settings file contains wrong info." + Environment.NewLine +
"Try deleting it or correcting it!" + Environment.NewLine + Environment.NewLine + "Try deleting it or correcting it!" + Environment.NewLine + Environment.NewLine +
"If you still get the problem, report it on GitHub!"); "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.Beep(2300, 250);
Console.WriteLine(Environment.NewLine + "Press any key to exit..."); Console.WriteLine(Environment.NewLine + "Press any key to exit...");
Console.ReadKey(); Console.ReadKey();
Environment.Exit(1);
} }
else else
{ {
Console.ForegroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Welcome!" + Environment.NewLine); Console.WriteLine("Server is up and running." + Environment.NewLine);
DisplayText(name, map, welcome, data, port, extralo, path); DisplayText(name, map, welcome, port, data, extralo, path);
string launchop = "-nographics -batchmode -name " + "\"" + name + "\"" + " -map " + map + " -welcome " + "\"" + welcome + "\"" + " -port:" + port + " " + extralo + " +secureserver/" + data; string launchop = "-nographics -batchmode -name " + "\"" + name + "\"" + " -map " + map + " -welcome " + "\"" + welcome + "\"" + " -port:" + port + " " + extralo + " +secureserver/" + data;
var proc = Process.Start(path + @"\Unturned.exe ", launchop); Process proc = new Process();
proc.WaitForExit(600000); 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) static void MkDirIfNotExist(string name)
/*This method name explains itself*/ /*This method name explains itself*/
{ {