mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-10 06:41:53 +00:00
Implemented a first basic set of commands (issue #62)
This commit is contained in:
parent
9b9836d40b
commit
0d5a4d0adf
15 changed files with 746 additions and 6 deletions
|
@ -19,6 +19,7 @@ local constants = require "luascripts.wolfadmin.util.constants"
|
|||
local events = require "luascripts.wolfadmin.util.events"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local files = require "luascripts.wolfadmin.util.files"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
local db = require "luascripts.wolfadmin.db.db"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
|
@ -58,6 +59,10 @@ function admin.unmuteVoice(clientId)
|
|||
stats.set(clientId, "voiceMute", false)
|
||||
end
|
||||
|
||||
function admin.putPlayer(clientId, teamId)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "forceteam "..clientId.." "..util.getTeamCode(teamId)..";")
|
||||
end
|
||||
|
||||
function admin.lockTeam(teamId)
|
||||
teamLocks[teamId] = false
|
||||
end
|
||||
|
|
28
luascripts/commands/admin/admintest.lua
Normal file
28
luascripts/commands/admin/admintest.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandAdminTest(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dadmintest: "..stats.get(clientId, "playerName").." ^9is a level "..auth.getlevel(clientId).." user (".."^7Guest".."^9).\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("admintest", commandAdminTest, auth.PERM_ADMINTEST, "display your current admin level", nil, (settings.get("g_standalone") == 0))
|
61
luascripts/commands/admin/finger.lua
Normal file
61
luascripts/commands/admin/finger.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
|
||||
function commandFinger(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfinger usage: "..commands.getadmin("finger")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfinger: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dfinger: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local stats = {
|
||||
["name"] = et.gentity_get(cmdClient, "pers.netname"),
|
||||
["cleanname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^[^^]", ""),
|
||||
["codedsname"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^([^^])", "^^2%1"),
|
||||
["guid"] = et.gentity_get(cmdClient, "pers.netname"):gsub("%^([^^])", "^^2%1"),
|
||||
["slot"] = cmdClient,
|
||||
["guid"] = stats.get(cmdClient, "playerGUID"),
|
||||
}
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dInformation about ^7"..stats["name"].."^d:\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dName: ^2"..stats["cleanname"].." ("..stats["codedsname"]..")\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dSlot: ^2"..stats["slot"]..(stats["slot"] < tonumber(et.trap_Cvar_Get("sv_privateClients")) and " ^9(private)" or "").."\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dGUID: ^2"..stats["guid"].."\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("finger", commandFinger, auth.PERM_FINGER, "gives specific information about a player", "^9[^3name|slot#^9]", (settings.get("g_standalone") == 0))
|
63
luascripts/commands/admin/gib.lua
Normal file
63
luascripts/commands/admin/gib.lua
Normal file
|
@ -0,0 +1,63 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandGib(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib usage: "..commands.getadmin("gib")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isallowed(cmdClient, "!") == 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getlevel(cmdClient) > auth.getlevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgib: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- GENTITYNUM_BITS 10 10
|
||||
-- MAX_GENTITIES 1 << GENTITYNUM_BITS 20
|
||||
-- ENTITYNUM_WORLD MAX_GENTITIES - 2 18
|
||||
et.G_Damage(cmdClient, 18, 18, 500, 0, 0) -- MOD_UNKNOWN = 0
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dgib: ^7"..stats.get(cmdClient, "playerName").." ^9was gibbed.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("gib", commandGib, auth.PERM_GIB, "insantly gibs a player", "^9(^3name|slot#^9) (^hreason^9)", (settings.get("g_standalone") == 0))
|
|
@ -31,7 +31,7 @@ function commandHelp(clientId, cmdArguments)
|
|||
end
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dhelp: ^9"..#availableCommands.." "..((settings.get("g_standalone") == 0) and "additional " or "").."commands (open console for the full list)\";")
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dhelp: ^9"..#availableCommands.." "..((settings.get("g_standalone") == 1) and "available" or "additional").." commands (open console for the full list)\";")
|
||||
|
||||
local cmdsOnLine, cmdsBuffer = 0, ""
|
||||
|
||||
|
@ -68,8 +68,4 @@ function commandHelp(clientId, cmdArguments)
|
|||
|
||||
return false
|
||||
end
|
||||
<<<<<<< HEAD
|
||||
commands.addadmin("help", commandHelp, "h", "display commands available to you or help on a specific command", "^9(^hcommand^9)", true)
|
||||
=======
|
||||
commands.addadmin("help", commandHelp, auth.PERM_HELP, "display commands available to you or help on a specific command", "^9(^hcommand^9)", true)
|
||||
>>>>>>> feature/auth
|
||||
commands.addadmin("help", commandHelp, auth.PERM_HELP, "display commands available to you or help on a specific command", "^9(^hcommand^9)", (settings.get("g_standalone") == 0))
|
||||
|
|
57
luascripts/commands/admin/kick.lua
Normal file
57
luascripts/commands/admin/kick.lua
Normal file
|
@ -0,0 +1,57 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
|
||||
function commandKick(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick usage: "..commands.getadmin("kick")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isallowed(cmdClient, "!") == 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getlevel(cmdClient) > auth.getlevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dkick: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
et.trap_DropClient(cmdClient, "You have been kicked, Reason: "..(cmdArguments[2] and cmdArguments[2] or "kicked by admin"), 0)
|
||||
|
||||
return false
|
||||
end
|
||||
commands.addadmin("kick", commandKick, auth.PERM_KICK, "kick a player with an optional reason", "^9[^3name|slot#^9] ^9(^3reason^9)", (settings.get("g_standalone") == 0))
|
85
luascripts/commands/admin/listplayers.lua
Normal file
85
luascripts/commands/admin/listplayers.lua
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local fireteams = require "luascripts.wolfadmin.game.fireteams"
|
||||
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
|
||||
function commandListPlayers(clientId, cmdArguments)
|
||||
local players = {}
|
||||
|
||||
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
|
||||
if wolfa_isPlayer(playerId) then
|
||||
table.insert(players, playerId)
|
||||
end
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dCurrently ^7"..(#players).." ^dplayers online^d:\";")
|
||||
for _, player in pairs(players) do
|
||||
local guidStub
|
||||
|
||||
if stats.get(player, "isBot") then
|
||||
guidStub = "OMNIBOT-"
|
||||
else
|
||||
guidStub = stats.get(player, "playerGUID"):sub(-8)
|
||||
end
|
||||
|
||||
local teamColor, teamCode
|
||||
|
||||
if et.gentity_get(player, "pers.connected") then
|
||||
teamColor = util.getTeamColor(tonumber(et.gentity_get(player, "sess.sessionTeam")))
|
||||
teamCode = util.getTeamCode(tonumber(et.gentity_get(player, "sess.sessionTeam"))):upper():sub(1,1)
|
||||
else
|
||||
teamColor = "^8"
|
||||
teamCode = "C"
|
||||
end
|
||||
|
||||
local fireteamId, fireteamName = fireteams.getPlayerFireteamId(player), ""
|
||||
|
||||
if fireteamId then
|
||||
fireteamName = fireteams.getName(fireteamId):sub(1, 1)
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^f"..string.format("%2i %s ^7%-2i %20s ^7(*%s) ^1%1s ^3%1s ^7%s ^7%s%s^7%s",
|
||||
player, -- slot
|
||||
teamCode, -- team
|
||||
auth.getlevel(player), -- level
|
||||
"Guest", -- levelname
|
||||
guidStub, -- guid stub
|
||||
(stats.get(player, "playerMuted") and "M" or ""), -- muted
|
||||
fireteamName, -- fireteam
|
||||
stats.get(player, "playerName"), -- name
|
||||
"", -- alias open
|
||||
"", -- alias
|
||||
"" -- alias close
|
||||
).."\";")
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistplayers: ^9current player info was printed to the console.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("listplayers", commandListPlayers, auth.PERM_LISTPLAYERS, "display a list of connected players, their slot numbers as well as their admin levels", nil, (settings.get("g_standalone") == 0))
|
29
luascripts/commands/admin/nextmap.lua
Normal file
29
luascripts/commands/admin/nextmap.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandNextMap(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dnextmap: ^9next map was loaded.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "vstr nextmap")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("nextmap", commandNextMap, auth.PERM_NEXTMAP, "loads the next map", nil, (settings.get("g_standalone") == 0))
|
30
luascripts/commands/admin/pause.lua
Normal file
30
luascripts/commands/admin/pause.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandPause(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dpause: ^9map paused.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ref pause")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("pause", commandPause, auth.PERM_RESTART, "pauses the game for all players", nil, (settings.get("g_standalone") == 0))
|
73
luascripts/commands/admin/put.lua
Normal file
73
luascripts/commands/admin/put.lua
Normal file
|
@ -0,0 +1,73 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local admin = require "luascripts.wolfadmin.admin.admin"
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local util = require "luascripts.wolfadmin.util.util"
|
||||
|
||||
function commandPlayerLock(clientId, cmdArguments)
|
||||
if cmdArguments[2] == nil or (cmdArguments[2] ~= constants.TEAM_AXIS_SC and cmdArguments[2] ~= constants.TEAM_ALLIES_SC and cmdArguments[2] ~= constants.TEAM_SPECTATORS_SC) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput usage: "..commands.getadmin("put")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isallowed(cmdClient, "!") == 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getlevel(cmdClient) > auth.getlevel(cmdClient) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dput: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local team
|
||||
if cmdArguments[2] == constants.TEAM_AXIS_SC then
|
||||
team = constants.TEAM_AXIS
|
||||
elseif cmdArguments[2] == constants.TEAM_ALLIES_SC then
|
||||
team = constants.TEAM_ALLIES
|
||||
elseif cmdArguments[2] == constants.TEAM_SPECTATORS_SC then
|
||||
team = constants.TEAM_SPECTATORS
|
||||
end
|
||||
|
||||
local teamname = util.getTeamColor(team)..util.getTeamName(team)
|
||||
|
||||
-- TODO fix behaviour, cannot unbalance teams (see g_svcmds.c:SetTeam)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "chat \"^dput: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9has been put to "..teamname.."\";")
|
||||
|
||||
admin.putPlayer(cmdClient, team)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("put", commandPlayerLock, auth.PERM_LOCKPLAYER, "locks a player to a specific team", "^9[^3name|slot#^9]")
|
37
luascripts/commands/admin/restart.lua
Normal file
37
luascripts/commands/admin/restart.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandRestart(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^drestart: ^9map restarted.\";")
|
||||
|
||||
local currentState = game.getState()
|
||||
local newState = 5 -- GS_RESET
|
||||
|
||||
if currentState == 0 or currentState == 3 then -- GS_PLAYING or GS_INTERMISSION
|
||||
newState = 2 -- GS_WARMUP
|
||||
end
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "map_restart 0 "..newState)
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("restart", commandRestart, auth.PERM_RESTART, "restarts the current map", nil, (settings.get("g_standalone") == 0))
|
66
luascripts/commands/admin/slap.lua
Normal file
66
luascripts/commands/admin/slap.lua
Normal file
|
@ -0,0 +1,66 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local stats = require "luascripts.wolfadmin.players.stats"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandSlap(clientId, cmdArguments)
|
||||
if cmdArguments[1] == nil then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap usage: "..commands.getadmin("slap")["syntax"].."\";")
|
||||
|
||||
return true
|
||||
elseif tonumber(cmdArguments[1]) == nil then
|
||||
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||
else
|
||||
cmdClient = tonumber(cmdArguments[1])
|
||||
end
|
||||
|
||||
if cmdClient == -1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^9no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||
|
||||
return true
|
||||
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^9no connected player by that name or slot #\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if auth.isallowed(cmdClient, "!") == 1 then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
|
||||
|
||||
return true
|
||||
elseif auth.getlevel(cmdClient) > auth.getlevel(clientId) then
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dslap: ^9sorry, but your intended victim has a higher admin level than you do.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local newHealth = et.gentity_get(cmdClient, "health") - 20
|
||||
|
||||
if newHealth < 1 then
|
||||
newHealth = 1
|
||||
end
|
||||
|
||||
et.gentity_set(cmdClient, "health", newHealth)
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dslap: ^7"..stats.get(cmdClient, "playerName").." ^9was slapped.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("slap", commandSlap, auth.PERM_SLAP, "give a player a specified amount of damage for a specified reason", "^9[^3name|slot#^9] (^hdamage^9) (^hreason^9)", (settings.get("g_standalone") == 0))
|
27
luascripts/commands/admin/time.lua
Normal file
27
luascripts/commands/admin/time.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandTime(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dtime: ^9current time is ^7"..os.date("%H:%M:%S").."^9.\";")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("time", commandTime, auth.PERM_TIME, "displays the local time", nil, (settings.get("g_standalone") == 0))
|
30
luascripts/commands/admin/unpause.lua
Normal file
30
luascripts/commands/admin/unpause.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local auth = require "luascripts.wolfadmin.auth.auth"
|
||||
local commands = require "luascripts.wolfadmin.commands.commands"
|
||||
local game = require "luascripts.wolfadmin.game.game"
|
||||
local settings = require "luascripts.wolfadmin.util.settings"
|
||||
|
||||
function commandUnpause(clientId, cmdArguments)
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dpause: ^9map unpaused.\";")
|
||||
|
||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ref unpause")
|
||||
|
||||
return true
|
||||
end
|
||||
commands.addadmin("unpause", commandUnpause, auth.PERM_PAUSE, "pauses the game for all players", nil, (settings.get("g_standalone") == 0))
|
153
luascripts/game/fireteams.lua
Normal file
153
luascripts/game/fireteams.lua
Normal file
|
@ -0,0 +1,153 @@
|
|||
|
||||
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
|
||||
-- Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
local teams = require "luascripts.wolfadmin.game.teams"
|
||||
|
||||
local bits = require "luascripts.wolfadmin.util.bits"
|
||||
local constants = require "luascripts.wolfadmin.util.constants"
|
||||
local events = require "luascripts.wolfadmin.util.events"
|
||||
|
||||
local fireteams = {}
|
||||
|
||||
fireteams.FT_ALPHA = 0
|
||||
fireteams.FT_BRAVO = 1
|
||||
fireteams.FT_CHARLIE = 2
|
||||
fireteams.FT_DELTA = 3
|
||||
fireteams.FT_ECHO = 4
|
||||
fireteams.FT_FOXTROT = 5
|
||||
|
||||
fireteams.NUM_FIRETEAMS = 6
|
||||
|
||||
function fireteams.getId(fireteam)
|
||||
return 893 + fireteam
|
||||
end
|
||||
|
||||
function fireteams.isUsed(fireteamId)
|
||||
if not fireteamId then
|
||||
return nil
|
||||
end
|
||||
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
local id = tonumber(et.Info_ValueForKey(data, "id"))
|
||||
|
||||
return (id ~= -1)
|
||||
end
|
||||
|
||||
function fireteams.isPrivate(fireteamId)
|
||||
if not fireteamId or not fireteams.isUsed(fireteamId) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
local p = tonumber(et.Info_ValueForKey(data, "p"))
|
||||
|
||||
return (p == 1)
|
||||
end
|
||||
|
||||
function fireteams.getName(fireteamId)
|
||||
if not fireteamId or not fireteams.isUsed(fireteamId) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
local id = tonumber(et.Info_ValueForKey(data, "id"))
|
||||
|
||||
local name
|
||||
|
||||
if id == fireteams.FT_ALPHA then
|
||||
name = "Alpha"
|
||||
elseif id == fireteams.FT_BRAVO then
|
||||
name = "Bravo"
|
||||
elseif id == fireteams.FT_CHARLIE then
|
||||
name = "Charlie"
|
||||
elseif id == fireteams.FT_DELTA then
|
||||
name = "Delta"
|
||||
elseif id == fireteams.FT_ECHO then
|
||||
name = "Echo"
|
||||
elseif id == fireteams.FT_FOXTROT then
|
||||
name = "Foxtrot"
|
||||
end
|
||||
|
||||
return name
|
||||
end
|
||||
|
||||
function fireteams.getLeader(fireteamId)
|
||||
if not fireteamId or not fireteams.isUsed(fireteamId) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
local l = tonumber(et.Info_ValueForKey(data, "l"))
|
||||
|
||||
return l
|
||||
end
|
||||
|
||||
function fireteams.getTeam(fireteamId)
|
||||
if not fireteamId or not fireteams.isUsed(fireteamId) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
local l = tonumber(et.Info_ValueForKey(data, "l"))
|
||||
local team = et.gentity_get(l, "sess.sessionTeam")
|
||||
|
||||
return team
|
||||
end
|
||||
|
||||
function fireteams.getMembers(fireteamId)
|
||||
if not fireteamId or not fireteams.isUsed(fireteamId) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
|
||||
local members = {}
|
||||
|
||||
for i = 0, 15 do
|
||||
local c = tonumber("0x0"..et.Info_ValueForKey(data, "c"):sub(16 - i, 16 - i))
|
||||
|
||||
for j = 0, 3 do
|
||||
if bits.hasbit(c, 2^j) then
|
||||
table.insert(members, (i * 4 + j))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return members
|
||||
end
|
||||
|
||||
function fireteams.getPlayerFireteamId(clientId)
|
||||
local hex = math.floor(clientId / 4)
|
||||
local bit = clientId % 4
|
||||
|
||||
for i = 0, 11 do
|
||||
local fireteamId = fireteams.getId(i)
|
||||
|
||||
if fireteams.isUsed(fireteamId) then -- please add a continue statement one day
|
||||
local data = et.trap_GetConfigstring(fireteamId)
|
||||
local c = tonumber("0x0"..et.Info_ValueForKey(data, "c"):sub(16 - hex, 16 - hex))
|
||||
|
||||
if bits.hasbit(c, 2^bit) then
|
||||
return fireteamId
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
return fireteams
|
Loading…
Reference in a new issue