add !bot and !Kickbots

This commit is contained in:
edshot99 2025-01-11 11:00:37 -06:00
parent 494ea4c5c4
commit 11ad16fb39

View File

@ -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")