-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHelpText.cs
More file actions
83 lines (71 loc) · 2.34 KB
/
HelpText.cs
File metadata and controls
83 lines (71 loc) · 2.34 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
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
using System;
using System.Collections.Generic;
using System.Text;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
namespace Oxide.Plugins
{
[Info("HelpText", "Domestos/Calytic", "2.0.0", ResourceId = 676)]
class HelpText : CovalencePlugin
{
private bool UseCustomHelpText;
private bool AllowHelpTextFromOtherPlugins;
private List<object> CustomHelpText;
private void Loaded()
{
this.UseCustomHelpText = GetConfig<bool>("Settings","UseCustomHelpText", false);
this.AllowHelpTextFromOtherPlugins = GetConfig<bool>("Settings","AllowHelpTextFromOtherPlugins", true);
this.CustomHelpText = GetConfig<List<object>>("CustomHelpText", new List<object>() {
"custom helptext",
"custom helptext"
});
}
protected override void LoadDefaultConfig ()
{
Config["UseCustomHelpText"] = false;
Config["Settings","AllowHelpTextFromOtherPlugins"] = true;
Config["Settings","CustomHelpText"] = CustomHelpText = new List<object>() {
"custom helptext",
"custom helptext"
};
SaveConfig();
}
[Command("help")]
void cmdHelp(IPlayer player, string command, string[] args)
{
if (player == null) return;
if (UseCustomHelpText)
{
foreach (var text in CustomHelpText)
{
player.Reply(text.ToString());
}
}
if (AllowHelpTextFromOtherPlugins)
{
#if RUST
plugins.CallHook("SendHelpText", player.ConnectedPlayer.Character.Object);
#endif
}
}
private T GetConfig<T>(string name, T defaultValue)
{
if (Config[name] == null)
{
return defaultValue;
}
return (T)Convert.ChangeType(Config[name], typeof(T));
}
private T GetConfig<T>(string name, string name2, T defaultValue)
{
if (Config[name, name2] == null)
{
return defaultValue;
}
return (T)Convert.ChangeType(Config[name, name2], typeof(T));
}
}
}