-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveDataCommand.cs
More file actions
57 lines (50 loc) · 1.93 KB
/
SaveDataCommand.cs
File metadata and controls
57 lines (50 loc) · 1.93 KB
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
using Smod2;
using Smod2.Commands;
using System;
using System.Collections.Generic;
namespace ExamplePlugin
{
class SaveDataCommand : ICommandHandler
{
private Plugin plugin;
public SaveDataCommand(Plugin plugin)
{
this.plugin = plugin;
}
public string GetCommandDescription()
{
// This prints when someone types HELP HELLO
return "Save game info";
}
public string GetUsage()
{
// This prints when someone types HELP HELLO
return "Write save";
}
public string[] OnCall(ICommandSender sender, string[] args)
{
List<string> comandRes = new List<string>();
comandRes.Add("Command called");
string fName = args[0].Equals("") ? "output.txt" : args[0];
using (System.IO.StreamWriter file = new System.IO.StreamWriter(fName)) {
//Player num
int plCount = plugin.Server.NumPlayers;
file.WriteLine("Player: " + plCount);
//Num round
//Plugins
file.WriteLine("List Of Pluggins:");
plugin.pluginManager.Plugins.ForEach(e => { file.WriteLine(e.Details.name); });
//Time
int totalSeconds=plugin.Round.Duration;//к сожаление не могу написать код считающий время сервера точно так же как и е его номер
int hours = totalSeconds / 3600;
int min = totalSeconds / 60;
int sec = totalSeconds % 60;
string totalTime = hours + ":" + min + ":" + sec;
file.WriteLine("Uptime:" + totalTime);
}
comandRes.Add("Data saved);
comandRes.ToArray();
return comandRes;
}
}
}