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

[Feature] OnMapStarts -> RoundStarts for Modes timeleft #19

Closed mavproductions closed 4 months ago

mavproductions commented 4 months ago

Hey Nocky,

I'm using a Multi-Mod server, and ideally, I would like my server to run a mp_restartgame when a player joins the server.

I am using a plugin like this to accomplish this with other mods on my server.

namespace EndWarmup
{
    using CounterStrikeSharp.API;
    using CounterStrikeSharp.API.Core;
    public sealed partial class Plugin : BasePlugin
    {
        public override string ModuleName => "EndWarmup";
        public override string ModuleAuthor => "audio_brutalci";
        public override string ModuleDescription => "";
        public override string ModuleVersion => "0.0.1";

        public override void Load(bool hotReload)
        {
            RegisterEventHandler<EventPlayerConnectFull>(OnPlayerConnect);
        }

        private static int PlayersConnected()
        {
            return Utilities.GetPlayers().Where(player => player.IsValid && !player.IsHLTV && !player.IsBot).Count();
        }

        public HookResult OnPlayerConnect(EventPlayerConnectFull @event, GameEventInfo info)
        {
            if (PlayersConnected() == 1)
            {
                Server.ExecuteCommand("mp_restartgame 1");
                Server.ExecuteCommand("mp_warmup_end");

            }
            return HookResult.Continue;
        }
    }
}

I would ideally like something like this already integrated into your mod as a toggle (or however you choose to do it), or allowing your plugin to work with the code displayed above.

Thanks!

mavproductions commented 4 months ago

Wrong plugin repo. Brought issue over to other repo 😅