Chat Command ( NOT WORKING )



if ( CLIENT ) then

	function AdminMenu( Player, text, Public )

		if ( Player:IsValid() ) then

			if (string.sub(text, 1, 9) == "/admintab") then
			local base = vgui.Create( "DFrame" )
				base:SetPos( 80,50 )
				base:SetSize( 200, 130 )
				base:SetTitle( "Admin Tab" )
				base:SetVisible( true )
				base:SetDraggable( true )
				base:ShowCloseButton( true )
			function base:Paint( w, h )
				draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 255, 100 ) )
				surface.SetDrawColor( Color(0,150,255,255) )
				surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
		
				surface.SetDrawColor( Color(0,0,0,255) )
				surface.DrawRect( 2, 2, self:GetWide()-4, self:GetTall()-4 )
			end
			end
		end

	end
	hook.Add( "PlayerSay", "AdminMenu", AdminMenu )

end


Please tell me anything thats wrong with this command!

Where is the code for the actual chat command?
Edit: Im blind

That is the whole chat command, Ive stored it in lua/autorun/server and the command should be /admintab like it says:



			if ( string.lower( Text ) == "/admintab" ) then


if (string.sub(text, 1, 9) == “/admintab”)
try that?

You’re trying to run client-side code on the server (vgui is handled clientside). Use the network library or usermessages to tell the client that it has said the chat command.

Could you please give me example, im new to coding and have no clue.

bump

[editline]22nd December 2013[/editline]



if ( CLIENT ) then

	function AdminMenu( Player, text, Public )

		if ( Player:IsValid() ) then

			if (string.sub(text, 1, 9) == "/admintab") then
			local base = vgui.Create( "DFrame" )
				base:SetPos( 80,50 )
				base:SetSize( 200, 130 )
				base:SetTitle( "Admin Tab" )
				base:SetVisible( true )
				base:SetDraggable( true )
				base:ShowCloseButton( true )
			function base:Paint( w, h )
				draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 255, 100 ) )
				surface.SetDrawColor( Color(0,150,255,255) )
				surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
		
				surface.SetDrawColor( Color(0,0,0,255) )
				surface.DrawRect( 2, 2, self:GetWide()-4, self:GetTall()-4 )
			end
			end
		end

	end

end
hook.Add( "PlayerSay", "AdminMenu", AdminMenu )


I’ve also tried that

[editline]22nd December 2013[/editline]

Ok I rewrote the code and tried this and still not working:



if ( SERVER ) then
	function AdminTab( text, ply )
		if (string.sub(text, 1, 9) == "/admintab") then
		umsg.Start( "AdminMenu" )
		end
	end
end
hook.Add( "PlayerSay", "AdminTab", AdminTab )

if ( CLIENT ) then
	usermessage.Hook( "AdminMenu", function( ply )
		if ply:IsAdmin() then
		local base = vgui.Create( "DFrame" )
			base:SetPos( 80,50 )
			base:SetSize( 200, 130 )
			base:SetTitle( "Admin Tab" )
			base:SetVisible( true )
			base:SetDraggable( true )
				function base:Paint( w, h )
					draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 255, 100 ) )
					surface.SetDrawColor( Color(0,150,255,255) )
					surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
		
					surface.SetDrawColor( Color(0,0,0,255) )
					surface.DrawRect( 2, 2, self:GetWide()-4, self:GetTall()-4 )
				end
			base:ShowCloseButton( true )
		end
	end)
end


snip

Thanks, atleast someone replies…

Show the path to your file.
garrysmod/lua/autorun . . ?