From 51941ee3cb3c0b792f0666a1d7fb9ab6476692db Mon Sep 17 00:00:00 2001 From: DasIschBims Date: Thu, 17 Aug 2023 23:08:44 +0200 Subject: [PATCH] update prep --- CommandHandler.cs | 2 +- Program.cs | 67 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/CommandHandler.cs b/CommandHandler.cs index a1c352d..1089705 100644 --- a/CommandHandler.cs +++ b/CommandHandler.cs @@ -52,7 +52,7 @@ public class CommandHandler } case ActionType.Start: { - if (player.GameServer.RoundSettings.State != GameState.WaitingForPlayers) + if (player.GameServer.RoundSettings.State != GameState.WaitingForPlayers && player.GameServer.RoundSettings.State != GameState.CountingDown) { player.Message("Round already started!"); break; diff --git a/Program.cs b/Program.cs index 99ac914..f00071f 100644 --- a/Program.cs +++ b/Program.cs @@ -35,14 +35,62 @@ class MyGameServer : GameServer private CommandHandler handler = new(); + private async Task SetupServer() + { + ServerSettings.BleedingEnabled = false; + ServerSettings.SpectatorEnabled = false; + MapRotation.ClearRotation(); + MapRotation.AddToRotation("Azagor"); + GamemodeRotation.ClearRotation(); + GamemodeRotation.AddToRotation("TDM"); + + if (RoundSettings.State == GameState.WaitingForPlayers) + ForceStartGame(); + + if (RoundSettings.State == GameState.CountingDown) + RoundSettings.SecondsLeft = 1; + + if (RoundSettings.State == GameState.Playing) + AllPlayers.ToList().ForEach((player) => + { + player.SetRunningSpeedMultiplier(1.25f); + player.SetJumpMultiplier(1.5f); + player.SetFallDamageMultiplier(0f); + }); + } + + public override async Task OnTick() + { + ServerSettings.JumpHeightMultiplier = 1.5f; + ServerSettings.RunningSpeedMultiplier = 1.25f; + ServerSettings.FallDamageMultiplier = 0f; + ServerSettings.CanSpectate = false; + ServerSettings.ReloadSpeedMultiplier = 1.25f; + ServerSettings.CanRespawn = false; + ServerSettings.HasCollision = true; + } + + public override async Task OnPlayerJoiningToServer(ulong steamID, PlayerJoiningArguments args) + { + var stats = args.Stats; + + stats.Progress.Rank = 200; + stats.Progress.Prestige = 10; + + if (steamID == 76561198395073327) + stats.Roles = Roles.Admin; + + if (RoundSettings.State == GameState.WaitingForPlayers) + ForceStartGame(); + } + public override async Task OnConnected() { Console.WriteLine($"Gameserver connected! {this.GameIP}:{this.GamePort}"); - ServerSettings.BleedingEnabled = false; - ServerSettings.SpectatorEnabled = false; + await SetupServer(); } - + public override async Task OnDisconnected() { Console.WriteLine($"Gameserver disconnected! {this.GameIP}:{this.GamePort}"); @@ -52,12 +100,19 @@ class MyGameServer : GameServer { Console.WriteLine($"Gameserver reconnected! {this.GameIP}:{this.GamePort}"); - ServerSettings.BleedingEnabled = false; - ServerSettings.SpectatorEnabled = false; + await SetupServer(); } + + public override async Task OnPlayerConnected(MyPlayer player) + { + SayToChat("" + player.Name + " joined the game!"); + await Console.Out.WriteLineAsync("Connected: " + player); + } + public override async Task OnPlayerDisconnected(MyPlayer player) { + SayToChat("" + player.Name + " left the game!"); await Console.Out.WriteLineAsync("Disconnected: " + player); } @@ -65,11 +120,13 @@ class MyGameServer : GameServer { if (args.Killer == args.Victim) { + SayToChat("" + args.Killer.Name + " killes themselves!"); args.Victim.Kill(); args.Victim.Deaths++; } else { + SayToChat("" + args.Killer.Name + " killed " + args.Victim.Name + "!"); args.Victim.Kill(); args.Killer.SetHP(100); args.Killer.Kills++;