From 449e6c856f83fbfbf0779b9ed49a209146c6d03c Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Sat, 21 Jan 2017 14:29:29 +0100 Subject: [PATCH] Fixed minor issues on several commands * gib now by correct attacker (world entity) * listlevels should not read shrubbot in standalone mode --- luamods/wolfadmin/commands/admin/gib.lua | 4 +- .../wolfadmin/commands/admin/listlevels.lua | 62 ++++++++++--------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/luamods/wolfadmin/commands/admin/gib.lua b/luamods/wolfadmin/commands/admin/gib.lua index df12746..e54a8cf 100644 --- a/luamods/wolfadmin/commands/admin/gib.lua +++ b/luamods/wolfadmin/commands/admin/gib.lua @@ -55,9 +55,9 @@ function commandGib(clientId, cmdArguments) end -- GENTITYNUM_BITS 10 10 - -- MAX_GENTITIES 1 << GENTITYNUM_BITS 20 + -- MAX_GENTITIES 1 << GENTITYNUM_BITS 1024 -- ENTITYNUM_WORLD MAX_GENTITIES - 2 18 - et.G_Damage(cmdClient, 18, 18, 500, 0, 0) -- MOD_UNKNOWN = 0 + et.G_Damage(cmdClient, 0, 1024, 500, 0, 0) -- MOD_UNKNOWN = 0 et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dgib: ^7"..players.getName(cmdClient).." ^9was gibbed.\";") diff --git a/luamods/wolfadmin/commands/admin/listlevels.lua b/luamods/wolfadmin/commands/admin/listlevels.lua index 718b98e..a0ac2f2 100644 --- a/luamods/wolfadmin/commands/admin/listlevels.lua +++ b/luamods/wolfadmin/commands/admin/listlevels.lua @@ -29,35 +29,41 @@ local util = require (wolfa_getLuaPath()..".util.util") function commandListLevels(clientId, cmdArguments) if cmdArguments[1] == nil then - local fileName = et.trap_Cvar_Get("g_shrubbot") - local functionStart = et.trap_Milliseconds() - local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ) - local levelsCount = 0 - - if fileLength == -1 then - et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9an error happened (shrubbot file could not be opened)\";") - - error("failed to open "..fileName.."\n") + if settings.get("g_standalone") ~= 0 then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels usage: "..commands.getadmin("listlevels")["syntax"].."\";") + + return true + else + local fileName = et.trap_Cvar_Get("g_shrubbot") + local functionStart = et.trap_Milliseconds() + local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ) + local levelsCount = 0 + + if fileLength == -1 then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9an error happened (shrubbot file could not be opened)\";") + + error("failed to open "..fileName.."\n") + end + + local fileString = et.trap_FS_Read(fileDescriptor, fileLength) + + et.trap_FS_FCloseFile(fileDescriptor) + + for entry, levelNr, levelName, levelFlags in string.gmatch(fileString, "(%[level%]\nlevel%s+=%s+(-?[0-9]+)\nname%s+=%s+([%a%d%p ]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do + -- et.G_Print(string.format("%d %s %s\n", levelNr, levelName, levelFlags)) + + local numberOfSpaces = 24 - string.len(util.removeColors(levelName)) + local spaces = string.rep(" ", numberOfSpaces) + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^7"..string.format("%5s", levelNr).." ^7"..spaces..levelName.." ^7"..levelFlags.."\";") + + levelsCount = levelsCount + 1 + end + + et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistlevels: ^9"..levelsCount.." available levels (open console for the full list)\";") + + return true end - - local fileString = et.trap_FS_Read(fileDescriptor, fileLength) - - et.trap_FS_FCloseFile(fileDescriptor) - - for entry, levelNr, levelName, levelFlags in string.gmatch(fileString, "(%[level%]\nlevel%s+=%s+(-?[0-9]+)\nname%s+=%s+([%a%d%p ]+)\nflags%s+=%s+([%a%d%p]*)\n\n)") do - -- et.G_Print(string.format("%d %s %s\n", levelNr, levelName, levelFlags)) - - local numberOfSpaces = 24 - string.len(util.removeColors(levelName)) - local spaces = string.rep(" ", numberOfSpaces) - - et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^7"..string.format("%5s", levelNr).." ^7"..spaces..levelName.." ^7"..levelFlags.."\";") - - levelsCount = levelsCount + 1 - end - - et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dlistlevels: ^9"..levelsCount.." available levels (open console for the full list)\";") - - return true elseif not db.isconnected() then et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistlevels: ^9level history is disabled.\";")