diff --git a/CHANGELOG b/CHANGELOG index 687f71d..4beb6c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ - feat: Added option to change the warning print interval - feat: Added log and check for game details privated +- fix: Warning countdown issues -- 2024. 07. 02 - v1.4.0 diff --git a/src/KitsuneSteamRestrict.cs b/src/KitsuneSteamRestrict.cs index 2759430..a164d6b 100644 --- a/src/KitsuneSteamRestrict.cs +++ b/src/KitsuneSteamRestrict.cs @@ -244,28 +244,36 @@ private void CheckUserViolations(nint handle, ulong authorizedSteamID) { if (Config.PrivateProfileWarningTime > 0 && (userInfo.IsPrivate || userInfo.IsGameDetailsPrivate)) { - g_iWarnTime[player.Slot] = Config.PrivateProfileWarningTime; int playerSlot = player.Slot; + g_iWarnTime[playerSlot] = Config.PrivateProfileWarningTime; + int printInterval = Config.PrivateProfileWarningPrintSeconds; + int remainingPrintTime = printInterval; - AddTimer(Config.PrivateProfileWarningTime, () => - { - if (player?.IsValid == true) - Server.ExecuteCommand($"kickid {player.UserId} \"You have been kicked for not meeting the minimum requirements.\""); - }); - - g_hTimer[playerSlot] = AddTimer(Config.PrivateProfileWarningPrintSeconds, () => + g_hTimer[playerSlot] = AddTimer(1.0f, () => { if (player?.IsValid == true) { - player.PrintToChat($" {ChatColors.Silver}[ {ChatColors.Lime}SteamRestrict {ChatColors.Silver}] {ChatColors.LightRed}Your Steam profile or Game details are private. You will be kicked in {g_iWarnTime[playerSlot]} seconds."); + g_iWarnTime[playerSlot]--; + remainingPrintTime--; + + if (remainingPrintTime <= 0) + { + player.PrintToChat($" {ChatColors.Silver}[ {ChatColors.Lime}SteamRestrict {ChatColors.Silver}] {ChatColors.LightRed}Your Steam profile or Game details are private. You will be kicked in {g_iWarnTime[playerSlot]} seconds."); + remainingPrintTime = printInterval; + } + + if (g_iWarnTime[playerSlot] <= 0) + { + Server.ExecuteCommand($"kickid {player.UserId} \"You have been kicked for not meeting the minimum requirements.\""); + g_hTimer[playerSlot]?.Kill(); + g_hTimer[playerSlot] = null; + } } else { g_hTimer[playerSlot]?.Kill(); g_hTimer[playerSlot] = null; } - - g_iWarnTime[playerSlot] -= Config.PrivateProfileWarningPrintSeconds; }, TimerFlags.REPEAT); } else