Problem with Addon

I need help with my addon

[LUA]
local FrameMenu
local FrameBrowser
local HTML
local BtnShow
local BtnHide
local BtnExit
local BtnUpdate

function OpenTS3Viewer()
surface.PlaySound("/npc/turret_floor/turret_active_5.wav")

FrameMenu = vgui.Create("DFrame")
FrameMenu:SetSize(85, 145)
FrameMenu:SetPos(5, 5)
FrameMenu:SetTitle("Menu")
FrameMenu:ShowCloseButton(false)

FrameBrowser = vgui.Create("DFrame")
FrameBrowser:SetSize(282, 503)
FrameBrowser:SetPos(5, 155)
FrameBrowser:SetTitle("TS3 Viewer")
FrameBrowser:SetVisible(false)
FrameBrowser:SetDeleteOnClose(false)

HTML = vgui.Create( "HTML",FrameBrowser)
HTML:SetPos(5, 25)
HTML:SetSize(278, 480)

BtnExit = vgui.Create("DButton",FrameMenu)
BtnExit:SetSize(70, 25)
BtnExit:SetPos(5, 115)
BtnExit:SetText("Exit")
BtnExit.DoClick = function()
	surface.PlaySound("/npc/turret_floor/turret_disabled_4.wav")
	FrameMenu:Remove()
	FrameBrowser:Remove()
	timer.Destroy("Interval")
end

BtnHide = vgui.Create("DButton",FrameMenu)
BtnHide:SetSize(70, 25)
BtnHide:SetPos(5, 55)
BtnHide:SetText("Hide")
BtnHide.DoClick = function()
if(FrameBrowser:IsVisible()) then
	surface.PlaySound( "/npc/turret_floor/turret_search_2.wav" )
	FrameBrowser:SetVisible(false)
	HTML:SetVisible(false)
	timer.Destroy("Interval")
	else
		surface.PlaySound( "buttons/button18.wav" )
	end
end

BtnShow = vgui.Create("DButton",FrameMenu)
BtnShow:SetSize(70, 25)
BtnShow:SetPos(5, 25)
BtnShow:SetText("Show")
BtnShow.DoClick = function()
	surface.PlaySound( "/npc/turret_floor/turret_active_8.wav" )
	FrameBrowser:SetPos(5, 155)
	FrameBrowser:SetVisible(true)
	HTML:SetVisible(true)
	HTML:OpenURL("http://dl.dropbox.com/u/14827431/Scripts/HTML/TSWatcher.html")
	timer.Create("Interval", 10, 0, function() HTML:Refresh() end)
end  

BtnUpdate = vgui.Create("DButton",FrameMenu)
BtnUpdate:SetSize(70, 25)
BtnUpdate:SetPos(5, 85)
BtnUpdate:SetText("Update")
BtnUpdate.DoClick = function()
	if(FrameBrowser:IsVisible()) then
		surface.PlaySound( "/npc/turret_floor/active.wav" )
		HTML:Refresh()
	else
		surface.PlaySound( "buttons/button18.wav" )
	end

	if(!FrameMenu:IsValid()) then
		FrameBrowser:Remove()
	end
end

end

concommand.Add(“ts3_viewer”,OpenTS3Viewer)
[/LUA]

If I put this code into “addons/TS3_Viewer/lua/autorun/client/ts3.lua” it returns me an error:

[addons s3 viewer\lua\autorun\client s3.lua:13] attempt to index local ‘FrameMenu’ (a nil value)

Please help me :3
Greetz MaXx0r


(User was banned for this post ("Wrong forum" - Grea$eMonkey))

Use the [LUA][ LUA ][/LUA] tags. Much easier to read.

Currently you’re calling the function OpenTS3Viewer on the last line, instead of passing the function itself as an argument.

[lua]concommand.Add(“ts3_viewer”,OpenTS3Viewer())
– vs.
concommand.Add(“ts3_viewer”,OpenTS3Viewer)[/lua]

Thank you,
How can I auto-run this script as an addon, without using a console command?

Put it in /lua/autorun/client/