Fixed Server using commands Bug

This commit is contained in:
Cooldude2606
2019-03-16 18:11:37 +00:00
parent cfaa80d153
commit 89b9d8e164
5 changed files with 23 additions and 13 deletions

View File

@@ -14,6 +14,7 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
:add_param('page',true,'integer') -- the keyword that will be looked for
:add_defaults{keyword='',page=1}
:register(function(player,keyword,page,raw)
local player_index = player and player.index or 0
-- if keyword is a number then treat it as page number
if tonumber(keyword) then
page = math.floor(tonumber(keyword))
@@ -22,9 +23,9 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
-- gets a value for pages, might have result in cache
local pages
local found = 0
if search_cache[player.index] and search_cache[player.index].keyword == keyword:lower() then
pages = search_cache[player.index].pages
found = search_cache[player.index].found
if search_cache[player_index] and search_cache[player_index].keyword == keyword:lower() then
pages = search_cache[player_index].pages
found = search_cache[player_index].found
else
pages = {{}}
local current_page = 1
@@ -51,7 +52,7 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
})
end
-- adds the result to the cache
search_cache[player.index] = {
search_cache[player_index] = {
keyword=keyword:lower(),
pages=pages,
found=found