Skip to content

Commit

Permalink
Fixed minor issues on several commands
Browse files Browse the repository at this point in the history
* gib now by correct attacker (world entity)
* listlevels should not read shrubbot in standalone mode
  • Loading branch information
Timo Smit committed Jan 21, 2017
1 parent 839036e commit 449e6c8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
4 changes: 2 additions & 2 deletions luamods/wolfadmin/commands/admin/gib.lua
Expand Up @@ -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.\";")

Expand Down
62 changes: 34 additions & 28 deletions luamods/wolfadmin/commands/admin/listlevels.lua
Expand Up @@ -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")
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
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

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.\";")

Expand Down

0 comments on commit 449e6c8

Please sign in to comment.