mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
1.3.3a
- Fixed godmode - Added logging commands to simpleadmin logs file - Fixed votes? - Added updating player_ip and player_name after connect with ban issued by css_addban
This commit is contained in:
69
Events.cs
69
Events.cs
@@ -206,7 +206,6 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
playerPenaltyManager.RemoveAllPenalties(player.Slot);
|
||||
//RemoveFromConcurrentBag(gaggedPlayers, player.Slot);
|
||||
RemoveFromConcurrentBag(silentPlayers, player.Slot);
|
||||
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
||||
|
||||
@@ -226,7 +225,6 @@ public partial class CS2_SimpleAdmin
|
||||
private void OnMapStart(string mapName)
|
||||
{
|
||||
Random random = new Random();
|
||||
//gaggedPlayers.Clear();
|
||||
godPlayers.Clear();
|
||||
silentPlayers.Clear();
|
||||
|
||||
@@ -290,7 +288,7 @@ public partial class CS2_SimpleAdmin
|
||||
TagsDetected = true;
|
||||
}
|
||||
|
||||
AddTimer(2.0f, async () =>
|
||||
AddTimer(3.0f, async () =>
|
||||
{
|
||||
string? address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}";
|
||||
string? hostname = ConVar.Find("hostname")!.StringValue;
|
||||
@@ -300,68 +298,63 @@ public partial class CS2_SimpleAdmin
|
||||
AdminSQLManager _adminManager = new(_database);
|
||||
try
|
||||
{
|
||||
await using (var connection = await _database.GetConnectionAsync())
|
||||
await using var connection = await _database.GetConnectionAsync();
|
||||
bool addressExists = await connection.ExecuteScalarAsync<bool>(
|
||||
"SELECT COUNT(*) FROM sa_servers WHERE address = @address",
|
||||
new { address });
|
||||
|
||||
if (!addressExists)
|
||||
{
|
||||
bool addressExists = await connection.ExecuteScalarAsync<bool>(
|
||||
"SELECT COUNT(*) FROM sa_servers WHERE address = @address",
|
||||
new { address });
|
||||
|
||||
if (!addressExists)
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"INSERT INTO sa_servers (address, hostname) VALUES (@address, @hostname)",
|
||||
new { address, hostname });
|
||||
}
|
||||
else
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"UPDATE `sa_servers` SET hostname = @hostname WHERE address = @address",
|
||||
new { address, hostname });
|
||||
}
|
||||
|
||||
int? serverId = await connection.ExecuteScalarAsync<int>(
|
||||
"SELECT `id` FROM `sa_servers` WHERE `address` = @address",
|
||||
new { address });
|
||||
|
||||
ServerId = serverId;
|
||||
await connection.ExecuteAsync(
|
||||
"INSERT INTO sa_servers (address, hostname) VALUES (@address, @hostname)",
|
||||
new { address, hostname });
|
||||
}
|
||||
else
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"UPDATE `sa_servers` SET hostname = @hostname WHERE address = @address",
|
||||
new { address, hostname });
|
||||
}
|
||||
|
||||
int? serverId = await connection.ExecuteScalarAsync<int>(
|
||||
"SELECT `id` FROM `sa_servers` WHERE `address` = @address",
|
||||
new { address });
|
||||
|
||||
ServerId = serverId;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (_logger != null)
|
||||
_logger.LogCritical("Unable to create or get server_id");
|
||||
_logger?.LogCritical("Unable to create or get server_id");
|
||||
}
|
||||
|
||||
await _adminManager.GiveAllFlags();
|
||||
});
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
|
||||
AddTimer(2.0f, () =>
|
||||
AddTimer(3.0f, () =>
|
||||
{
|
||||
ConVar? botQuota = ConVar.Find("bot_quota");
|
||||
|
||||
if (botQuota != null && botQuota.GetPrimitiveValue<int>() > 0)
|
||||
{
|
||||
Logger.LogInformation("Due to bugs with bots (game bug), consider disabling bots by setting `bot_quota 0` in the gamemode config if your server crashes after a map change.");
|
||||
Logger.LogWarning("Due to bugs with bots (game bug), consider disabling bots by setting `bot_quota 0` in the gamemode config if your server crashes after a map change.");
|
||||
Logger.LogCritical("Due to bugs with bots (game bug), consider disabling bots by setting `bot_quota 0` in the gamemode config if your server crashes after a map change.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[GameEventHandler]
|
||||
private HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
|
||||
public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
|
||||
{
|
||||
CCSPlayerController? player = @event.Userid;
|
||||
|
||||
if (player is null || @event.Attacker == null || !player.IsValid || !player.PlayerPawn.IsValid || player.PlayerPawn.Value == null
|
||||
|| player.IsBot || player.IsHLTV || player.PlayerPawn.IsValid || player.Connected == PlayerConnectedState.PlayerDisconnecting
|
||||
|| @event.Attacker.Connected == PlayerConnectedState.PlayerDisconnecting)
|
||||
if (player is null || @event.Attacker is null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE || player.PlayerPawn.Value == null
|
||||
|| player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
return HookResult.Continue;
|
||||
|
||||
if (godPlayers.Contains(player.Slot) && player.PawnIsAlive)
|
||||
if (godPlayers.Contains(player.Slot))
|
||||
{
|
||||
player.Health = 100;
|
||||
player.PlayerPawn.Value.Health = 100;
|
||||
player.PlayerPawn.Value.Health = player.PlayerPawn.Value.MaxHealth;
|
||||
player.PlayerPawn.Value.ArmorValue = 100;
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
|
||||
Reference in New Issue
Block a user