• Removing tabs from the q menu adding a tab
    21 replies, posted
So recently i got on a kick to remove all visual menus that are unusable on my server (npc spawning, vehicles, dupe, save) it was not TOO hard to do but i figured others could benefit from the little snippet of code. The bottom of the code adds another tab for "rules" that opens a webpage (you can not input text into this area for whatever reason [lua] newtabaddress = "http://piebald-gaming.com/rules.html" newtabname = "Rules" newtabicon = "icon16/control_repeat_blue.png" local function removeOldTabls() for k, v in pairs( g_SpawnMenu.CreateMenu.Items ) do if (v.Tab:GetText() == language.GetPhrase("spawnmenu.category.npcs") or v.Tab:GetText() == language.GetPhrase("spawnmenu.category.entities") or v.Tab:GetText() == language.GetPhrase("spawnmenu.category.weapons") or v.Tab:GetText() == language.GetPhrase("spawnmenu.category.vehicles") or v.Tab:GetText() == language.GetPhrase("spawnmenu.category.postprocess") or v.Tab:GetText() == language.GetPhrase("spawnmenu.category.dupes") or v.Tab:GetText() == language.GetPhrase("spawnmenu.category.saves")) then g_SpawnMenu.CreateMenu:CloseTab( v.Tab, true ) removeOldTabls() end end end hook.Add("SpawnMenuOpen", "blockmenutabs", removeOldTabls) spawnmenu.AddCreationTab( newtabname , function() HTML = vgui.Create( "HTML" ) HTML:OpenURL( newtabaddress ) HTML:SetMouseInputEnabled(true) local DPanel = vgui.Create( "DPanel", HTML ) local DButton = vgui.Create( "DButton", DPanel ) DButton:SetText( "Back To Rules" ) DButton:SizeToContents() DButton:SetTall(DPanel:GetTall()) DButton:SetDark( 1 ) DButton.DoClick = function() HTML:OpenURL( newtabaddress ) end return HTML , DPanel end, newtabicon, 200 ) [/lua] Feel free to use this however you want, remove any of the "spawnmenu.category.*" lines that you do not want to remove (this is all tabs except for the spawn menu) change newtabaddress to any website you want or just remove everything after [code]hook.Add("SpawnMenuOpen", "blockmenutabs", removeOldTabls) [/code] to not have the extra tab Edit There is a single moment of lag when you first open the menu but i believe my computer does that even with all the tabs
Hi How do I remove a tab spawnlists
if you are talking about the regular spawn list by removing that you render the q menu useless basically but likely just add a line with spawnmenu.category.spawnlist (at work so i dont know the name used for it in the language files)
[QUOTE=kulcris;48583248]if you are talking about the regular spawn list by removing that you render the q menu useless basically but likely just add a line with spawnmenu.category.spawnlist (at work so i dont know the name used for it in the language files)[/QUOTE] i believe the correct name is "spawnmenu.content_tab" removing all tabs will make the menu spit out a lua error when attempting to open it for the first time after running the script [t]http://i.imgur.com/5f4JeiC.png[/t] the spawnmenu is at that point not shown, until the button to call it is pressed again. [t]http://i.imgur.com/ZcHgrWS.jpg[/t] when attempting to open the spawnmenu after the error message occurs, it does open, but with the regular prop spawnlists intact, and with the tabs at the top of the menu appearing broken.
lol figured it would screw something up didnt realize it would try to go crazy XD, so not recommended to remove all the tabs from the spawnmenu what does it do if you remove all but one tab that is not the content_tab [editline]31st August 2015[/editline] btw this should be ran on the client only
You could just put all of those tabs into a table rather than having tons of or statements.
[QUOTE=xbeastguyx;48592436]You could just put all of those tabs into a table rather than having tons of or statements.[/QUOTE] lol yes i could, might do that sometime today if i get time
i may be COMPLETELY wrong on this as i am not to great with tables but i think this will do the same thing while adding the tabs to check for into a table [lua] local function removeOldTabls() local tabstoremove = {language.GetPhrase("spawnmenu.category.npcs"), language.GetPhrase("spawnmenu.category.entities"), language.GetPhrase("spawnmenu.category.weapons"), language.GetPhrase("spawnmenu.category.vehicles"), language.GetPhrase("spawnmenu.category.postprocess"), language.GetPhrase("spawnmenu.category.dupes"), language.GetPhrase("spawnmenu.category.saves")} for k, v in pairs( g_SpawnMenu.CreateMenu.Items ) do if table.HasValue(tabstoremove, v.Tab:GetText()) then g_SpawnMenu.CreateMenu:CloseTab( v.Tab, true ) removeOldTabls() end end end hook.Add("SpawnMenuOpen", "blockmenutabs", removeOldTabls)[/lua] If someone would test this and let me know i would be greatful (video card fried so cant test on gmod lol) and if this does work i dont think i need removeOldTabls() anymore either
[QUOTE=kulcris;48600510] [lua] local function removeOldTabls() local tabstoremove = {language.GetPhrase("spawnmenu.category.npcs"), language.GetPhrase("spawnmenu.category.entities"), language.GetPhrase("spawnmenu.category.weapons"), language.GetPhrase("spawnmenu.category.vehicles"), language.GetPhrase("spawnmenu.category.postprocess"), language.GetPhrase("spawnmenu.category.dupes"), language.GetPhrase("spawnmenu.category.saves")} for k, v in pairs( g_SpawnMenu.CreateMenu.Items ) do if table.HasValue(tabstoremove, v.Tab:GetText()) then g_SpawnMenu.CreateMenu:CloseTab( v.Tab, true ) removeOldTabls() end end end hook.Add("SpawnMenuOpen", "blockmenutabs", removeOldTabls)[/lua][/QUOTE] this code works just as well as the original code.
awesome :D thanks can you try it without the removeOldTabls() after g_SpawnMenu.CreateMenu:CloseTab( v.Tab, true ) I think the table will remove it in order instead of having to go back through the table multiple times
I was thinking of simplifying, not just putting all of it into a table. However, it still works and that's what matters :P
How do I make it like only admins can access them ?
Could you help us with an example of a custom tab that ? maybe one like flood ??? xD? One that could probably remove money for a prop being spawned <3
[lua]local function removeOldTabls() local tabstoremove = {language.GetPhrase("spawnmenu.category.npcs"), language.GetPhrase("spawnmenu.category.entities"), language.GetPhrase("spawnmenu.category.weapons"), language.GetPhrase("spawnmenu.category.vehicles"), language.GetPhrase("spawnmenu.category.postprocess"), language.GetPhrase("spawnmenu.category.dupes"), language.GetPhrase("spawnmenu.category.saves")} if !LocalPlayer():IsAdmin() then for k, v in pairs( g_SpawnMenu.CreateMenu.Items ) do if table.HasValue(tabstoremove, v.Tab:GetText()) then g_SpawnMenu.CreateMenu:CloseTab( v.Tab, true ) removeOldTabls() end end end end hook.Add("SpawnMenuOpen", "blockmenutabs", removeOldTabls)[/lua] for admins and up only being able to SEE all tabs [editline]28th October 2015[/editline] the original post shows how to add tabs.
[QUOTE=kulcris;49003670][lua]local function removeOldTabls() local tabstoremove = {language.GetPhrase("spawnmenu.category.npcs"), language.GetPhrase("spawnmenu.category.entities"), language.GetPhrase("spawnmenu.category.weapons"), language.GetPhrase("spawnmenu.category.vehicles"), language.GetPhrase("spawnmenu.category.postprocess"), language.GetPhrase("spawnmenu.category.dupes"), language.GetPhrase("spawnmenu.category.saves")} if !LocalPlayer():IsAdmin() then for k, v in pairs( g_SpawnMenu.CreateMenu.Items ) do if table.HasValue(tabstoremove, v.Tab:GetText()) then g_SpawnMenu.CreateMenu:CloseTab( v.Tab, true ) removeOldTabls() end end end end hook.Add("SpawnMenuOpen", "blockmenutabs", removeOldTabls)[/lua] for admins and up only being able to SEE all tabs [editline]28th October 2015[/editline] the original post shows how to add tabs.[/QUOTE] How would you add a way to charge money per item spawned. Not Darkrp. And how can I blacklist some props? [editline]29th October 2015[/editline] Once again not darkrp
What ?! You mean charge DarkRP money or your own 'money system' ?
No idea :P and not going to build a system to do that. but you might look into [url]http://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnedProp[/url]
where should i put it?
Hello Can you me say who i found this and can edit this?! For Tab i mean
lua/autorun/client
Thanks for this. Would it also be possible to hide certain tools from the menu too?
Hello! How can I create tab with special weapons?
Sorry, you need to Log In to post a reply to this thread.