EasyMOTD - Easy, fast and useful

[release]

http://s3.garrysmod.org/img/dl/112062_1.jpg

I were a little bit bored, and I decided to make EasyMOTD
The point of this MOTD script is that it’s supposed to be easy, fast and useful. By that I mean you got stuff like

[ul]
[li] You got a configuration part in the client/cl_easymotd.lua where you can do following:
[/li][li] Enable/Disable the motd
[/li][li] Write in your chosen html code you want to show OR add a URL you want to redirect the MOTD to
[/li]
[li] Set the title of the MOTD window
[/li][li] Set accept button text to what ever you want
[/li][li] Set a timer on accept button where it’s grayed out in the amount of time you chose
[/li][li] Write something the player will say if he presses “Accept” or “Close”
[/li][li] If wished, you can add a Decline button too and change the text of it if wished too
[/li][li] You can also make the admins not see the motd at all. If wished
[/li][/ul]

The script also has the function to open the MOTD with the following commands in chat: /motd & /rules

Remember: You need to restart the server to make the changes apply

The point of this release is that you can easly create the motd you want, without really knowing LUA at all.

Download


This addon is not optimized for G13

Current Release (v.1.1b)
http://www.mediafire.com/?4jmdl7wxmvxhv0l

Old Versions

Version 1.1: http://www.garrysmod.org/downloads/?a=view&id=112062
Version 1.0: http://www.mediafire.com/?d9ocur6c8wzv6pu

:siren:


Here is the not-working-chat bug official fix!

:siren:
[lua]
function ChatCommandSay(ply, text)
if string.find(string.lower(text), “/motd”) or string.find(string.lower(text), “/rules”) then
ply:ConCommand(“EasyMOTD_Open”)
return “”
end
end
hook.Add(“PlayerSay”, “ChatCommandSay”, ChatCommandSay)
[/lua]

** Pictures **

[tab]Default Config[/tab] [img_thumb]http://i974.photobucket.com/albums/ae222/blt950/EasyMOTD/EasyMOTD1.jpg[/img_thumb]

[tab]When accept say enabled[/tab] [img_thumb]http://i974.photobucket.com/albums/ae222/blt950/EasyMOTD/EasyMOTD2.jpg[/img_thumb]

[tab]Redirecting to URL, waiting 5 sec for the button to get enabled. Also edited the button texts. Easy![/tab] [img_thumb]http://i974.photobucket.com/albums/ae222/blt950/EasyMOTD/EasyMOTD3.jpg[/img_thumb]

[/release]

Its nice to see people doing something usefull Instead of copyed code on diffrent weapon models.

Looks like something that server owners with to many minges would find very usefull.

Epic, I can’t thank you enough for this!

Finally i can have the “button will appear after 5 secs” when i am using ulx!

Good job BTL, I’ll probably use this over ULX.

Yeah.

In other news, I need to buy a new irony meter.

Hey Blt, you need to edit the script, so the mouse shows when trying to click the ‘Accept’ button. Other wise, idiot 7 year old’s will say that they can’t click it, and have no idea what F3 does.

I’ll check that out. That script was made in so short time that it’s not neccesarry to mention it lol.

I’m going to maybe update it in the next days with some fixed statements and making the code look smarter, and run smarter ^^
Also add chat commands to pop-up the menu :slight_smile:

The F3 button is a DarkRP function. So it’s probably a problem there, but I can enable it to be sure you have the mouse when MOTD pops up.

Edit :S
**Huh? Automerge failed? **

Update released! (Version 1.1)

[tab]Changelog[/tab]
[release][EDIT] Edited some silly statements, but not many… This will get even more improved/completely fixed when I make everything controlled from Options in Q menu.
[ADD] Enabled mouse just to be sure the players gets it up and closed.
[ADD] Made MOTD popup with following commands: /motd, /rules (More can be added/edited in easymotd.lua; WARNING: This might need LUA skills, or basic understandings)
[/release]

Automerge failed again here, sorry moderators :S Used to have it working

Oh thanks for chat feature! Can’t there be an SVN? :slight_smile:

Do you really need an SVN for something that probably won’t get a lot of updates?

Gmod.org linking is fine IMHO.

Using this myself btw.

As Phoenix said:

Totally agree there, it’s no need of SVN for this little thing that is not updates everyday.
Garrysmod.org works good here

kk, its anyway awesome

it is only the Admins on my server there can see the page, and the buttons… ??? help plz

Sorry, I can’t understand what you’re trying to say.

He’s propably meaning that only admins can see the webpage in the MOTD and the buttons, but players can’t.

