NockyCZ / CS2-Discord-Utilities

Plugin for communication between your CS2 server and your Discord server
https://buymeacoffee.com/sourcefactory
41 stars 18 forks source link

Wrong hostname in Status Discord #25

Closed Armatura-Create closed 2 months ago

Armatura-Create commented 3 months ago

When launching default maps, the hostname is not always transmitted correctly; sometimes it just says Counter Strike 2 I solved this problem by simply initializing the server model 5 seconds later in OnMapStart listener

AddTimer(5.0f, () =>
                {
                    playerData.Clear();
                    serverData = new ServerData
                    {
                        ModuleDirectory = ModuleDirectory,
                        GameDirectory = Server.GameDirectory,
                        Name = ConVar.Find("hostname")!.StringValue,
                        MaxPlayers = Server.MaxPlayers.ToString(),
                        MapName = Server.MapName,
                        OnlinePlayers = 0.ToString(),
                        OnlinePlayersAndBots = 0.ToString(),
                        OnlineBots = 0.ToString(),
                        Timeleft = 60.ToString(),
                        IP = Config.ServerIP
                    };
                    Server.ExecuteCommand("sv_hibernate_when_empty false");
                    ServerDataLoaded();
                });
image
NockyCZ commented 2 months ago

Fixed, https://github.com/NockyCZ/CS2-Discord-Utilities/releases/tag/v2.0.6