From 9b6f8b60ccbfc484f4d5639c93a11bd16b7f2b59 Mon Sep 17 00:00:00 2001 From: grilledham Date: Mon, 7 May 2018 13:16:41 +0100 Subject: [PATCH] custom commands use pcall --- custom_commands.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/custom_commands.lua b/custom_commands.lua index 2c184f8e..1357b94b 100644 --- a/custom_commands.lua +++ b/custom_commands.lua @@ -458,6 +458,17 @@ local function reactor_toggle() end end end + +local old_add_command = commands.add_command +commands.add_command = function(name, desc, func) + old_add_command(name, desc, function(cmd) + local success, error = pcall(func, cmd) + if not suc then + log(err) + end + end) +end + commands.add_command("kill", "Will kill you.", kill) commands.add_command("tpplayer", " - Teleports you to the player. (Admins and moderators)", teleport_player) commands.add_command("invoke", " - Teleports the player to you. (Admins and moderators)", invoke)