File size: 2,019 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
class DayZTool: WorkbenchPlugin
{
void RunDayZBat(string filepath, bool wait = false)
{
if (filepath.Length() < 2) return;
filepath.Replace("\\", "/");
if (filepath[1] != ":")
{
string cwd;
Workbench.GetCwd(cwd);
filepath = cwd + "/" + filepath;
}
int index = filepath.IndexOf("/");
int last_index = index;
while(index != -1)
{
last_index = index;
index = filepath.IndexOfFrom(last_index + 1, "/");
}
if (last_index == -1) return;
string path = filepath.Substring(0, last_index);
string bat = filepath.Substring(last_index + 1, filepath.Length() - last_index - 1);
/*Print(filepath);
Print(path);
Print(bat);*/
Workbench.RunCmd("cmd /c \"cd " + path + " & call " + bat + "\"", wait);
}
override void Configure()
{
Workbench.ScriptDialog("Mission directory","", this);
}
[ButtonAttribute("OK")]
void DialogOk()
{
}
};
[WorkbenchPluginAttribute("DayZ Restart", "Just for testing", "ctrl+1", "", {"ScriptEditor"})]
class RestartDayzTool: DayZTool
{
[Attribute("day_z_data_missions/killDayZ.bat", "fileeditbox", "Path to missions dir", "")]
string KillBatPath;
[Attribute("day_z_data_missions/_default_single/default_SampleMap3_Empty.bat", "fileeditbox", "Path to missions dir", "")]
string MissionBatPath;
override void Run()
{
RunDayZBat(KillBatPath, true);
RunDayZBat(MissionBatPath);
}
}
[WorkbenchPluginAttribute("DayZ Run", "Just for testing", "ctrl+2", "", {"ScriptEditor"})]
class RunDayzTool: DayZTool
{
[Attribute("day_z_data_missions/_default_single/default_SampleMap3_Empty.bat", "fileeditbox", "Path to missions dir", "")]
string MissionBatPath;
override void Run()
{
RunDayZBat(MissionBatPath);
}
}
[WorkbenchPluginAttribute("DayZ Kill", "Just for testing", "ctrl+3", "", {"ScriptEditor"})]
class KillDayzTool: DayZTool
{
[Attribute("day_z_data_missions/killDayZ.bat", "fileeditbox", "Path to missions dir", "")]
string KillBatPath;
override void Run()
{
RunDayZBat(KillBatPath);
}
}
|