I is confused.

So I want to know how to correctly use concommands and functions… Tell me if this is on the right track because I don’t have access to gmod right now
[lua] function setatoone (a = 1)
if( a == 1 )
print( “A has been set to one. I suck.” )
end
concommand.Add(“test”, setatoone )
[/lua]
Thanks

That’s basicly it (except you forgot an end), also all the info you need is on the wiki :http://wiki.garrysmod.com/?title=Concommand.Add

That gmod wiki is what confused me. Where is the end missing?

at the end of the if statement

[lua]
function setatoone (a = 1)
if( a == 1 )
print( “A has been set to one. I suck.” )
end
end
concommand.Add(“test”, setatoone )
[/lua]

Oh so each little indent needs an end?

technically yea, if statements must have an end and functions must have an end

if you use a function an if statement or a for or while loop you need to have an end.

Scope, my dear Watson, Scope.

“=” expected near “)”

or maybe the other way around? I don’t have accesss to gmod but that’s what it does when I open the script in GMOD

You completely mis understand arguments. for a console command if you type it in it has 3 arguments(make that more but 3 to pay attention to)
[lua]function saymymessage(ply,cmd,args)
local argss=""
for k,v in pairs(args) do
argss=argss…v
end
RunConsoleCommand(“say”,ply:Nick()…“just ran”…cmd…“with args”…argss)
end
concommand.Add(“test”,saymymessage)[/lua]
now if you type in console test BOO it will make you say anti-fla just ran test with args BOO
you cannot set anything within those parenthesis at the top of the function all it simply does is pass information from one point to another (aka arguments) so in a practical use you could send information from a local variable in a function to another function to use or you could also get returned info but that gets into a little more complex. so your function name(a=1) is invalid syntax.

meow!