-
Notifications
You must be signed in to change notification settings - Fork 0
/
cs2-forbiddennames.cs
63 lines (55 loc) · 1.75 KB
/
cs2-forbiddennames.cs
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
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using System.Text.Json.Serialization;
namespace cs2_forbiddennames;
public class SampleConfig : BasePluginConfig
{
[JsonPropertyName("Cmd")] public string Cmd { get; set; } = "css_ban {USERID} 0 xD";
[JsonPropertyName("Nicknames")] public string[] Nicknames { get; set; } = {"phrase1", "phrase2"};
}
public class cs2_forbiddennames : BasePlugin, IPluginConfig<SampleConfig>
{
public override string ModuleName => "cs2-forbiddennames";
public override string ModuleVersion => "0.0.1";
public override string ModuleAuthor => "Letaryat";
string Plugincmd;
string[] Names;
public SampleConfig Config { get; set; }
public void OnConfigParsed(SampleConfig config)
{
Plugincmd = config.Cmd;
Names = config.Nicknames;
}
public override void Load(bool hotReload){
Console.WriteLine("Loaded: CS2-ForbiddenNames.");
}
[GameEventHandler]
public HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
{
checkPlayer(@event.Userid!);
return HookResult.Continue;
}
public void checkPlayer(CCSPlayerController player)
{
if(player.IsBot || player.IsHLTV)
{
return;
}
else
{
if(Names.Any(player.PlayerName.Contains))
{
Plugincmd = Plugincmd
.Replace("{USERID}", "#"+player!.UserId!.Value.ToString());
AddTimer(1.0f, () => {
Server.ExecuteCommand(Plugincmd);
});
}
else
{
return;
}
}
}
}