Having trouble with timer (I think)

Okay so I am coding a custom addon (just to learn Lua) and I seem to be getting this script error… It basically says there is an issue in line 22 in my shared.lua, here is the code

GM.Name = “Test GM”
GM.Author = “Chris Tucker”
GM.Email = “N/A”
GM.Website = “www.casualrp.zone”

function GM:Initialize()

self.BaseClass.Initialize( self )

end

// Teams //
team.SetUp( 1, “Cops”, Color (255, 0, 0))
team.SetUp( 2, “Baddies”, Color (0, 255, 0))
team.SetUp( 3, “Spectate”, Color (0, 0, 255))
// Models //
util.PrecacheModel(“models/player/arctic.mdl”)
util.PrecacheModel(“models/player/leet.mdl”)
util.PrecacheModel(“models/player/alyx.mdl”)
// Timers //
timer.Create(“Team”, 10, 5, TeamT) //Error is on this line (apparently) //

Please help as I have no idea why
Cheers

Does the error say something along the lines of “function expected, got nil”?

When you create a timer using timer.Simple, the first argument is the delay, the second is the reference to a function or a new function declaration. With timer.Create you’ve got the timer id/name, the delay, how many times it should run, and the function reference or declaration.

There is also a hook which is used to call team.SetUp; CreateTeams - http://wiki.garrysmod.com/page/GM/CreateTeams

Example:


//
// SHARED HOOK : Called during Game-mode initialization / startup when the teams should be created
//
hook.Add( "CreateTeams", "CreateTeamsAndPrecacheModels", function( )
	// Teams
	team.SetUp( 1, "Cops", Color( 255, 0, 0, 255 ) );
	team.SetUp( 2, "Baddies", Color( 0, 255, 0, 255 ) );
	team.SetUp( 3, "Spectate", Color( 0, 0, 255, 255 ) );

	// Models
	util.PrecacheModel( "models/player/arctic.mdl" );
	util.PrecacheModel( "models/player/leet.mdl" );
	util.PrecacheModel( "models/player/alyx.mdl" );
end );

As for the timer, I’m not sure what it should do, but here’s a few ways to set it up:


timer.Create( "TeamT", 10, 5, function( )
	print( "Timer TeamT has executed" );
end );


local function TeamT( )
	print( "Timer TeamT has executed" );
end
timer.Create( "TeamT", 10, 5, TeamT );

Also, for addons you do not need to specify GM.Name, etc… That is for game-modes…

To simplify your addon, the structure is ( You can simply drop files into the autorun directories and avoid needing to call include/AddCSLuaFile because the 3 folders do it for you automatically ):

garrysmod/addons/<addon_name>/
garrysmod/addons/<addon_name>/lua/
garrysmod/addons/<addon_name>/lua/autorun/ – Files in here are automatically included and AddCSLuaFile’ed ( SHARED REALM )
garrysmod/addons/<addon_name>/lua/autorun/server/ – Files in here are automatically included ( SERVER REALM )
garrysmod/addons/<addon_name>/lua/autorun/client/ – Files in here are automatically included on the client only and AddCSLuaFile’ed on the server ( CLIENT REALM )

EDIT: Welcome to Facepunch:
Hey, welcome to FacePunch.
I have written over 400 tutorials and completed “systems” in Lua for Garry’s Mod. I tutor and answer questions for free; feel free to add me on Steam if you need some guidance. This forum is for devs that need help working on things. Here are some resources to help you get started:

Generalized Lua Help ( Links to Wikis, Answers the question of “Where do I post a simple question or DarkRP Specific question”, links to other resources compiled by forum members )
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_general_lua_learning.lua.html

Useful Programs ( SteamCMD, Autosizer, Desktops, Process Explorer ) and Notepad++ Upgrades
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_useful_programs_and_notepadpp_upgrades.lua.html

AcecoolDev_Base Skeletonized Dev Base Game-Mode ( Never worry about Include or AddCSLuaFile ever again; comes with New Hooks, Console Commands, Meta-Table Objects, Helper Functions, Extended Functionality, and more! )
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_acecooldev_base_gamemode_info.lua.html