Initial commit
This commit is contained in:
parent
7ec9d5b9c0
commit
6bcb10c5cf
11 changed files with 586 additions and 0 deletions
48
Events.cs
Normal file
48
Events.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
|
||||
namespace CS2_SimpleAdmin
|
||||
{
|
||||
public partial class CS2_SimpleAdmin
|
||||
{
|
||||
private void registerEvents()
|
||||
{
|
||||
RegisterListener<Listeners.OnClientAuthorized>(OnClientAuthorized);
|
||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||
}
|
||||
|
||||
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
||||
{
|
||||
int playerIndex = playerSlot + 1;
|
||||
|
||||
CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex);
|
||||
|
||||
if (player.AuthorizedSteamID == null)
|
||||
{
|
||||
AddTimer(3.0f, () =>
|
||||
{
|
||||
OnClientAuthorized(playerSlot, steamID);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
bool isBanned = _banManager.IsPlayerBanned(player.AuthorizedSteamID.SteamId64.ToString());
|
||||
|
||||
if (isBanned)
|
||||
{
|
||||
Helper.KickPlayer(player.UserId, "Banned");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMapStart(string mapName)
|
||||
{
|
||||
AddTimer(120.0f, () =>
|
||||
{
|
||||
BanManager _banManager = new(dbConnectionString);
|
||||
_banManager.ExpireOldBans();
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue