Chat command

Hi. So I’m making a menu for my server (some have already helped me on this) and I now want to allow people to open the menu when they do “!servermenu” in chat. Can someone provide me with a ready-to-use script for it? The way I was going to open the menu was using Derma’s :MakePopup(), but would that work?

You are asking for someone to make you a script for this. Put this in requests if you don’t want to make it yourself. However, if you do plan to make it yourself, I am not a very good LUA scripter at all so the only thing I can really tell you is that I heard of something called like AddChatCommand. It might be a custom function I’m not sure. Could be a hook.

I think I can help! :3

[lua]
function sayRegister(ply, text, Team, death)
local Explode = string.Explode(" ", text)
if text == “!motd” then
//Do Something…
end
end

hook.Add(“PlayerSay”,“MOTDChatHook”,sayRegister)[/lua]

This should take care of it! Good luck!

Oh yea, I forgot there was a requests section :slight_smile: Silly me…

EDIT: AddChatCommand() is a function which is in DarkRP, so they can easily make their own chat commands…

[editline]19th October 2011[/editline]

That script looks brilliant. I will try it with my script and see how it works. Thanks!

No problem at all! I am glad I could be of assistance. :slight_smile:

Doesn’t seem to work… No idea why
EDIT: I think it’s my derma panels not working. How do you suggest I make a derma panel show from a function?

Just put the code that creates it in a function. Make sure it doesn’t already exist too.

[lua]
function ShowPanel()

if( !DermaPanel ) then

	DermaPanel = vgui.Create( "DFrame" )
	DermaPanel:SetPos( 50, 50 )
	DermaPanel:SetSize( 300, 325 )
	DermaPanel:SetTitle( "Testing Derma Stuff" )
	DermaPanel:SetVisible( true )
	DermaPanel:SetDraggable( true )
	DermaPanel:ShowCloseButton( true )
	DermaPanel:MakePopup()

end

end
[/lua]

Thanks for the script. I’ll put it into mine and see how it works :slight_smile:

It needs to be ran on init. So make sure it isn’t in a random scripts that isn’t being called. Includes are important.