Motd

[lua]function ShowMotdMenu()
local window = vgui.Create( “DFrame” )
if ScrW() > 640 then – Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( “[NG] Message Of The Day” )
window:SetVisible( true )
window:MakePopup()

local html = vgui.Create( "HTML", window )

local button = vgui.Create( "DButton", window )
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )    

html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
html:SetHTML( file.Read( "motd.txt" ) )

end

local function showMotd( ply )
if not ply:IsValid() then return end – They left, doh
ShowMotdMenu()
end[/lua]

how do I make this display when someone joins the server?

I’m not sure but try to put it in “lua/autorun/client”

-shouldn’t have been so harsh-

You’re gonna want to use usermessages and hooks in a shared file:

[lua]if SERVER then
hook.Add(“PlayerInitialSpawn”,“MOTDPopup”,function(pl)
umsg.Start(“showMOTD”,pl) umsg.End()
end)
else
function ShowMOTD()
local window = vgui.Create( “DFrame” )
if ScrW() > 640 then – Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( “[NG] Message Of The Day” )
window:SetVisible( true )
window:MakePopup()

	local html = vgui.Create( "HTML", window )
	
	local button = vgui.Create( "DButton", window )
	button:SetText( "Close" )
	button.DoClick = function() window:Close() end
	button:SetSize( 100, 40 )
	button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )    
	
	html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
	html:SetPos( 10, 30 )
	html:SetHTML( file.Read( "motd.txt" ) )
end
usermessage.Hook("showMOTD",ShowMOTD)

end[/lua]

Thanx Entoros I couldn’t find that on Gmod.org +1

sorry but when i put a derma in autorun/client, it open when someone connect, i’m a noob, i just wanted to help

Where do I put this? In the client folder…?

lua/autorun/motd.lua

[lua]
if ( SERVER ) then
AddCSLuaFile(“autorun/motd.lua”)
return
end

hook.Add(“InitPostEntity”, “MOTD”, function()
local window = vgui.Create( “DFrame” )
if ScrW() > 640 then – Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( “[NG] Message Of The Day” )
window:SetVisible( true )
window:MakePopup()

local html = vgui.Create( "HTML", window )

local button = vgui.Create( "DButton", window )
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )    

html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
html:SetHTML( file.Read( "motd.txt" ) )

end )
[/lua]

What folder do I put the motd.txt in?

data/

[editline]06:29PM[/editline]

[lua]
resource.AddFile(“data/motd.txt”)
[/lua]

So it would be

[lua]resource.AddFile(“data/motd.txt”)
if ( SERVER ) then
AddCSLuaFile(“autorun/motd.lua”)
return
end

hook.Add(“InitPostEntity”, “MOTD”, function()
local window = vgui.Create( “DFrame” )
if ScrW() > 640 then – Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( “[NG] Message Of The Day” )
window:SetVisible( true )
window:MakePopup()

local html = vgui.Create( "HTML", window )  
  
local button = vgui.Create( "DButton", window )  
button:SetText( "Close" )  
button.DoClick = function() window:Close() end  
button:SetSize( 100, 40 )  
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )      
  
html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )  
html:SetPos( 10, 30 )  
html:SetHTML( file.Read( "motd.txt" ) )  

end ) [/lua]

The resource.AddFile goes inside the if ( SERVER ) statement

Thanks, It works!

:pervert:

Thats in my data folder and its called motd.TXT , and it just says test. What is on line 29 of post #12? I think that may be reading another file also.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<style type="text/css">
.style1 {
	text-align: center;
	font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
	font-size: x-large;
	text-decoration: underline;
}
.style2 {
	text-align: left;
	font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
	font-size: large;
}
.style3 {
	text-decoration: underline;
}
.style4 {
	font-size: small;
}
.style6 {
	text-align: left;
	font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
	font-size: medium;
}
.style7 {
	text-align: left;
	font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
	font-size: small;
}
</style>
</head>

<body bgcolor="black" style="color: #C0C0C0">

<p class="style1">Neutral Gaming DarkRP</p>
<p class="style2"><span class="style3">Section 1 - Rules</span><br />
<br />
<span class="style4">Rule 1: Do not Prop-Surf or Prop-Climb, Using Props to get 
to another area.<br />
Rule 2: Do not Prop-Block, Using Props to block something.<br />
Rule 3: Do not exploit, this means anything. Anything that will give you an 
advantage over others.<br />
Rule 4: Do not Farm Money, Go AFK with a higher paying job.<br />
Rule 5: Do not shoot the NPC's this will result in immedate ban.<br />
Rule 5: Do not RDM, Killing players without a reason.<br />
Rule 6: Do not randomly kill the mayor.<br />
Rule 7: Do not use buttons to bypass a banned prop.<br />
Rule 8: Do not block the any area where a player spawns.<br />
Rule 9: Do not give somone anything they shouldnt have suck as a citizen a 
stunstick.<br />
Rule 10: Do not shoot every cop you see, this is RDM.<br />
Rule 11: You are scared of the law, if they say something you should do it.<br />
Rule 12: Do not advert illegal things suck as selling weapons or drugs.<br />
Rule 13: Do not create bases above the ground. This is not a build server.<br />
Rule 14: Do not abuse the door swep, such as putting 5 doors infront of your 
money printer.<br />
Rule 15: Do not trap players in props or jail them.<br />
Rule 16: If someone breaks into your house call the police with /cr.<br />
Rule 17: Do not randomly jail kill, unless there is a good reason too.<br />
Rule 18: Do not sell job slots. If you don't want a job go citizen.<br />
Rule 19: Do not change classes to avoid demoliton.<br />
Rule 20: Do not job steal, demote somone and take thier job.<br />
Rule 21: Do not Prop-Push, using a prop to push somone around.<br />
Rule 22: Do not put random props in the street, if a prop isnt being used remove 
it!<br />
Rule 23: Do not hack. We have an anti-cheat system so all hackers will be banned 
when detected!<br />
Rule 24: If you are a CP listen to the mayor and patrol, do not guard peoples 
shops!<br />
Rule 25: If there is no mayor do not be the mayors guard.</span></p>
<p class="style6">Please visit our website <a href="neutralgaming.co.uk">here</a> 
and have a good day! </p>
<p class="style7"> </p>
<p class="style7">Our MOTD and VIP Terms of use are subjected to change without 
reason or warning. We reserve the right to remove any players VIP and ban them 
from the server without reason.</p>

</body>

</html>


post #12

Also; are you asking a question here, or…?

I thought it had worked because I made it print ‘Test’ and I tryed to change it and it failed :S

I am an Idiot ignore me.