Gamemode help

I want to create a really simple gamemode but i need some basic information first.
1.
How can I make a system that adds, say 5 seconds to a variable every 20 seconds?
2.
How can I make a system that runs a console command when you press a button, and when “x” seconds have passed another console command runs?
3.
How can I create a simple HUD
4.
How can I create a help menu
5.
How can I make it so the only way player can get weapons is through the map?
6.
How can I disable the Q menu?
7.
How can I make the HUD have text that displays the weapon that the player is holding?

I know this is kind of a landslide of questions, but i am new to lua coding

Thats alot of questions you got there and i cant answer them all. when i first started out making my gamemode i did the 3 tutorials on gamemodes at http://wiki.garrysmod.com/?title=Lua_Tutorial_Series
along with the derma tutorial. after you read through those you will have a good idea on how to do a basic game mode.
for the questions you asked i will try and answer them
1.
timer.Create( “add_five”, 20, 0, function()
time = time + 5
end )
2.
function i_hit_the_q_button ()
RunConsoleCommand( “kill” )
timer.Create(“wait”, x, 1, function()
RunConsoleCommand( “kill” )
end)
end

concommand.Add( “+menu”, i_hit_the_q_button )

i learned here http://wiki.garrysmod.com/?title=Creating_a_HUD
4.
i would think just make it with derma or a panel and create a console command called “gm_showhelp”
5.
if you mean spawn with no weapons then set up GM:PlayerSpawn with no weapons
6.
if your making your own gamemode not derived from sandbox there is no q menu
7.
this is the question i said before i don’t know how to answer

Uhm… basically, this is just a gamemode with a cool hud and some simple functions… what should i derive it from?

many of these, as said before could be answered by cruising the wiki. i am punching this in on a wii so i wont answer your question now but feel free to add me on steam. my id is awatemonosan

Also, i want a system where if a part of a map has a certain keyvalue, then the object turns a color when you come within 1024 units
how can i do this?

  1. Timer adding
    [lua]local var = 0
    timer.Create(“VarInc”,20,0,function() var = var + 5 end)
    [/lua]

  2. Timed concommand
    [lua]concommand.Add(“do_command”,function(ply,cmd,args)
    timer.Simple(args[2],function() ply:ConCommand(args[1]) end)
    end[/lua]
    This makes it so you use “do_command kill 5” so that it kills you after 5 seconds, if that makes sense.

  3. HUD
    Depends on what you want to do. Use the surface and draw libraries. Look to the 7th question for a use.

  4. Help menu
    That would be derma. Like this:
    [lua]function HelpMenu()
    local frame = vgui.Create(“DFrame”)
    frame:SetSize(500,500)
    frame:Center()
    frame:MakePopup()
    frame:SetTitle(“Help Menu”)

concommand.Add(“help_menu”,HelpMenu)[/lua]
You would need to learn derma though.

  1. Weapon restrictions
    [lua]hook.Add(“PlayerLoadout”,“StripWeapons”,function(ply) return true end)[/lua]
    Basically it gives the player absolutely no weapons.

  2. Disabling the Q menu
    [lua]hook.Add(“EnableSpawnMenu”,“NoShow”,function() return false end)[/lua]
    This goes on the client.

  3. Drawing the weapon name

[lua]hook.Add(“HUDPaint”,“WeaponName”,function()
draw.DrawText(LocalPlayer():GetActiveWeapon():GetPrintName(),“ScoreboardText”,ScrW()/2,20,Color(255,0,0,255),1)
end)[/lua]

And lastly, your coloring issue…

[lua]local ents = {}
hook.Add(“HUDPaint”,“SetColor”,function()
for _,v in ipairs(ents.GetAll()) do
if (v:GetPos()-LocalPlayer():GetPos()):Length() <= 1024 then
for p,q in ipairs(v:GetKeyValues()) do
if p == “Key Value” then
v:SetColor(Color(255,0,0,255))
table.insert(ents)
end
end
end
end
end)

hook.Add(“PlayerFootstep”,“RemoveColor”,function()
for k,v in ipairs(ents) do if (v:GetPos()-LocalPlayer():GetPos()):Length() > 1024 then
v:SetColor(255,255,255,255)
table.remove(ents,k)
end
end
end)
[/lua]

Something like that. Replace “Key Value” with the string of the keyvalue if you want (the current code checks for the existance of the key value, not what it’s equal to).

Dunno if it will work, I made it on the spot. Also, that could get a little laggy running through every entity and setting the color.

What file should that be in?
init.lua?

Also, what is the scale of the units when using hudpaint?
is it like, 1= 1 pixel?

Is there ANYTHING (literally anything) wikipedia doesn’t know!?

:ughh:
thats not wikipedia. thats the gmod wiki.

Also, the hudmaking tutorial didnt make any sense.
Are there any others?