UnsubscribeAll Console Command

Hey guys so i wanted to make a script that unsubscribes to all my addons (because i often download like 400 addons and my gmod runs with 3 fps)
Everything is working alright it seems, Just i had a question is there a way to run the script when the game launch ? (i am noob with lua)
Script:


concommand.Add("UnsubscribeAll", function()
for k,v in pairs(engine.GetAddons()) do
steamworks.Unsubscribe( v.wsid )
end
steamworks.ApplyAddons()
end)



Right now to make it run on startup i make a file called UnsubscribeAll.lua on here GarrysMod\garrysmod\lua\menu and after i open menu.lua and i add include( “UnsubscribeAll.lua” ) on the last line
Like this:



include( "mount/mount.lua" )
include( "getmaps.lua" )
include( "loading.lua" )
include( "mainmenu.lua" )
include( "video.lua" )
include( "demo_to_video.lua" )

include( "menu_save.lua" )
include( "menu_demo.lua" )
include( "menu_addon.lua" )
include( "menu_dupe.lua" )
include( "errors.lua" )

include( "motionsensor.lua" )
include( "util.lua" )
include( "UnsubscribeAll.lua" )



Any ideas on how to do it with other way ?
Sorry for being that noob lol

Try putting it into lua/autorun/client(or server) then load up a map?

steamworks works only on the main menu also i want it just for the main menu

I’m just guessing but,

GM:MenuStart?

I am not an expert but i don’t think this can work how it can use the hook if even the lua file didn’t load first :frown:

Right now i am not even sure if it is possible to do it without including it on the main lua’s
Also :pudge:

I’ve never done menu state, so I really don’t know how it works, sorry.

Its nothing thank you anyways :smile:

Well if you remove the concommand part it runs immediately, that should work.

i need the concommand part

try this:

[lua]local function UnsubscribeAll()
for k,v in pairs(engine.GetAddons()) do
steamworks.Unsubscribe( v.wsid )
end
steamworks.ApplyAddons()
end

concommand.Add(“UnsubscribeAll”, UnsubscribeAll)

UnsubscribeAll()[/lua]

You guys are setting a new standard for missing the point.

No, as far as I know, there is not a way to load something in the menu state without explicitly including it in menu.lua.

IIRC there used to be a menu plugins system that was removed. This is supposed to re-add it, but also works by editing menu.lua. It might be outdated and seems like overkill TBH.

Really there’s no reason to do it in another way though?