From 11ad16fb3988b555aba923887eda955b442bd50c Mon Sep 17 00:00:00 2001 From: edshot99 Date: Sat, 11 Jan 2025 11:00:37 -0600 Subject: [PATCH] add !bot and !Kickbots --- .../lua/ulx/modules/sh/noob_bots.lua | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ulx_noob_extras/lua/ulx/modules/sh/noob_bots.lua diff --git a/ulx_noob_extras/lua/ulx/modules/sh/noob_bots.lua b/ulx_noob_extras/lua/ulx/modules/sh/noob_bots.lua new file mode 100644 index 0000000..8f22b0a --- /dev/null +++ b/ulx_noob_extras/lua/ulx/modules/sh/noob_bots.lua @@ -0,0 +1,35 @@ + +-- from: ulx-custom-commands/lua/ulx/modules/sh/cc_util.lua + +function ulx.bot(calling_ply, number, bKick) + if (bKick) then + for _, v in ipairs(player.GetBots()) do + if (v:IsBot()) then -- Just to be sure they are bots + v:Kick("") + end + end + ulx.fancyLogAdmin(calling_ply, "#A kicked all bots from the server") + elseif (!bKick) then + if (tonumber(number) == 0) then + for i = 1, 6 do -- Only add 6 to prevent a overflow. + RunConsoleCommand("bot") + end + ulx.fancyLogAdmin(calling_ply, "#A spawned a few bots") + elseif (tonumber(number) != 0) then + for i = 1, number do + RunConsoleCommand("bot") + end + if (number == 1) then + ulx.fancyLogAdmin(calling_ply, "#A spawned #i bot", number) + elseif (number > 1) then + ulx.fancyLogAdmin(calling_ply, "#A spawned #i bots", number) + end + end + end +end +local bot = ulx.command("Utility", "ulx bot", ulx.bot, "!bot") +bot:addParam{type = ULib.cmds.NumArg, default = 0, hint = "number", ULib.cmds.optional} +bot:addParam{type = ULib.cmds.BoolArg, invisible = true} +bot:defaultAccess(ULib.ACCESS_ADMIN) +bot:help("Spawn or remove bots.") +bot:setOpposite("ulx kickbots", {_, _, true}, "!kickbots")