Motd

Hello,
i wanted to make a Motd with a Html content and two Buttons,one
(Denie) will kick Client and the second (Accept)will be only clickable after lets say 5 seconds. I searched in garrysmod.org and found one ,but only for Assmod =(. Than i found one not really that what i need but i started editing it, this is what comes out.
cl_client.lua

[Lua]
– Draw the menu derrr :stuck_out_tongue:

local MOTD = {};

function MotdOpen()
if MOTD.Window then MOTD.Window:SetVisible(true) return end
MOTD.Window = vgui.Create(“DFrame”)
MOTD.Window:SetSize( ScrW()*0.9, ScrH()*0.9 )
MOTD.Window:Center()
MOTD.Window:SetTitle( “Rambos Spielplatz” )
MOTD.Window:SetVisible( true )
MOTD.Window:MakePopup()

timer.Create( "timer", 1, 0, function()
MOTD.FakeButton3:SetText( "Wait (4s)" )
end
timer.Adjust("timer", 1, 0, function()
MOTD.FakeButton3:SetText( "Wait (3s)" )
end
timer.Adjust("timer", 1, 0, function()
MOTD.FakeButton3:SetText( "Wait (2s)" )
end
timer.Adjust("timer", 1, 0, function()
MOTD.FakeButton3:SetText( "Wait (1s)" )
end
timer.Adjust("timer", 1, 0, function()
MOTD.FakeButton3:SetText( "Accept!" )
end
timer.Destroy("timer")
function FakeButton3:DoClick( ) //This is called when the button is clicked
    MOTD.Window:SetVisible(false) //lolz
end

MOTD.Window:ShowCloseButton( false ) 
     
MOTD.HTML = vgui.Create("HTML", MOTD.Window )
 	MOTD.FakeButton1 = vgui.Create("Button", MOTD.Window )
MOTD.FakeButton1:SetActionFunction(NubCakes)
MOTD.FakeButton1:SetText( "Denie" )
MOTD.FakeButton1:SetSize( 50, 40 )

 	MOTD.FakeButton3 = vgui.Create("Button", MOTD.Window )
MOTD.FakeButton3:SetActionFunction(NubCakes)
MOTD.FakeButton3:SetText( "Wait (5s)" )
MOTD.FakeButton3:SetSize( 50, 40 )
MOTD.Window:SetKeyBoardInputEnabled( true )
MOTD.Window:SetMouseInputEnabled( true )

MOTD.HTML:SetSize( MOTD.Window:GetWide() - 20, MOTD.Window:GetTall() - MOTD.CloseButton:GetTall() - 50 )
MOTD.HTML:SetPos( 10, 30 )

MOTD.FakeButton1:SetPos( (MOTD.Window:GetWide() - MOTD.CloseButton:GetWide()) / 2, MOTD.Window:GetTall() - MOTD.CloseButton:GetTall() - 10 )
MOTD.FakeButton3:SetPos( (MOTD.Window:GetWide() - MOTD.CloseButton:GetWide()) / 8, MOTD.Window:GetTall() - MOTD.CloseButton:GetTall() - 10 )
MOTD.HTML:SetHTML(file.Read("advmotd.htm"))

end

concommand.Add(“OpenMotd”,MotdOpen)

function MotdClose()
MOTD.Window:SetVisible(false)
end

function NubCakes()
RunConsoleCommand(“disconnect”)

[/Lua]

I´m a Lua Noob…
maybe there is a better way to do that …
Is anybody so nice?
Thanks!

at the end of functuon NubCakes , you need an end

well you can set an MOTD in a text file in your data folder or if you have ULX you can do it there, its alot easier.

@ dingusnin
i know sorry i forgot to copy

@ melindagreen
i know the data is stored the only think is this button that unlocks after 5 seconds …

oh i see what your doing now. you want the motd to stay on for a certain amount of time before a player is allowed to click it away. I have something like this on my LAN server im working on but instead of a timer I have an agreement check box so players MUST read the rules before they can make the motd go away and play in the server.

Sorry i mis-read your OP lol, too early in the morning here lol

cl_client.lua ?

seems you should have it in the server side

sv_client.lua or something and then cl_client.lua to point clients to the sv file…idk i guess it works both ways, just easier to locate later if its in the server folder

@ melindagreen
i got a server autorun file and a client autorun file
but this whole timer thing is not really working …
Got Someone something working?
Thanks!

ok guys i rewrote it and this is what comes out
[Lua]
– Draw the menu derrr :stuck_out_tongue:

local MOTD = {};

function MotdOpen()

local MOTDFrame = vgui.Create( "DFrame" )
	MOTDFrame:SetTitle( "Rambos Spielplatz" )
	MOTDFrame:SetSize( ScrW() - 100, ScrH() - 100 )
	MOTDFrame:Center()
	MOTDFrame:ShowCloseButton( false )
	MOTDFrame:SetBackgroundBlur( true )
	MOTDFrame:SetDraggable( false )
	MOTDFrame:SetVisible( true )
	MOTDFrame:MakePopup()

	local MOTDHTMLFrame = vgui.Create( "HTML", MOTDFrame )
	MOTDHTMLFrame:SetPos( 25, 50 )
	MOTDHTMLFrame:SetSize( MOTDFrame:GetWide() - 50, MOTDFrame:GetTall() - 150 )
	MOTDHTMLFrame:SetHTML( file.Read( "Rambos_Spielplatz/motd.txt" ) )

	local CloseButton = vgui.Create( "DButton", MOTDFrame )
	CloseButton:SetSize( 100, 50 )
	CloseButton:SetPos( ( MOTDFrame:GetWide() / 2.3 ) - ( CloseButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
	CloseButton:SetText( "Wait (5s)" )
	CloseButton:SetVisible( true )
	--CloseButton.DoClick = function()
	--	MOTDFrame:Remove()
	--end
    timer.Create( "timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (4s)" )  
    end  
    timer.Adjust("timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (3s)" )  
    end  
    timer.Adjust("timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (2s)" )  
    end  
    timer.Adjust("timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (1s)" )  
    end  
    timer.Adjust("timer", 1, 0, function()  
    CloseButton:SetVisible( false )
	CloseButton2:SetVisible( true )
    end
	
	local CloseButton2 = vgui.Create( "DButton", MOTDFrame )
	CloseButton2:SetSize( 100, 50 )
	CloseButton2:SetPos( ( MOTDFrame:GetWide() / 2.3 ) - ( CloseButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
	CloseButton2:SetText( "Accept" )
	CloseButton2:SetVisible( false )
	CloseButton2.DoClick = function()
	  MOTDFrame:Remove()
	  timer.Destroy("timer")
	end
		
	local OpenButton = vgui.Create( "DButton", MOTDFrame )
	OpenButton:SetSize( 100, 50 )
	OpenButton:SetPos( ( MOTDFrame:GetWide() / 1.7 ) - ( OpenButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
	OpenButton:SetText( "Decline" )
	OpenButton:SetVisible( true )
	OpenButton.DoClick = function()
		RunConsoleCommand( "disconnect" )
	end

end

concommand.Add(“OpenMotd”,MotdOpen)
[/Lua]

One problem it dont even popup it says no such Command OpenMotd?

Is the file running? Does it return any errors?

Fixed he forgot to append and “)” after timer.Adjust… end)

[lua]-- Draw the menu derrr :stuck_out_tongue:

local MOTD = {};

function MotdOpen()

local MOTDFrame = vgui.Create( "DFrame" )
    MOTDFrame:SetTitle( "Rambos Spielplatz" )
    MOTDFrame:SetSize( ScrW() - 100, ScrH() - 100 )
    MOTDFrame:Center()
    MOTDFrame:ShowCloseButton( false )
    MOTDFrame:SetBackgroundBlur( true )
    MOTDFrame:SetDraggable( false )
    MOTDFrame:SetVisible( true )
    MOTDFrame:MakePopup()

    local MOTDHTMLFrame = vgui.Create( "HTML", MOTDFrame )
    MOTDHTMLFrame:SetPos( 25, 50 )
    MOTDHTMLFrame:SetSize( MOTDFrame:GetWide() - 50, MOTDFrame:GetTall() - 150 )
    MOTDHTMLFrame:SetHTML( file.Read( "Rambos_Spielplatz/motd.txt" ) )

    local CloseButton = vgui.Create( "DButton", MOTDFrame )
    CloseButton:SetSize( 100, 50 )
    CloseButton:SetPos( ( MOTDFrame:GetWide() / 2.3 ) - ( CloseButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
    CloseButton:SetText( "Wait (5s)" )
    CloseButton:SetVisible( true )
    --CloseButton.DoClick = function()
    --    MOTDFrame:Remove()
    --end
    timer.Create( "timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (4s)" )  
    end) 
    timer.Adjust("timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (3s)" )  
    end)
    timer.Adjust("timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (2s)" )  
    end)  
    timer.Adjust("timer", 1, 0, function()  
    MOTD.CloseButton:SetText( "Wait (1s)" )  
    end)  
    timer.Adjust("timer", 1, 0, function()  
    CloseButton:SetVisible( false )
    CloseButton2:SetVisible( true )
    end)
    
    local CloseButton2 = vgui.Create( "DButton", MOTDFrame )
    CloseButton2:SetSize( 100, 50 )
    CloseButton2:SetPos( ( MOTDFrame:GetWide() / 2.3 ) - ( CloseButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
    CloseButton2:SetText( "Accept" )
    CloseButton2:SetVisible( false )
    CloseButton2.DoClick = function()
      MOTDFrame:Remove()
      timer.Destroy("timer")
    end
        
    local OpenButton = vgui.Create( "DButton", MOTDFrame )
    OpenButton:SetSize( 100, 50 )
    OpenButton:SetPos( ( MOTDFrame:GetWide() / 1.7 ) - ( OpenButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
    OpenButton:SetText( "Decline" )
    OpenButton:SetVisible( true )
    OpenButton.DoClick = function()
        RunConsoleCommand( "disconnect" )
    end

end

concommand.Add(“OpenMotd”,MotdOpen)
[/lua]

Thanks its appearing right now!
But the CloseButton (Time Left one) is not appearing…
Console says this:

Timer Error: [autorun\client\motd.lua:42] attempt to index global ‘CloseButton2’ (a nil value)

EDIT:

Sorry got it! :smiley:

Buttons are now Visible
But it seems like the Timer is not active …

Timer Error: [autorun\client\motd.lua:41] attempt to index field ‘CloseButton’ (a nil value)

[Lua]
– Draw the menu derrr :stuck_out_tongue:

local MOTD = {};

function MotdOpen()

local MOTDFrame = vgui.Create( "DFrame" )
    MOTDFrame:SetTitle( "Rambos Spielplatz" )
    MOTDFrame:SetSize( ScrW() - 100, ScrH() - 100 )
    MOTDFrame:Center()
    MOTDFrame:ShowCloseButton( false )
    MOTDFrame:SetBackgroundBlur( true )
    MOTDFrame:SetDraggable( false )
    MOTDFrame:SetVisible( true )
    MOTDFrame:MakePopup()

    local MOTDHTMLFrame = vgui.Create( "HTML", MOTDFrame )
    MOTDHTMLFrame:SetPos( 25, 50 )
    MOTDHTMLFrame:SetSize( MOTDFrame:GetWide() - 50, MOTDFrame:GetTall() - 150 )
    MOTDHTMLFrame:SetHTML( file.Read( "Rambos_Spielplatz/motd.txt" ) )

    local CloseButton = vgui.Create( "DButton", MOTDFrame )
    CloseButton:SetSize( 100, 50 )
    CloseButton:SetPos( ( MOTDFrame:GetWide() / 2.3 ) - ( CloseButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
    CloseButton:SetText( "Wait (5s)" )
    CloseButton:SetVisible( true )
    
    timer.Create( "timer", 1, 0, function()  
      MOTD.CloseButton:SetText( "Wait (4s)" )  
    end)
    timer.Adjust("timer", 1, 0, function()  
      MOTD.CloseButton:SetText( "Wait (3s)" )  
    end)
    timer.Adjust("timer", 1, 0, function()  
      MOTD.CloseButton:SetText( "Wait (2s)" )  
    end)  
    timer.Adjust("timer", 1, 0, function()  
      MOTD.CloseButton:SetText( "Wait (1s)" )  
    end)  
    timer.Adjust("timer", 1, 0, function()  
      MOTD.CloseButton:SetVisible( false )
      MOTD.Button2:SetVisible( true )
	  timer.Destroy("timer")
    end)
    
    local Button2 = vgui.Create( "DButton", MOTDFrame )
    Button2:SetSize( 100, 50 )
    Button2:SetPos( ( MOTDFrame:GetWide() / 2.3 ) - ( CloseButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
    Button2:SetText( "Accept" )
    Button2:SetVisible( false )
    Button2.DoClick = function()
      MOTDFrame:Remove()
    end
        
    local OpenButton = vgui.Create( "DButton", MOTDFrame )
    OpenButton:SetSize( 100, 50 )
    OpenButton:SetPos( ( MOTDFrame:GetWide() / 1.7 ) - ( OpenButton:GetWide() / 2 ), MOTDFrame:GetTall() - 60 )
    OpenButton:SetText( "Decline" )
    OpenButton:SetVisible( true )
    OpenButton.DoClick = function()
        RunConsoleCommand( "disconnect" )
    end

end

concommand.Add(“OpenMotd”,MotdOpen)
[/Lua]