From d8820dc1de2129db5c13c08dc8a2a13384d2d97b Mon Sep 17 00:00:00 2001 From: elexis Date: Sun, 27 Nov 2016 23:31:14 +0000 Subject: [PATCH] Add chat command to kick or ban all observers, refs #3241. This is in particular useful as many observers can join in the gamesetup phase (since the server doesn't restrict connects then due to not knowing in advance which client will become an assigned player.) git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@19007 3db68df2-c116-0410-a063-a993310a9797 --- binaries/data/mods/public/gui/common/network.js | 30 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/binaries/data/mods/public/gui/common/network.js b/binaries/data/mods/public/gui/common/network.js index c5a8e353ef..bc4e52e260 100644 --- a/binaries/data/mods/public/gui/common/network.js +++ b/binaries/data/mods/public/gui/common/network.js @@ -39,6 +39,8 @@ var g_NetworkWarningTexts = { var g_NetworkCommands = { "/kick": argument => kickPlayer(argument, false), "/ban": argument => kickPlayer(argument, true), + "/kickspecs": argument => kickObservers(false), + "/banspecs": argument => kickObservers(true), "/list": argument => addChatMessage({ "type": "clientlist" }), "/clear": argument => clearChatMessages() }; @@ -95,17 +97,33 @@ function reportDisconnect(reason, wasConnected) ); } +function kickError() +{ + addChatMessage({ + "type": "system", + "text": translate("Only the host can kick clients!") + }); +} + function kickPlayer(username, ban) { if (g_IsController) Engine.KickPlayer(username, ban); else - addChatMessage({ - "type": "system", - "text": sprintf(ban ? translate("Could not ban %(name)s.") : translate("Could not kick %(name)s."), { - "name": username - }) - }); + kickError(); +} + +function kickObservers(ban) +{ + if (!g_IsController) + { + kickError(); + return; + } + + for (let guid in g_PlayerAssignments) + if (g_PlayerAssignments[guid].player == -1) + Engine.KickPlayer(g_PlayerAssignments[guid].name, ban); } /** -- 2.11.4.GIT