Need some tips with chattextchanged

Hello,

I am trying to findout what is the function which can check the text message and add a tooltip list like in Developer Console if the chat command exists.
Sorry for bad english :frowning:

-Snip-

Sorry, but what do you mean by a ‘tooltip list’? Do you mean a list of the chat commands or something?

Do you mean something like this?

I wrote a quick example of what I believe you are needing. If it’s even related to what you’re looking for, you can play around with it and see if it helps at all.


-- namespace table to hold everything in
cbt = cbt or {}




-- a list of valid commands the user can enter
cbt.Commands = {
	"ban", "build", "kick", "kill", "slap", "slay"
}




-- creates a DListView that will be used to act like the "tooltip"
-- this is positioned underneath the chatbox with the same width
function cbt.CreateList()
	if ( IsValid( cbt.List ) ) then
		cbt.List:Remove()
	end
	
	local x, y = chat.GetChatBoxPos()
	local w, h = chat.GetChatBoxSize()


	local list = vgui.Create( "DListView" )
	list:SetPos( x, y + h + 5 )
	list:SetSize( w, 70 )
	list:AddColumn( "Commands" )
	
	cbt.List = list
end




-- gets a table of commands that match the full or partial text entered by the user
-- e.g., typing "Sla" would return a table with "slap" and "slay" (case insensitive) 
function cbt.GetMatchedCommands( word )
	word = word:lower():Trim()
	
	local matches  = {}
	local commands = cbt.Commands
	
	for i = 1, #commands do
		local command = commands[ i ]
		if ( command:sub( 1, word:len() ):lower() == word ) then
			matches[#matches+1] = command
		end
	end
	
	return matches
end




-- hook into GM:ChatTextChanged and listen for changes to the typed text
-- try to find commands that match what the user has typed and then
-- display them on the DListView
hook.Add( "ChatTextChanged", "Example", function( text )
	if ( not IsValid( cbt.List ) ) then cbt.CreateList() end
	
	local list = cbt.List
	
	local words = text:Split( " " )
	local word = words[1]
	local matches = {}
	
	if ( word ~= "" and #words == 1 ) then 
		matches = cbt.GetMatchedCommands( word )
	end
	
	list:Clear()
	
	if ( #matches > 0 ) then
		for k, v in pairs( matches ) do
			list:AddLine( v )
		end
		
		list:InvalidateLayout( true )
		list:SizeToContents()
		list:SetVisible( true )
	else
		list:SetVisible( false )
	end
end )




-- hide the DListView when the users closes their chatbox
hook.Add( "FinishChat", "CloseTooltips", function()
	if ( not IsValid( cbt.List ) ) then cbt.CreateList() end
	
	cbt.List:SetVisible( false )
end )


Ye I mean this thanks for your advice and help ^^