yeah, there it was :)… sry for bad English but it isn’t my first Language…

Awesome work! Simple and easy. But only one thing, it won’t work for me. The only thing which happens is a gray window popping up, with no content, no matter if I use an URL or not. Also no close button, only thing which shows up is the window title.
Error in console:


 autorun\client\cl_easymotd.lua:54] attempt to index global 'LocalPlayer' (a function value) 

My cl_easymotd.lua:


/*
WELCOME TO EasyMOTD! Made by: Blt950 aka Monkey Power

Remember to turn off all MOTD's from other admin mods/addons before using this one!

Also remember that any edit here needs a server restart ^^
Have fun!
======================================================
================== CONFIGURATION =====================
======================================================

*/
local EnableMOTD = true -- Change to false if you want to disable the EasyMOTD completely. But want to keep the script installed.

local EasyMOTDhtml = [[

<html><center><b> Welcome to EasyMOTD! Please change this to your wished HTML code! </b></center></html>

]]
-- ^^ Over here you paste your HTML code that you want people to see ^^ If you want to display a URL instead of a HTML code here. Change below here:
local URL = "http://extreme.7forum.biz" -- From the moment you change this from blank, to something. It will redirect the MOTD to that page. And ignore the HTML code that is above here. PASTE WHOLE URL! With http://


local EasyMOTDTitle = "Welcome to The eXtreme Server!! By closing this, you agree to our rules. We hope you will get an Great playing time :)" -- Write your wished title here. If you leave it blank. It will only show "EasyMOTD"
local AcceptButtonText = "Happy Playing :)" -- Write your wished text for the accept button here. If you leave it blank, it will show default: "Close"
local AcceptButtonTime = 2 -- If you change this to a postitive value that is not 0. The accept button will be grayed out in that amount you set in here.
local AcceptSay = "" -- If you change this to something else, the player will say this in the chat (when accepted). WARNING: If you e.g. have a RP server with OOC you have to write like "// I accepted the rules" to display in OOC

local DeclineButton = false -- Set this to "true" if you wan't a "Decline" button that disconnect player when pressed.
local DeclineButtonText = "" -- Set the text of deny button here if you don't want the default "Decline"

local ShowAdmins = true -- Change this to "false" if you don't want admins to get the MOTD. WARNING: If your admin-mod is too slow to load, 
-- and doesn't reconice you as admin before the motd pops up. The motd will detect you as a non-admin!

/*====================================================
============= DON'T CHANGE BELOW HERE ================
====================================================*/
-- And yeah, the code is messy. But you're not supposed to change it. At least with your own risk ;D
if EnableMOTD then
	function ShowEasyMOTD()
		gui.EnableScreenClicker(true) -- Enable the mouse
	
		local window = vgui.Create( "DFrame" )
		window:ShowCloseButton(false)
		window:SetDraggable(false)
		if ScrW() > 640 then
			window:SetSize( ScrW()*0.9, ScrH()*0.9 )
		else
			window:SetSize( 640, 480 )
		end
		window:Center()
		if EasyMOTDTitle == "" then
			window:SetTitle( "EasyMOTD" )
		else
			window:SetTitle( EasyMOTDTitle )
		end
		
		if LocalPlayer():IsAdmin() or LocalPlayer:IsSuperAdmin() and ShowAdmins then
			window:SetVisible( true )
			window:MakePopup()
		end

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

		local AcceptButton = vgui.Create( "DButton", window )
		if AcceptButtonText == "" then
			AcceptButton:SetText( "Close" )
		else
			AcceptButton:SetText( AcceptButtonText )
		end
		AcceptButton.DoClick = function()
			if AcceptSay != "" then
				RunConsoleCommand("say", AcceptSay)
			end
			window:Close() 
			gui.EnableScreenClicker(false) -- Disable the mouse
		end
		AcceptButton:SetSize( 100, 40 )
		
		if AcceptButtonTime > 0 then
		AcceptButton:SetDisabled( true )
			timer.Simple( AcceptButtonTime, function()
					AcceptButton:SetDisabled( false )
			end )
		end
		
		
		if !DeclineButton then
			AcceptButton:SetPos( (window:GetWide() - AcceptButton:GetWide()) / 2, window:GetTall() - AcceptButton:GetTall() - 10 )
		else
			AcceptButton:SetPos( ( window:GetWide() / 2.3 ) - ( AcceptButton:GetWide() / 2 ), window:GetTall() - 57 )
			
			local DeclineButton = vgui.Create( "DButton", window )
			DeclineButton:SetSize( 100, 40 )
			DeclineButton:SetPos( ( window:GetWide() / 1.7 ) - ( DeclineButton:GetWide() / 2 ), window:GetTall() - 57 )
			if DeclineButtonText == "" then
				DeclineButton:SetText( "Decline" )
			else
				DeclineButton:SetText( DeclineButtonText )
			end
			DeclineButton:SetVisible( true )
			DeclineButton.DoClick = function()
				RunConsoleCommand( "disconnect" )
			end
		end
	

		html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 50 )
		html:SetPos( 10, 30 )
		
		if URL != "" then
			html:OpenURL( URL )
		elseif URL == "" then
			html:SetHTML( EasyMOTDhtml )
		else
			html:SetHTML( "<html><b> Sorry, something here errored. Is everything correctly set? </b></html>" )
		end
		
		window:SetSkin("EasyMOTDSkin")
	end
	concommand.Add( "EasyMOTD_Open", ShowEasyMOTD ) -- Don't edit this one, if you do. The script might go bananas. Rest one you might edit if wished.
	concommand.Add( "EasyMOTDOpen", ShowEasyMOTD )
	concommand.Add( "motd", ShowEasyMOTD )
