About the F4

Im new to all this coding and such, but i was wondering. How do i add a button to the f4 menu and make it do a command?

I want to add a button that says “Get an Admin”

and when the player clicks it, it sends a message to all staff members saying “insert players name needs an admin!”

Thank you!

Just find where darkrp’s menu is and add this button their:
[LUA]local button = vgui.Create(“DButton”)
button:SetParent( ENTERTHEPARENT)
button:SetPos(270, 35)
button:SetFont(“default”)
button:SetText(“Get an Admin!”)
button:SetSize(110, 25)
button.DoClick = function()
RunConsoleCommand(“call”, LocalPlayer()) end[/LUA]
but we still need the call command so here is what we would do for that;
[LUA]function call(who)
for _,v in pairs(player.GetAll()) do
if v:IsAdmin() or v:IsSuperAdmin() then
v:ChatPrint(who:Nick()…" needs an admin!")
end
end
end
concommand.Add(“call”, call)[/LUA]
Keep in mind this is untested, if something goes wrong with it report back.

Going to try it now, thanks!

[editline]19th July 2013[/editline]

I get this

http://puu.sh/3GXXr.png

Try copy and pasting the code, instead of typing it out manually and misspelling it. (Check line 132)

Hmm, I see why that would be an error because it says conccomand but I can’t find it in the code I told you. Can you post line 132 for me?

-snip-

Just copy and paste the code he gave you, when you were manually re-typing it you misspelled concommand.

I realize that I pretty much said exactly what Lixquid did.

Alright, my F4 menu works, but the button is not in the menu, its at the top of my screen (to the people who told me about the spelling error, that was the problem)

Now, i need the button to stay on the menu :slight_smile:

[LUA]local button = vgui.Create(“DButton”)
button:SetParent( ENTERTHEPARENT)
button:SetPos(270, 35)
button:SetFont(“default”)
button:SetText(“Get an Admin!”)
button:SetSize(110, 25)
button.DoClick = function()
RunConsoleCommand(“call”, LocalPlayer()) end[/LUA]
This is the button you’re gonna need to set the parent and the position. If you need help with this just ask i’ll download darkrp and show you how :wink:

Yeah im completely new to this stuff, and i feel really stupid that i cant do this lol. Can you please show me?

Hey no problem, and I didn’t notice this before but darkrp has their own table for adding stuff so just find this inside showteamtabs.lua at line 293 that should be right under
[LUA]rpnameTextbox.OnEnter = function() RunConsoleCommand(“darkrp”, “/rpname”, tostring(rpnameTextbox:GetValue())) end[/LUA]
and add this
[LUA] local button = ActionsPanel:Add(“DButton”)
button:SetParent( Commands)
button:SetFont(“default”)
button:SetText(“Get an Admin!”)
button.DoClick = function()
RunConsoleCommand(“call”, LocalPlayer()) end[/LUA]

So do i add this [LUA] local button = ActionsPanel:Add(“DButton”)

button:SetParent( Commands)
button:SetFont("default")
button:SetText("Get an Admin!")
button.DoClick = function()
	RunConsoleCommand("call", LocalPlayer()) end[/LUA]

Below this [LUA]rpnameTextbox.OnEnter = function() RunConsoleCommand(“darkrp”, “/rpname”, tostring(rpnameTextbox:GetValue())) end[/LUA]

You got it.

http://puu.sh/3H49M.png

Thank you so much XD

No problem pal, if you need anymore help feel free to make another forum post just like this one! Have a nice day :wink:

May i add you on steam by any chance? So its easier to communicate.

Yes sir, my steam name is Loki611.

Alright i sent it, thank you.