LUA:Modifying F4

From Official DarkRP Wiki
Revision as of 22:15, 3 September 2013 by FPtje (talk | contribs) (Created page with "=== Add a tab to the F4 menu === {{Example | Description = Add your own tab to the F4 menu | Code = function createMyTab() local tab = vgui.Create("whatever...") -- Create ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Add a tab to the F4 menu

DescriptionAdd your own tab to the F4 menu
Code
function createMyTab()
	local tab = vgui.Create("whatever...")
	-- Create the your tab here or something
	return tab
end

hook.Add("F4MenuTabs", "addTab", function()
	-- Add the tab to F4 (will be added as fifth tab)
	-- DarkRP.addf4menutab("NAME OF TAB HERE", vguiControlOfTab, "Icon here!") returns the tab number of the added tab
	local tabNr = DarkRP.addf4menutab("My Custom tab", createMyTab(), "icon16/money.png")


	-- I want it to be before the HUD tab (which is the fourth tab)
	-- DarkRP.switchtaborder(TabNumberOfFirstTab, TabNumberOfSecondTab)
	DarkRP.switchtaborder(tabNr, 4)
end)
OutputYour tab is added to the F4 menu

Remove a tab from F4

DescriptionRemove the HUD tab
Code
hook.Add("F4MenuTabs", "removeTab", function()
	-- the HUD tab is the fourth one
	-- removef4menutab(TabNumber)
	removef4menutab(4)
end)
OutputHUD tab is gone.