Open Motd Automatically For Player

My server uses motd_menu addon and the motd no longer opens automatically when a player connects. In addition, it wont open when the F key is pressed.

Here’s what i have for sv_motd.lua:

And in motd.lua, here’s the hook:

Any idea how to get this working?

Where’s the OpenMOTDMenu function you’re trying to call?

It rather sounds like you deinstalled the addon unless you changed something. Any errors while server startup? Double check if the addon is really there

The motd does display when i use the console command. It’s just the auto display and display when F1 is pressed, where it isnt working.

There is an error on server startup though:

[ERROR] addons/motd_menu/lua/autorun/server/sv_motd.lua:3: attempt to index global 'GM' (a nil value)
  1. unknown - addons/motd_menu/lua/autorun/server/sv_motd.lua:3

Here’s the contents of both files:


-----Made by JohnnyThunders (Loures)-----

local FrameColor = Color(0, 0, 0, 0) --You can set your own frame color, remember to decrease the alpha value.
local ButtonColor = Color(0, 0, 0, 0) --You can set your own button color, remember to decrease the alpha value.

function OpenMOTDMenu()

local MenuFrame = vgui.Create("DFrame")
--MenuFrame.OPaint = MenuFrame.Paint
MenuFrame:SetSize(ScrW() * 0.95, ScrH() * 0.95)
MenuFrame:SetPos((ScrW() - MenuFrame:GetWide()) / 2, (ScrH() - MenuFrame:GetTall()) / 2)
MenuFrame:SetTitle("Welcome to " .. GetHostName())
--MenuFrame.Paint = function()
--	MenuFrame.OPaint(MenuFrame)
	surface.SetDrawColor(Color(60, 60, 60, 255))
	surface.DrawLine(1, MenuFrame:GetTall() - 27, MenuFrame:GetWide() - 1, MenuFrame:GetTall() - 27)
	draw.RoundedBox( 6, 0, 1, MenuFrame:GetWide(), MenuFrame:GetTall() + 1, FrameColor )

local CloseButton = vgui.Create("DButton", MenuFrame)
--CloseButton.OPaint = CloseButton.Paint
CloseButton:SetSize(150, 35)
CloseButton:SetPos(MenuFrame:GetWide() * 0.75, MenuFrame:GetTall() - 27 - CloseButton:GetTall()/2)
CloseButton:SetText("Ok, now let me play!")
--CloseButton.Paint = function()
--    CloseButton.OPaint(CloseButton)
--   surface.DrawRect(1, 1, CloseButton:GetWide() - 2, CloseButton:GetTall() - 2)
CloseButton.DoClick = function(button)

local MenuPSheet = vgui.Create("DPropertySheet", MenuFrame)
MenuPSheet:SetPos(13, 30)
MenuPSheet:SetSize(MenuFrame:GetWide() - 25, MenuFrame:GetTall() - 84)

local Rules = vgui.Create( "HTML", MenuFrame )
Rules:SetPos( 25, 50 )
Rules:SetSize( 250, 250 )
--Rules:SetHTML([[]]) --use this for custom html code
Rules:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

local Tips = vgui.Create( "HTML", MenuFrame )
Tips:SetPos( 25, 50 )
Tips:SetSize( 250, 250 )
Tips:SetHTML([[]]) --use this for custom html code
Tips:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

local GroupPage = vgui.Create("HTML")
GroupPage:SetPos( 25, 50 )
GroupPage:SetSize( 250, 250 )
--GroupPage:SetHTML([[]]) --use this for custom html code
GroupPage:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

local AdminList = vgui.Create( "HTML", MenuFrame )
AdminList:SetPos( 25, 50 )
AdminList:SetSize( 250, 250 )
--AdminList:SetHTML([[]]) --use this for custom html code
AdminList:OpenURL("") -- or this if you want to open an URL, remember that you must pick only one

--You can chane the popup order here, or add your own tab!

local order = {}
order[1] = {"INFO", Rules, "icon16/page.png", false, false, "Info"}
--order[2] = {"TIPS", LHelp, "icon16/award_star_gold_1.png", false, false, "Tips"}
--order[3] = {"ADMIN LIST", AdminList, "icon16/shield.png", false, false, "Admin List"}
--order[4] = {"STEAM GROUP", GroupPage, "icon16/group.png", false, false, "Group Page"}

for _, tab in pairs(order) do


concommand.Add("showmotdmenu", OpenMOTDMenu)
hook.Add( "ShowHelp", "motdmen", OpenMOTDMenu )



function GM:ShowTeam(ply) // F1
	ply:ConCommand( "showmotdmenu" )

ply:RunCommand( "showmotdmenu" )

That should work, not sure though.



function GAMEMODE:ShowTeam(ply) // F1
	ply:ConCommand( "showmotdmenu" )

should fix it

Do not override gamemode functions use hooks instead
So it should look like this instead


hook.Add("ShowTeam", "opensmotd", function(ply) 
	ply:ConCommand( "showmotdmenu" );

Awesome thanks, that fixed the F button not working. Only problem is, it still doesnt automatically display when a player loads into the game.

local function OpenMOTDAtSpawn( ply )
    if (ply:IsAdmin()) then return end
    ply:ConCommand( "showmotdmenu" )
hook.Add( "PlayerInitialSpawn", "OpenMOTDAtSpawn", OpenMOTDAtSpawn )


Most excellent!

That fixed it. YOU ARE A ROCKSTAR.