diff --git a/lua/autorun/badmin_init.lua b/lua/autorun/badmin_init.lua index f27e2cf..1e795b8 100644 --- a/lua/autorun/badmin_init.lua +++ b/lua/autorun/badmin_init.lua @@ -164,27 +164,6 @@ if SERVER then end local Load = BAdmin.Utilities.loadFile - -- Core folder will always load first, afterwards anything in "lua/badmin/addon" will be loaded, order depending on operating system - - MsgN("+ Loading core files...") - Load("badmin/core") - - BAdmin.Utilities.cullBanList() - - -- Load our own commands first - MsgN("+ Adding core commands...") - Load("badmin/corecommands") - - -- Load any command files that the current gamemode might have, if they opt to write any - MsgN("+ Adding gamemode commands...") - Load(engine.ActiveGamemode() .. "/badmin/addon") - - -- Load any command files that another addon might have - MsgN("+ Adding addon commands...") - Load("badmin/addon") - - MsgN("+ Finished adding commands!") - ---------------------------------------------------------------------------------------------------------------- -- autocomplete networking ---------------------------------------------------------------------------------------------------------------- @@ -212,8 +191,13 @@ if SERVER then BAdmin.Autocomplete.CMDData[k] = Data end end + BAdmin.Autocomplete.build() + timer.Simple(0.5,function() + BAdmin.Autocomplete.broadcast() + end) + -- Broadcasts autocomplete data to all of the players function BAdmin.Autocomplete.broadcast() net.Start("BAdmin.commandList") @@ -230,10 +214,6 @@ if SERVER then net.Send(ply) end - timer.Simple(0.5,function() - BAdmin.Autocomplete.broadcast() - end) - net.Receive("BAdmin.requestCommands",function(_,ply) -- also the first breathing moment the player can do anything BAdmin.Utilities.initialRank(ply) @@ -273,6 +253,47 @@ if SERVER then BAdmin.Utilities.initialRank(ply) end) + -- Core folder will always load first, afterwards anything in "lua/badmin/addon" will be loaded, order depending on operating system + + local function LoadBM() + MsgN("+ Loading core files...") + Load("badmin/core") + + BAdmin.Utilities.cullBanList() + + -- Load our own commands first + MsgN("+ Adding core commands...") + Load("badmin/corecommands") + + -- Load any command files that the current gamemode might have, if they opt to write any + MsgN("+ Adding gamemode commands...") + Load(engine.ActiveGamemode() .. "/badmin/addon") + + -- Load any command files that another addon might have + MsgN("+ Adding addon commands...") + Load("badmin/addon") + + MsgN("+ Finished adding commands!") + + BAdmin.Autocomplete.build() + + timer.Simple(0.5,function() + BAdmin.Autocomplete.broadcast() + end) + end + + hook.Add("PostGamemodeLoaded", "BAdmin.PostGamemodeLoad", function() + LoadBM() + + BAdmin.Initialized = true + + hook.Remove("PostGamemodeLoaded", "BAdmin.PostGamemodeLoad") + end) + + if BAdmin.Initialized then + LoadBM() + end + MsgN("Finished loading BAdmin!") MsgN("+-----------END BADMIN-----------+") elseif CLIENT then -------------------------------------------------------- diff --git a/lua/badmin/core/commands.lua b/lua/badmin/core/commands.lua index 4449d90..27701e5 100644 --- a/lua/badmin/core/commands.lua +++ b/lua/badmin/core/commands.lua @@ -3,6 +3,17 @@ local BAdmin = BAdmin MsgN("+ Loading command system...") +--[[ + + When a command is being added, a hook will also be run before anything is truly added + + BAdmin.AddCommand + Args: Command name (string), Settings (table) + + Return: Disable (boolean), Override (boolean), NewSettings (table) + +]] + --[[ Variables for the commands MinimumPrivilege | 0 - User (anyone, also is default if this is left out), 1 - Admin, 2 - Superadmin, 3 - RCON or Host of localhost server CanTargetEqual | Whether the player can target an equally ranked person @@ -37,13 +48,25 @@ MsgN("+ Loading command system...") } -- This calls the built-in function to create the command, where it can be seen with autocomplete and usable by the approriate players - BAdmin.Utilities.addCommand("kick",callfunc,cmdSettings) + BAdmin.Utilities.addCommand( + "kick", -- The command string itself + callfunc, -- The function defined above + cmdSettings, -- The settings defined above + false -- Special boolean for ignoring the hook.Run check, leave false except for extremely special commands (like the force reload ones) + ) ]] -function BAdmin.Utilities.addCommand(cmdString,func,settings) +function BAdmin.Utilities.addCommand(cmdString, func, settings, forceDefine) local CMDData = {} + if not forceDefine then + local Disable, Override, NewSettings = hook.Run("BAdmin.AddCommand", cmdString, settings) + + if Disable then MsgN("X Blocked " .. cmdString) return end + if Override then MsgN("V Overridden settings for " .. cmdString) table.Merge(settings, NewSettings, false) end + end + table.Merge(CMDData,settings) CMDData["func"] = func @@ -128,7 +151,7 @@ cmdSettings = { } -- This calls the built-in function to create the command, where it can be seen with autocomplete and usable by the approriate players -BAdmin.Utilities.addCommand("@@ba_reload",callfunc,cmdSettings) +BAdmin.Utilities.addCommand("@@ba_reload", callfunc, cmdSettings, true) --- Individual reload list @@ -148,7 +171,7 @@ cmdSettings = { ["MinimumPrivilege"] = 2, ["RCONCanUse"] = true } -BAdmin.Utilities.addCommand("@@ba_indreloadlist",callfunc,cmdSettings) +BAdmin.Utilities.addCommand("@@ba_indreloadlist", callfunc, cmdSettings, true) --- Individual reload command @@ -171,4 +194,4 @@ cmdSettings = { ["MinimumPrivilege"] = 2, ["RCONCanUse"] = true } -BAdmin.Utilities.addCommand("@@ba_indreload",callfunc,cmdSettings) \ No newline at end of file +BAdmin.Utilities.addCommand("@@ba_indreload", callfunc, cmdSettings, true) \ No newline at end of file diff --git a/lua/badmin/corecommands/plymgmt.lua b/lua/badmin/corecommands/plymgmt.lua index 401de44..56a6076 100644 --- a/lua/badmin/corecommands/plymgmt.lua +++ b/lua/badmin/corecommands/plymgmt.lua @@ -174,12 +174,29 @@ function callfunc(ply,args) -- Freezing the whole map return true end cmdSettings = { - ["Help"] = "Freezes the entire map in props.", + ["Help"] = "Freezes all of the props across the map.", ["MinimumPrivilege"] = 2, ["RCONCanUse"] = true } BAdmin.Utilities.addCommand("freezemap",callfunc,cmdSettings) +-- Toggle physics + +function callfunc(ply,args) -- Freezing the whole map + + physenv.SetPhysicsPaused(not physenv.GetPhysicsPaused()) + + BAdmin.Utilities.broadcastPrint({Color(255,127,127),BAdmin.Utilities.checkName(ply),Color(200,200,200)," just toggled the physics simulation!"}) + + return true +end +cmdSettings = { + ["Help"] = "Toggles physics sim for the whole server.", + ["MinimumPrivilege"] = 2, + ["RCONCanUse"] = true +} +BAdmin.Utilities.addCommand("togglephysics",callfunc,cmdSettings) + --======== Set Jail Position function callfunc(ply,args) -- Jail position