diff --git a/.vs/CommunityServerAPI/FileContentIndex/294619c2-7791-40e7-ba38-9cc5a642c0bc.vsidx b/.vs/CommunityServerAPI/FileContentIndex/294619c2-7791-40e7-ba38-9cc5a642c0bc.vsidx
new file mode 100644
index 0000000..fba731a
Binary files /dev/null and b/.vs/CommunityServerAPI/FileContentIndex/294619c2-7791-40e7-ba38-9cc5a642c0bc.vsidx differ
diff --git a/.vs/CommunityServerAPI/FileContentIndex/cd40a925-bf38-4e6f-8da2-c19bdbb709f8.vsidx b/.vs/CommunityServerAPI/FileContentIndex/704c6c55-56c8-4f42-aee0-b9ab92032f8d.vsidx
similarity index 75%
rename from .vs/CommunityServerAPI/FileContentIndex/cd40a925-bf38-4e6f-8da2-c19bdbb709f8.vsidx
rename to .vs/CommunityServerAPI/FileContentIndex/704c6c55-56c8-4f42-aee0-b9ab92032f8d.vsidx
index ce9d83f..aee4d8c 100644
Binary files a/.vs/CommunityServerAPI/FileContentIndex/cd40a925-bf38-4e6f-8da2-c19bdbb709f8.vsidx and b/.vs/CommunityServerAPI/FileContentIndex/704c6c55-56c8-4f42-aee0-b9ab92032f8d.vsidx differ
diff --git a/.vs/CommunityServerAPI/FileContentIndex/75e5fed3-9ebe-4f37-a2a6-163b8abeca55.vsidx b/.vs/CommunityServerAPI/FileContentIndex/d3342608-bdca-4bc6-b2e9-367f8d0b02b9.vsidx
similarity index 79%
rename from .vs/CommunityServerAPI/FileContentIndex/75e5fed3-9ebe-4f37-a2a6-163b8abeca55.vsidx
rename to .vs/CommunityServerAPI/FileContentIndex/d3342608-bdca-4bc6-b2e9-367f8d0b02b9.vsidx
index 6759e87..55ab044 100644
Binary files a/.vs/CommunityServerAPI/FileContentIndex/75e5fed3-9ebe-4f37-a2a6-163b8abeca55.vsidx and b/.vs/CommunityServerAPI/FileContentIndex/d3342608-bdca-4bc6-b2e9-367f8d0b02b9.vsidx differ
diff --git a/.vs/CommunityServerAPI/FileContentIndex/daa5c73d-5e00-467e-94d4-6ca2cb40af0d.vsidx b/.vs/CommunityServerAPI/FileContentIndex/daa5c73d-5e00-467e-94d4-6ca2cb40af0d.vsidx
deleted file mode 100644
index 6777e63..0000000
Binary files a/.vs/CommunityServerAPI/FileContentIndex/daa5c73d-5e00-467e-94d4-6ca2cb40af0d.vsidx and /dev/null differ
diff --git a/.vs/CommunityServerAPI/FileContentIndex/8a207fb2-7594-49af-a59c-6b94b15e19a5.vsidx b/.vs/CommunityServerAPI/FileContentIndex/e3f880b8-7637-42b5-b5b7-0e11b9874b7a.vsidx
similarity index 71%
rename from .vs/CommunityServerAPI/FileContentIndex/8a207fb2-7594-49af-a59c-6b94b15e19a5.vsidx
rename to .vs/CommunityServerAPI/FileContentIndex/e3f880b8-7637-42b5-b5b7-0e11b9874b7a.vsidx
index 42c2586..032b61c 100644
Binary files a/.vs/CommunityServerAPI/FileContentIndex/8a207fb2-7594-49af-a59c-6b94b15e19a5.vsidx and b/.vs/CommunityServerAPI/FileContentIndex/e3f880b8-7637-42b5-b5b7-0e11b9874b7a.vsidx differ
diff --git a/.vs/CommunityServerAPI/v17/.futdcache.v2 b/.vs/CommunityServerAPI/v17/.futdcache.v2
index 66f7da2..1f3c6ba 100644
Binary files a/.vs/CommunityServerAPI/v17/.futdcache.v2 and b/.vs/CommunityServerAPI/v17/.futdcache.v2 differ
diff --git a/.vs/ProjectEvaluation/communityserverapi.metadata.v6.1 b/.vs/ProjectEvaluation/communityserverapi.metadata.v6.1
index bca460e..2294723 100644
Binary files a/.vs/ProjectEvaluation/communityserverapi.metadata.v6.1 and b/.vs/ProjectEvaluation/communityserverapi.metadata.v6.1 differ
diff --git a/.vs/ProjectEvaluation/communityserverapi.projects.v6.1 b/.vs/ProjectEvaluation/communityserverapi.projects.v6.1
index 23bacc8..3746240 100644
Binary files a/.vs/ProjectEvaluation/communityserverapi.projects.v6.1 and b/.vs/ProjectEvaluation/communityserverapi.projects.v6.1 differ
diff --git a/BattleBitAPI/Networking/NetworkCommuncation.cs b/BattleBitAPI/Networking/NetworkCommuncation.cs
index 3f251e3..18e6859 100644
--- a/BattleBitAPI/Networking/NetworkCommuncation.cs
+++ b/BattleBitAPI/Networking/NetworkCommuncation.cs
@@ -11,6 +11,7 @@
SendPlayerStats = 11,
SpawnPlayer = 12,
SetNewRoomSettings = 13,
+ RespondPlayerMessage = 14,
PlayerConnected = 50,
PlayerDisconnected = 51,
diff --git a/BattleBitAPI/Server/GameServer.cs b/BattleBitAPI/Server/GameServer.cs
index 5a72fd3..56aa88b 100644
--- a/BattleBitAPI/Server/GameServer.cs
+++ b/BattleBitAPI/Server/GameServer.cs
@@ -14,10 +14,10 @@ namespace BattleBitAPI.Server
// ---- Public Variables ----
public TcpClient Socket { get; private set; }
+ public ulong ServerHash { get; private set; }
///
/// Is game server connected to our server?
///
- public ulong ServerHash { get; private set; }
public bool IsConnected { get; private set; }
public IPAddress GameIP { get; private set; }
public int GamePort { get; private set; }
@@ -54,7 +54,7 @@ namespace BattleBitAPI.Server
private mInternalResources mInternal;
private StringBuilder mBuilder;
- // ---- Constrction ----
+ // ---- Construction ----
public GameServer(TcpClient socket, mInternalResources resources, Func func, IPAddress iP, int port, bool isPasswordProtected, string serverName, string gamemode, string map, MapSize mapSize, MapDayNight dayNight, int currentPlayers, int inQueuePlayers, int maxPlayers, string loadingScreenText, string serverRulesText)
{
this.IsConnected = true;
diff --git a/BattleBitAPI/Server/ServerListener.cs b/BattleBitAPI/Server/ServerListener.cs
index 2def85f..c191906 100644
--- a/BattleBitAPI/Server/ServerListener.cs
+++ b/BattleBitAPI/Server/ServerListener.cs
@@ -92,7 +92,10 @@ namespace BattleBitAPI.Server
/// ChatChannel: The channel the message was sent
/// string - Message: The message
///
- public Func OnPlayerTypedMessage { get; set; }
+ ///
+ /// Returns: True if you let the message broadcasted, false if you don't it to be broadcasted.
+ ///
+ public Func> OnPlayerTypedMessage { get; set; }
///
/// Fired when a player kills another player.
@@ -794,8 +797,9 @@ namespace BattleBitAPI.Server
}
case NetworkCommuncation.OnPlayerTypedMessage:
{
- if (stream.CanRead(8 + 1 + 2))
+ if (stream.CanRead(2 + 8 + 1 + 2))
{
+ ushort messageID = stream.ReadUInt16();
ulong steamID = stream.ReadUInt64();
if (resources.TryGetPlayer(steamID, out var player))
@@ -803,8 +807,18 @@ namespace BattleBitAPI.Server
ChatChannel chat = (ChatChannel)stream.ReadInt8();
if (stream.TryReadString(out var msg))
{
+ bool pass = true;
if (OnPlayerTypedMessage != null)
- await OnPlayerTypedMessage.Invoke((TPlayer)player, chat, msg);
+ pass = await OnPlayerTypedMessage.Invoke((TPlayer)player, chat, msg);
+
+ //Respond back.
+ using (var response = Common.Serialization.Stream.Get())
+ {
+ response.Write((byte)NetworkCommuncation.RespondPlayerMessage);
+ response.Write(messageID);
+ response.Write(pass);
+ server.WriteToSocket(response);
+ }
}
}
}
diff --git a/Program.cs b/Program.cs
index 7b54cec..e79826e 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,7 +1,9 @@
using BattleBitAPI;
using BattleBitAPI.Common;
using BattleBitAPI.Server;
-using BattleBitAPI.Storage;
+using System.Diagnostics;
+using System.Net;
+using System.Net.Http.Headers;
using System.Numerics;
class Program
@@ -9,21 +11,32 @@ class Program
static void Main(string[] args)
{
var listener = new ServerListener();
- listener.OnGameServerTick += OnGameServerTick;
- listener.Start(29294);//Port
+ listener.Start(29294);
+
+ listener.OnPlayerTypedMessage += OnPlayerTypedMessage;
+
Thread.Sleep(-1);
}
- private static async Task OnGameServerTick(GameServer server)
+ private static async Task OnPlayerTypedMessage(MyPlayer player, ChatChannel ch, string msg)
{
- //server.Settings.SpectatorEnabled = !server.Settings.SpectatorEnabled;
- //server.MapRotation.AddToRotation("DustyDew");
- //server.MapRotation.AddToRotation("District");
- //server.GamemodeRotation.AddToRotation("CONQ");
- //server.ForceEndGame();
+ if (msg == "nword")
+ {
+ player.NumberOfNWord++;
+ if (player.NumberOfNWord > 4)
+ {
+ player.Kick("N word is not accepted!");
+ }
+ else
+ {
+ player.Message("Do not type nword, this is your " + player.NumberOfNWord + "th warning");
+ }
+ return false;
+ }
+ return true;
}
}
class MyPlayer : Player
{
-
-}
+ public int NumberOfNWord;
+}
\ No newline at end of file
diff --git a/bin/Debug/net6.0/CommunityServerAPI.dll b/bin/Debug/net6.0/CommunityServerAPI.dll
index acd038e..7ecc677 100644
Binary files a/bin/Debug/net6.0/CommunityServerAPI.dll and b/bin/Debug/net6.0/CommunityServerAPI.dll differ
diff --git a/bin/Debug/net6.0/CommunityServerAPI.pdb b/bin/Debug/net6.0/CommunityServerAPI.pdb
index 6b3a129..f084d54 100644
Binary files a/bin/Debug/net6.0/CommunityServerAPI.pdb and b/bin/Debug/net6.0/CommunityServerAPI.pdb differ
diff --git a/obj/Debug/net6.0/CommunityServerAPI.dll b/obj/Debug/net6.0/CommunityServerAPI.dll
index acd038e..7ecc677 100644
Binary files a/obj/Debug/net6.0/CommunityServerAPI.dll and b/obj/Debug/net6.0/CommunityServerAPI.dll differ
diff --git a/obj/Debug/net6.0/CommunityServerAPI.pdb b/obj/Debug/net6.0/CommunityServerAPI.pdb
index 6b3a129..f084d54 100644
Binary files a/obj/Debug/net6.0/CommunityServerAPI.pdb and b/obj/Debug/net6.0/CommunityServerAPI.pdb differ
diff --git a/obj/Debug/net6.0/ref/CommunityServerAPI.dll b/obj/Debug/net6.0/ref/CommunityServerAPI.dll
index 35e6b9a..c7d507c 100644
Binary files a/obj/Debug/net6.0/ref/CommunityServerAPI.dll and b/obj/Debug/net6.0/ref/CommunityServerAPI.dll differ
diff --git a/obj/Debug/net6.0/refint/CommunityServerAPI.dll b/obj/Debug/net6.0/refint/CommunityServerAPI.dll
index 35e6b9a..c7d507c 100644
Binary files a/obj/Debug/net6.0/refint/CommunityServerAPI.dll and b/obj/Debug/net6.0/refint/CommunityServerAPI.dll differ