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