From 67582df4e73d5e2f4b962ed760f256aa578ec1fd Mon Sep 17 00:00:00 2001 From: Bitl Date: Thu, 5 Dec 2019 07:07:12 -0700 Subject: [PATCH] added addon scripts for servers --- NovetusLauncher/NovetusCMD/CommandLineArguments.cs | 2 +- NovetusLauncher/NovetusCMD/Program.cs | 8 +++++++- NovetusLauncher/NovetusFuncs/ClientScript.cs | 2 +- NovetusLauncher/NovetusFuncs/GlobalVars.cs | 3 ++- NovetusLauncher/NovetusFuncs/ScriptGenerator.cs | 5 +++-- NovetusLauncher/NovetusLauncher/MainForm.cs | 4 ++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/NovetusLauncher/NovetusCMD/CommandLineArguments.cs b/NovetusLauncher/NovetusCMD/CommandLineArguments.cs index 56e155b..f097979 100644 --- a/NovetusLauncher/NovetusCMD/CommandLineArguments.cs +++ b/NovetusLauncher/NovetusCMD/CommandLineArguments.cs @@ -18,7 +18,7 @@ namespace NovetusCMD public Arguments(string[] Args) { Parameters = new StringDictionary(); - Regex Spliter = new Regex(@"^-{1,2}|^/|=|:", + Regex Spliter = new Regex(@"^-{1,2}|^/|=", RegexOptions.IgnoreCase | RegexOptions.Compiled); Regex Remover = new Regex(@"^['""]?(.*?)['""]?$", diff --git a/NovetusLauncher/NovetusCMD/Program.cs b/NovetusLauncher/NovetusCMD/Program.cs index c7f0acb..e1c0cc6 100644 --- a/NovetusLauncher/NovetusCMD/Program.cs +++ b/NovetusLauncher/NovetusCMD/Program.cs @@ -258,6 +258,12 @@ namespace NovetusCMD GlobalVars.PlayerLimit = Convert.ToInt32(CommandLine["maxplayers"]); } } + + if (CommandLine["script"] != null) + { + GlobalVars.AddonScriptPath = CommandLine["script"].Replace(@"\", @"\\"); + ConsolePrint("NovetusCMD detected a custom script. Loading " + GlobalVars.AddonScriptPath, 4); + } } if (!OverrideINI) @@ -314,7 +320,7 @@ namespace NovetusCMD { if (!GlobalVars.FixScriptMapMode) { - args = quote + mapfile + "\" -script \"dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.Server, GlobalVars.SelectedClient) + quote + (no3d ? " -no3d" : ""); + args = quote + mapfile + "\" -script \"dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.Server, GlobalVars.SelectedClient) + "; " + (!string.IsNullOrWhiteSpace(GlobalVars.AddonScriptPath) ? "dofile('" + GlobalVars.AddonScriptPath + "');" : "") + quote + (no3d ? " -no3d" : ""); } else { diff --git a/NovetusLauncher/NovetusFuncs/ClientScript.cs b/NovetusLauncher/NovetusFuncs/ClientScript.cs index 40c0d52..3582d96 100644 --- a/NovetusLauncher/NovetusFuncs/ClientScript.cs +++ b/NovetusLauncher/NovetusFuncs/ClientScript.cs @@ -55,7 +55,7 @@ public class ClientScript return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ",'" + GlobalVars.PlayerTripcode + "')"; } } else if (type == ScriptGenerator.ScriptType.Server) { - return "dofile('" + luafile + "'); _G.CSServer(" + GlobalVars.RobloxPort + "," + GlobalVars.PlayerLimit + "," + md5s + ")"; + return "dofile('" + luafile + "'); _G.CSServer(" + GlobalVars.RobloxPort + "," + GlobalVars.PlayerLimit + "," + md5s + "); " + (!string.IsNullOrWhiteSpace(GlobalVars.AddonScriptPath) ? "dofile('" + GlobalVars.AddonScriptPath + "');" : ""); } else if (type == ScriptGenerator.ScriptType.Solo) { if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true) { return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; diff --git a/NovetusLauncher/NovetusFuncs/GlobalVars.cs b/NovetusLauncher/NovetusFuncs/GlobalVars.cs index 3ac0f12..2e10ae3 100644 --- a/NovetusLauncher/NovetusFuncs/GlobalVars.cs +++ b/NovetusLauncher/NovetusFuncs/GlobalVars.cs @@ -16,7 +16,7 @@ public static class Env #if DEBUG public static readonly bool Debugging = true; #else - public static readonly bool Debugging = false; + public static readonly bool Debugging = false; #endif } @@ -165,6 +165,7 @@ public static class GlobalVars public static bool FixScriptMapMode = false; public static bool AlreadyHasSecurity = false; public static string CustomArgs = ""; + public static string AddonScriptPath = ""; //charcustom public static string Custom_Hat1ID_Offline = "NoHat.rbxm"; public static string Custom_Hat2ID_Offline = "NoHat.rbxm"; diff --git a/NovetusLauncher/NovetusFuncs/ScriptGenerator.cs b/NovetusLauncher/NovetusFuncs/ScriptGenerator.cs index 58b5d63..a50c10b 100644 --- a/NovetusLauncher/NovetusFuncs/ScriptGenerator.cs +++ b/NovetusLauncher/NovetusFuncs/ScriptGenerator.cs @@ -134,8 +134,9 @@ public class ScriptGenerator "--Load Script", //scriptcontents, "dofile('rbxasset://scripts/" + GlobalVars.ScriptName + ".lua')", - GetScriptFuncForType(type, client) - ); + GetScriptFuncForType(type, client), + !string.IsNullOrWhiteSpace(GlobalVars.AddonScriptPath) ? "dofile('" + GlobalVars.AddonScriptPath + "')" : "" + ); List list = new List(Regex.Split(code, Environment.NewLine)); string[] convertedList = list.ToArray(); diff --git a/NovetusLauncher/NovetusLauncher/MainForm.cs b/NovetusLauncher/NovetusLauncher/MainForm.cs index b18224e..4d2002f 100644 --- a/NovetusLauncher/NovetusLauncher/MainForm.cs +++ b/NovetusLauncher/NovetusLauncher/MainForm.cs @@ -950,8 +950,8 @@ namespace NovetusLauncher { if (!GlobalVars.FixScriptMapMode) { - args = quote + mapfile + "\" -script \"dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.Server, GlobalVars.SelectedClient) + quote + (no3d ? " -no3d" : ""); - } + args = quote + mapfile + "\" -script \"dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.Server, GlobalVars.SelectedClient) + "; " + (!string.IsNullOrWhiteSpace(GlobalVars.AddonScriptPath) ? "dofile('" + GlobalVars.AddonScriptPath + "');" : "") + quote + (no3d ? " -no3d" : ""); + } else { ScriptGenerator.GenerateScriptForClient(ScriptGenerator.ScriptType.Server, GlobalVars.SelectedClient);