From 2ab252629a2c8b672c018e75b4ba730feff62b52 Mon Sep 17 00:00:00 2001 From: Linventif Date: Fri, 9 Aug 2024 17:33:41 +0000 Subject: [PATCH] refactor: gmi_test_error to admin only --- lua/gmod_integration/shared/sh_con.lua | 21 +++++++++++++++++++++ lua/gmod_integration/shared/sh_main.lua | 21 +-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 lua/gmod_integration/shared/sh_con.lua diff --git a/lua/gmod_integration/shared/sh_con.lua b/lua/gmod_integration/shared/sh_con.lua new file mode 100644 index 0000000..d3a347d --- /dev/null +++ b/lua/gmod_integration/shared/sh_con.lua @@ -0,0 +1,21 @@ +concommand.Add("gmi_test_error", function(ply, cmd, args) + if !SERVER && !LocalPlayer():gmIntIsAdmin() then + print("[Gmod Integration] Missing permissions to run this command") + return + end + + if #args == 0 then + error("This is a test error") + else + if args[1] == "loop" then + hook.Add("Think", "gmInte:TestError:Loop", function() error("This is a test error") end) + timer.Simple(5, function() hook.Remove("Think", "gmInte:TestError:Loop") end) + elseif args[1] == "crash" then + while true do + error("This is a crash error") + end + else + error("This is a test error") + end + end +end) \ No newline at end of file diff --git a/lua/gmod_integration/shared/sh_main.lua b/lua/gmod_integration/shared/sh_main.lua index a81719a..ca9c137 100644 --- a/lua/gmod_integration/shared/sh_main.lua +++ b/lua/gmod_integration/shared/sh_main.lua @@ -32,23 +32,4 @@ function gmInte.isPrivateIP(ip) if parts[1] == "172" && tonumber(parts[2]) >= 16 && tonumber(parts[2]) <= 31 then return true end if parts[1] == "127" then return true end return false -end - -concommand.Add("gmi_test_error", function(ply, cmd, args) - print(ply, cmd) - PrintTable(args) - if #args == 0 then - error("This is a test error") - else - if args[1] == "loop" then - hook.Add("Think", "gmInte:TestError:Loop", function() error("This is a test error") end) - timer.Simple(5, function() hook.Remove("Think", "gmInte:TestError:Loop") end) - elseif args[1] == "crash" then - while true do - error("This is a crash error") - end - else - error("This is a test error") - end - end -end) \ No newline at end of file +end \ No newline at end of file