Need help please

So im trying to make a redirect for my server using derna. I was wondering how would make a chat command run the console command to pull up the menu. Any help on this would be greatly appreciated thanks in advanced!


local function Say( ply, text, toall )
local GM = gmod.GetGamemode()
	if string.sub(text, 1, 14) == "/mychatcommand" then
                ply:ConCommand(  "mycommand" )
        end
end
hook.Add( "PlayerSay", "Say", Say )


Untested.

awesome i will give this a shot later when I got time tyvm

Sorry im not a coder at all but Ive been working on this for over an hour and i still cant get it to work. Ive tried functions GM:OnPlayerSay and GM:OnPlayerChat and also GAMEMODE for each. And I don’t know if it makes a difference but i tried to make it its own function instead of doing it locally or w/e. When i use these functions I get this error in my console: attempt to index global ‘GM’ (a nil value)

Thanks for giving it a shot |Bob Dole| I appreciate it. If someone could help me out I would love you long time :slight_smile:

I doubt you want to override the gamemode functions. Use hooks.

[lua]
hook.Add(“PlayerSay”, “ChatCommand”, function(pl, text, _)
if text == “some chat command” then
pl:ConCommand(“some concommand to open your menu”)
end
end)
[/lua](Untested and written in browser, but should work.)

tried it out and no luck, I must be doing something wrong with hooks because I cant get the VGUI to pop up when you hit F4 and that seems pretty straight forward. Im not sure whats going on here but can some1 take a look at this code and help me fix it up. And please don’t lul to hard im shocked/proud I made it this far with the redirect VGUI :stuck_out_tongue: thanks again for any input you can contribute!

[lua]
–garrysmod/lua/autorun/client/redirect.lua
–redirect vgui
–Swifty

–derma poop
function redirect()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( “KBz Redirect” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel )s
DermaButton:SetText( “TTT Server” )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
LocalPlayer():ConCommand(“connect 208.64.39.51:27015”)
end
local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( “MiniGames Server” )
DermaButton:SetPos( 25, 110 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
LocalPlayer():ConCommand(“connect 208.64.39.51:27035”)
end
local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( “DeathRun Server” )
DermaButton:SetPos( 25, 170 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
LocalPlayer():ConCommand(“connect 208.64.39.51:27055”)
end
end

concommand.Add(“redirect”, redirect)

usermessage.Hook( “redirect”, redirect )

–binding VGUI to F4
function redirect( ply )
umsg.Start( “redirect”, ply )
umsg.End()
end
hook.Add(“ShowSpare2”, “redirect”, redirect)

–chat command
hook.Add(“PlayerSay”, “ChatCommand”, function(pl, text, _)
if text == “!servers” then
pl:ConCommand(“redirect”)
end
end)
[/lua]

PlayerSay is serverside. You need to run that code I gave you in a server side file. lua/autorun/server/chatcommand.lua for example.

Woops! Sorry Swftone I forgot to say that mine was serverside.

Its cool man its something i should have known but im a noob :stuck_out_tongue: but everything works now including the hook for the showspare2. Thanks for the help everyone I really appreciate it!