From 9335e7a9abc0308085fe1813624d3f79eb2b919a Mon Sep 17 00:00:00 2001 From: Valansch Date: Sun, 30 Jul 2017 23:08:44 +0200 Subject: [PATCH] fixed /tag crash --- custom_commands.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/custom_commands.lua b/custom_commands.lua index 1e7eaa6f..2ca843de 100644 --- a/custom_commands.lua +++ b/custom_commands.lua @@ -269,15 +269,19 @@ local function tag(cmd) cant_run(cmd.name) return end - local params = {} - for param in string.gmatch(cmd.parameter, "%w+") do table.insert(params, param) end - if #params ~= 2 then - game.player.print("Two arguments expect failed. Usage: Sets a players tag.") - elseif game.players[params[1]] == nil then - game.player.print("Player does not exist.") + if cmd.parameter ~= nil then + local params = {} + for param in string.gmatch(cmd.parameter, "%w+") do table.insert(params, param) end + if #params ~= 2 then + game.player.print("Two arguments expect failed. Usage: Sets a players tag.") + elseif game.players[params[1]] == nil then + game.player.print("Player does not exist.") + else + game.players[params[1]].tag = "[" .. params[2] .. "]" + game.print(params[1] .. " joined [" .. params[2] .. "].") + end else - game.players[params[1]].tag = "[" .. params[2] .. "]" - game.print(params[1] .. " joined [" .. params[2] .. "].") + game.player.print('Usage: /tag Sets a players tag.') end end @@ -286,7 +290,7 @@ local function follow(cmd) global.follows[game.player.name] = cmd.parameter global.follows.n_entries = global.follows.n_entries + 1 else - game.player.print(" makes you follow the player. Use /unfollow to stop following a player.") + game.player.print("Usage: /follow makes you follow the player. Use /unfollow to stop following a player.") end end