From 2bef5f87db7c0c575f8018db8ef1144c96ad6063 Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Mon, 25 Mar 2019 18:55:38 +0100 Subject: [PATCH] Parametrized !shuffle command (fixes #101) --- .../wolfadmin/commands/admin/shuffle.lua | 26 ++++++++++++++--- .../wolfadmin/commands/admin/shufflesr.lua | 29 ------------------- 2 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 luascripts/wolfadmin/commands/admin/shufflesr.lua diff --git a/luascripts/wolfadmin/commands/admin/shuffle.lua b/luascripts/wolfadmin/commands/admin/shuffle.lua index 0bc7f23..a919d75 100644 --- a/luascripts/wolfadmin/commands/admin/shuffle.lua +++ b/luascripts/wolfadmin/commands/admin/shuffle.lua @@ -19,11 +19,29 @@ local auth = wolfa_requireModule("auth.auth") local commands = wolfa_requireModule("commands.commands") local settings = wolfa_requireModule("util.settings") -function commandShuffle(clientId, command) - et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by XP.\";") +function commandShuffle(clientId, command, type) + if type == "xp" then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by XP.\";") - et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams") + et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams") + elseif type == "sr" then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by SR.\";") + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams_sr") + elseif type == nil then + if settings.get("fs_game") == "legacy" then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by SR.\";") + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams_sr") + else + et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by XP.\";") + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams") + end + else + et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dshuffle usage: "..commands.getadmin("shuffle")["syntax"].."\";") + end return true end -commands.addadmin("shuffle", commandShuffle, auth.PERM_SHUFFLE, "shuffle the teams by XP to try and even them", nil, nil, (settings.get("g_standalone") == 0)) +commands.addadmin("shuffle", commandShuffle, auth.PERM_SHUFFLE, "shuffle the teams to try and even them", "^2!shuffle ^9(^hxp|sr^9)", nil, (settings.get("g_standalone") == 0)) diff --git a/luascripts/wolfadmin/commands/admin/shufflesr.lua b/luascripts/wolfadmin/commands/admin/shufflesr.lua deleted file mode 100644 index 5961ba2..0000000 --- a/luascripts/wolfadmin/commands/admin/shufflesr.lua +++ /dev/null @@ -1,29 +0,0 @@ - --- WolfAdmin module for Wolfenstein: Enemy Territory servers. --- Copyright (C) 2015-2019 Timo 'Timothy' Smit - --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- at your option any later version. - --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. - --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -local auth = wolfa_requireModule("auth.auth") -local commands = wolfa_requireModule("commands.commands") -local settings = wolfa_requireModule("util.settings") - -function commandShuffleSR(clientId, command) - et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dshuffle: ^9teams were shuffled by Skill Rating.\";") - - et.trap_SendConsoleCommand(et.EXEC_APPEND, "shuffle_teams_sr") - - return true -end -commands.addadmin("shufflesr", commandShuffleSR, auth.PERM_SHUFFLE, "shuffle the teams by Skill Rating to try and even them", nil, nil, (settings.get("fs_game") ~= "legacy"))