end

/* ==============   MOTD SKIN ============ (This is actuall skin from my MetroRP: http://www.facepunch.com/showthread.php?1010968)
It makes the buttons more rounder and fancy ;) */
local skin = {}
skin.PrintName			= "EasyMOTDSkin"
skin.Author				= "Blt950"
skin.DermaVersion		= 1
skin.text_normal		= Color( 100, 100, 100, 255 )
skin.control_color_active = Color(120, 180, 120, 255)
skin.tooltip			= Color( 145, 215, 45, 255 )
function skin:PaintButton(button)
	local w, h = button:GetSize()
	local x, y = 0,0
	
	local bordersize = 8
	if w <= 32 or h <= 32 then bordersize = 4 end -- This is so small buttons don't look messed up
	
	if button.m_bBackground then
		local color1 = Color(50, 50, 50, 255)
		local color2 = Color(150, 150, 150, 150)
		
		if button:GetDisabled() then
			color2 = Color(80, 80, 80, 255)
		elseif button.Depressed or button:GetSelected() then
			color2 = Color(color2.r + 40, color2.g + 100, color2.b + 40, color2.a + 40)
		elseif button.Hovered then
			color1 = Color(color1.r + 40, color1.g + 40, color1.b + 40, color1.a)
			color2 = Color(color2.r + 40, color2.g + 40, color2.b + 40, color2.a + 40)
		end
		draw.RoundedBox(bordersize, x, y, w, h, color1)
		draw.RoundedBox(bordersize, x+1, y+1, w-2, h-2, color2)
		draw.RoundedBox(bordersize, x+1, y+1, w-2, (h-2)/2, Color(color2.r + 80, color2.g + 80, color2.b + 80, 50))
	end
end
function skin:PaintScrollBarGrip( panel )

	local w, h = panel:GetSize()
	
	local col = self.control_color
	
	if ( panel.Depressed ) then
		col = self.control_color_active
	elseif ( panel.Hovered ) then
		col = self.control_color_highlight
	end
		
	draw.RoundedBox( 2, 0, 0, w, h, Color( 0, 0, 0, 230 ) )
	draw.RoundedBox( 2, 1, 1, w-2, h-2, Color( col.r + 30, col.g + 30, col.b + 30 ) )
	draw.RoundedBox( 2, 2, 2, w-4, h-4, col )
		
	draw.RoundedBox( 0, 3, h*0.5, w-6, h-h*0.5-2, Color( 0, 0, 0, 25 ) )

end
function skin:PaintOverButton( panel ) end
derma.DefineSkin("EasyMOTDSkin", "The skin for EasyMOTD", skin)




And my easymotd.lua file (just in case)


 AddCSLuaFile( "client/cl_easymotd.lua" )

function OpenMOTDAtSpawn( ply )
        ply:ConCommand( "EasyMOTD_Open" )
end
hook.Add( "PlayerInitialSpawn", "OpenMOTDAtSpawn", OpenMOTDAtSpawn )

function ChatCommandSay(ply, text)
    if string.find(string.lower(text), "/motd") or string.find(string.lower(text), "/rules") then -- if they type hello bettywhite it will play or BeTtyWhite
        ply:ConCommand("EasyMOTD_Open")
    end
    return ""
end
hook.Add("PlayerSay", "ChatCommandSay", ChatCommandSay) 

exactly the same problem i have…