-
Notifications
You must be signed in to change notification settings - Fork 2
/
WhiteList.cs
31 lines (24 loc) · 916 Bytes
/
WhiteList.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
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
namespace WhiteList;
public class WhiteList : BasePlugin
{
public override string ModuleName { get; }
public override string ModuleVersion { get; }
public override void Load(bool hotReload)
{
RegisterListener<Listeners.OnClientConnected>((slot =>
{
var player = Utilities.GetPlayerFromSlot(slot);
if(player.IsBot) return;
var steamId = player.SteamID;
var path = Path.Combine(ModuleDirectory, "whitelist.txt");
if(!File.Exists(path)) File.WriteAllLines(path, new []{"Steamid1", "Steamid2"});
var whiteList = File.ReadAllLines(path);
if (!whiteList.Contains(steamId.ToString()))
{
Server.ExecuteCommand($"kickid {player.UserId}");
}
}));
}
}