Hotfix - server loading

- Fix for server loading
This commit is contained in:
Dawid Bepierszcz
2024-11-22 23:01:31 +01:00
parent b2ebe136c3
commit 2defb2fe14
3 changed files with 15 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
if (hotReload)
{
ServerLoaded = false;
_serverLoading = false;
OnGameServerSteamAPIActivated();
OnMapStart(string.Empty);

View File

@@ -17,6 +17,8 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
private bool _serverLoading;
private void RegisterEvents()
{
RegisterListener<Listeners.OnMapStart>(OnMapStart);
@@ -49,6 +51,10 @@ public partial class CS2_SimpleAdmin
private void OnGameServerSteamAPIActivated()
{
if (_serverLoading)
return;
_serverLoading = true;
new ServerManager().LoadServerData();
}
@@ -330,11 +336,11 @@ public partial class CS2_SimpleAdmin
if (Config.OtherSettings.ReloadAdminsEveryMapChange && ServerLoaded && ServerId != null)
AddTimer(3.0f, () => ReloadAdmins(null));
AddTimer(34, () =>
{
if (!ServerLoaded)
OnGameServerSteamAPIActivated();
});
// AddTimer(34, () =>
// {
// if (!ServerLoaded)
// OnGameServerSteamAPIActivated();
// });
GodPlayers.Clear();
SilentPlayers.Clear();

View File

@@ -15,7 +15,7 @@ public class ServerManager
{
if (CS2_SimpleAdmin.ServerLoaded || CS2_SimpleAdmin.ServerId != null || CS2_SimpleAdmin.Database == null) return;
if (_getIpTryCount > 16)
if (_getIpTryCount > 16 && Helper.GetServerIp().StartsWith("0.0.0.0") || string.IsNullOrEmpty(Helper.GetServerIp()))
{
CS2_SimpleAdmin._logger?.LogError("Unable to load server data - can't fetch ip address!");
return;
@@ -39,6 +39,8 @@ public class ServerManager
var address = $"{ipAddress}:{ConVar.Find("hostport")?.GetPrimitiveValue<int>()}";
var hostname = ConVar.Find("hostname")!.StringValue;
CS2_SimpleAdmin.IpAddress = address;
CS2_SimpleAdmin._logger?.LogInformation("Loaded server with ip {ip}", ipAddress);
Task.Run(async () =>
{