Jova's simple clock

From GMod Wiki

Jump to: navigation, search
Lua: Jova's simple clock
Page white text.png Description:A simple clock by Jova
link=User:Jova Original Author:Jova
Calendar.png Created:March 13, 2010

Introduction

In this tutorial, you will be creating a very simple clock. Useful for servers and if you don't want to minimize your Garry's Mod game to see the time/set your Garry's Mod game to window mode...


In Addon Format

To create an addon, allowing you to easily place this clock in to any gamemode, without the hassle of setting it up in the files of the gamemode, do the following:

1. Create a folder in garrysmod/addons/ called: Simple Clock or something.

2. Inside of this folder create both a text file called info.txt and a folder called "lua".

3. Place this in info.txt:

"AddonInfo"
{
	"name"		"JcHud V3"
	"version"	"v3.0"
	"up_date"	""
	"author_name"	"Jova"
	"author_email"	""
	"author_url"	""
 
	"info"		""
	"override"	"0"
	{
	}
}

4. Inside the lua folder, create a folder named "autorun".

5. Inside autorun, create a file named "clock.lua" or something, then place the content below in "clock.lua".

if (SERVER) then
	AddCSLuaFile("autorun/clock.lua")
end
 
if (CLIENT) then
 
	function clockhud()
		draw.RoundedBox( 0, ScrW()*0.01, ScrH()*0.01, 128, 46, Color( 25, 25, 25, 255 ) )
		draw.RoundedBox( 20, ScrW()*0.01, ScrH()*0.01, 128, 46, Color( 125, 125, 125, 125 ) )
		draw.SimpleText(os.date( "%a, %I:%M:%S %p" ), "Default", ScrW()*0.024, ScrH()*0.02, Color( 255, 104, 86, 255 ),0,0)
		draw.SimpleText(os.date( "%m/%d/20%y" ), "Default", ScrW()*0.035, ScrH()*0.04, Color( 255, 104, 86, 255 ),0,0)
	end
	hook.Add("HUDPaint", "clockhud", clockhud)
end


The script will do the rest, and the result is a little clock appearing in the top left corner of your screen.

rmof1d.png

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox