diff --git a/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs b/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs index a0e0e2c..58a626e 100644 --- a/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs +++ b/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs @@ -1,5 +1,5 @@ using System.Numerics; -using CommunityServerAPI.BattleBitAPI.Server; +using BattleBitAPI.Server; namespace BattleBitAPI.Common { diff --git a/BattleBitAPI/Server/Internal/GamemodeRotation.cs b/BattleBitAPI/Server/Internal/GamemodeRotation.cs index 7c5ee4d..2e9cd1b 100644 --- a/BattleBitAPI/Server/Internal/GamemodeRotation.cs +++ b/BattleBitAPI/Server/Internal/GamemodeRotation.cs @@ -1,5 +1,5 @@ using BattleBitAPI.Common; -using CommunityServerAPI.BattleBitAPI.Server; +using BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/BattleBitAPI/Server/Internal/MapRotation.cs b/BattleBitAPI/Server/Internal/MapRotation.cs index c718005..601a02b 100644 --- a/BattleBitAPI/Server/Internal/MapRotation.cs +++ b/BattleBitAPI/Server/Internal/MapRotation.cs @@ -1,4 +1,4 @@ -using CommunityServerAPI.BattleBitAPI.Server; +using BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/BattleBitAPI/Server/Internal/RoundSettings.cs b/BattleBitAPI/Server/Internal/RoundSettings.cs index a25a203..d1b9258 100644 --- a/BattleBitAPI/Server/Internal/RoundSettings.cs +++ b/BattleBitAPI/Server/Internal/RoundSettings.cs @@ -1,5 +1,5 @@ using BattleBitAPI.Common; -using CommunityServerAPI.BattleBitAPI.Server; +using BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/BattleBitAPI/Server/Internal/ServerSettings.cs b/BattleBitAPI/Server/Internal/ServerSettings.cs index b84bdf8..2468d52 100644 --- a/BattleBitAPI/Server/Internal/ServerSettings.cs +++ b/BattleBitAPI/Server/Internal/ServerSettings.cs @@ -1,4 +1,4 @@ -using CommunityServerAPI.BattleBitAPI.Server; +using BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/BattleBitAPI/Server/ServerListener.cs b/BattleBitAPI/Server/ServerListener.cs index 5a4d261..14137a6 100644 --- a/BattleBitAPI/Server/ServerListener.cs +++ b/BattleBitAPI/Server/ServerListener.cs @@ -9,7 +9,7 @@ using BattleBitAPI.Common.Extentions; using BattleBitAPI.Common.Serialization; using BattleBitAPI.Networking; using CommunityServerAPI.BattleBitAPI; -using CommunityServerAPI.BattleBitAPI.Server; +using BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/Program.cs b/Program.cs index 41a78a4..bf31063 100644 --- a/Program.cs +++ b/Program.cs @@ -1,8 +1,6 @@ using BattleBitAPI; using BattleBitAPI.Common; using BattleBitAPI.Server; -using System.Threading.Channels; -using System.Xml; class Program { @@ -10,24 +8,24 @@ class Program { var listener = new ServerListener(); listener.Start(30001); - + Console.WriteLine("API started!"); Thread.Sleep(-1); } - - } + class MyPlayer : Player { public int Kills; public int Deaths; public List players; } + class MyGameServer : GameServer { private List players; - + public override async Task OnConnected() { Console.WriteLine($"Gameserver connected! {this.GameIP}:{this.GamePort}"); @@ -35,7 +33,7 @@ class MyGameServer : GameServer ServerSettings.BleedingEnabled = false; ServerSettings.SpectatorEnabled = false; } - + public override async Task OnDisconnected() { Console.WriteLine($"Gameserver disconnected! {this.GameIP}:{this.GamePort}"); @@ -44,23 +42,26 @@ class MyGameServer : GameServer public override async Task OnReconnected() { Console.WriteLine($"Gameserver reconnected! {this.GameIP}:{this.GamePort}"); - + ServerSettings.BleedingEnabled = false; ServerSettings.SpectatorEnabled = false; } public override async Task OnGameStateChanged(GameState oldState, GameState newState) { - await Console.Out.WriteLineAsync("Giveup: " + player); + await Console.Out.WriteLineAsync("State changed to -> " + newState); } + public override async Task OnPlayerDied(MyPlayer player) { await Console.Out.WriteLineAsync("Died: " + player); } + public override async Task OnAPlayerRevivedAnotherPlayer(MyPlayer from, MyPlayer to) { await Console.Out.WriteLineAsync(from + " revived " + to); } + public override async Task OnPlayerDisconnected(MyPlayer player) { await Console.Out.WriteLineAsync("Disconnected: " + player); @@ -71,10 +72,10 @@ class MyGameServer : GameServer var top5 = players.OrderByDescending(x => x.Kills / x.Deaths).Take(5).ToList(); var topPlayersInfo = top5.Select((p, index) => $"{index + 1}. {p.Name} - {p.Kills / p.Deaths}"); var announcement = $"--- Top 5 Players ---\n{string.Join("\n", topPlayersInfo)}"; - + AnnounceShort(announcement); } - + private MyPlayer FindPlayerByIdentifier(string identifier) { ulong.TryParse(identifier, out ulong steamid); @@ -91,64 +92,65 @@ class MyGameServer : GameServer switch (words[0]) { case "/tp": - // /tp + // /tp or /tp (tp executor to target) var tpTarget = FindPlayerByIdentifier(words[1]); - - if (tpTarget == null) + var tpDestination = FindPlayerByIdentifier(words.Length > 2 ? words[2] : player.Name); + + if (tpTarget == null || tpDestination == null) { player.Message("Player not found!"); return false; } - - player.Message("Not implemented yet!"); + + tpTarget.Teleport(tpDestination.Position); break; - + case "/kill": // /kill var killTarget = FindPlayerByIdentifier(words[1]); - + if (killTarget == null) { player.Message("Player not found!"); return false; } - + killTarget.Kill(); break; - + case "/heal": // /heal var healTarget = FindPlayerByIdentifier(words[1]); - + if (healTarget == null) { player.Message("Player not found!"); return false; } - + var healAmount = words.Length > 2 ? int.Parse(words[2]) : 100; healTarget.Heal(healAmount); break; - + case "/kick": // /kick var kickTarget = FindPlayerByIdentifier(words[1]); - + if (kickTarget == null) { player.Message("Player not found!"); return false; } - + var kickReason = words.Length > 2 ? string.Join(" ", words.Skip(2)) : "No reason provided"; - + kickTarget.Kick(kickReason); break; default: player.Message("Unknown command!"); break; } - + return false; } @@ -170,7 +172,7 @@ class MyGameServer : GameServer player.Deaths = 0; } - public override Task OnGetPlayerStats(ulong steamID, PlayerStats officialStats) + public override Task OnPlayerJoiningToServer(ulong steamID, PlayerJoiningArguments args) { var stats = new PlayerStats(); @@ -181,21 +183,23 @@ class MyGameServer : GameServer { stats.Roles = Roles.Admin; } - + return Task.FromResult(stats); } - public override async Task OnAPlayerKilledAnotherPlayer(OnPlayerKillArguments args) + + public override async Task OnAPlayerDownedAnotherPlayer(OnPlayerKillArguments args) { + args.Victim.Kill(); args.Killer.Heal(100); args.Killer.Kills++; args.Victim.Deaths++; } - public override async Task OnPlayerRequestingToChangeRole(MyPlayer player, GameRole role) + public override async Task OnPlayerRequestingToChangeRole(MyPlayer player, GameRole role) { if (role == GameRole.Assault) return true; - + player.GameServer.AnnounceShort("You can only play as Assault!"); return false; } @@ -213,9 +217,9 @@ class MyGameServer : GameServer return request; } - + public override async Task OnPlayerSpawned(MyPlayer player) { player.SetGiveDamageMultiplier(0.25f); } -} +} \ No newline at end of file