diff options
author | Emma Miler <27428383+emma-miler@users.noreply.github.com> | 2022-04-12 22:52:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 22:52:32 +0200 |
commit | 3aff1ab6d7649d9729ebad47b7251ebd24c2f917 (patch) | |
tree | c487a7393f38ff1b4c8baf1dc639ffe402fd0b4a | |
parent | fa534ac10a4fdc134fc732b8920d78fca0395487 (diff) | |
download | NorthstarMods-3aff1ab6d7649d9729ebad47b7251ebd24c2f917.tar.gz NorthstarMods-3aff1ab6d7649d9729ebad47b7251ebd24c2f917.zip |
Restrict and log message sending on connect (#299)
* Restrict message sending on connect
Restricts users from sending messages until they are fully connected. This is related to a bug where if a player joins the server, send a message, and disconnects quickly enough the join message will not show up in the chat.
* Log messages on receive
* Fix issue with private lobbies
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/_custom_codecallbacks.gnut | 5 | ||||
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_custom_codecallbacks.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_custom_codecallbacks.gnut index 9e46f99a..4a7f8189 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/_custom_codecallbacks.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/_custom_codecallbacks.gnut @@ -22,10 +22,11 @@ void function CServerGameDLL_ProcessMessageStartThread(int playerIndex, string m void function CServerGameDLL_OnReceivedSayTextMessageCallback(int playerIndex, string message, bool isTeam) { entity player = GetPlayerByIndex(playerIndex) - if (player == null) { + if (player == null || !player.hasConnected) { print("Ignored chat message from invalid player index " + playerIndex + ": " + message) return } + print("Received message from " + player + "(" + player.GetUID() + "): " + message) ClServer_MessageStruct localMessage localMessage.message = message @@ -55,4 +56,4 @@ void function AddCallback_OnReceivedSayTextMessage( ClServer_MessageStruct funct void function NSSetupChathooksServer() { getroottable().rawset("CServerGameDLL_ProcessMessageStartThread", CServerGameDLL_ProcessMessageStartThread) -}
\ No newline at end of file +} diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut index 33c0b8e9..ae933b71 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut @@ -25,6 +25,7 @@ void function Lobby_OnClientConnectionStarted( entity player ) void function Lobby_OnClientConnectionCompleted( entity player ) { + player.hasConnected = true FinishClientScriptInitialization( player ) } @@ -35,4 +36,4 @@ bool function ClientCommandCallback_StartPrivateMatchSearch( entity player, arra GameRules_ChangeMap( "mp_lobby", GAMETYPE ) return true -}
\ No newline at end of file +} |