Gamemode.OnChatTab

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameOnChatTab
SyntaxGM:OnChatTab( String text )
DescriptionCalled when the local player presses TAB while having their chatbox opened.
ReturnsString
Lua StateNewerClient.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.OnChatTab]Gamemode.OnChatTab [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionHow it is defined in the base gamemode
Used onNewerClient.png
Code
function GM:OnChatTab( str )
 
	local LastWord
	for word in string.gmatch( str, "%a+" ) do
	     LastWord = word;
	end
 
	if (LastWord == nil) then return str end
 
	playerlist = player.GetAll()
 
	for k, v in pairs( playerlist ) do
 
		local nickname = v:Nick()
 
		if ( string.len(LastWord) < string.len(nickname) &&
			 string.find( string.lower(nickname), string.lower(LastWord) ) == 1 ) then
 
			str = string.sub( str, 1, (string.len(LastWord) * -1) - 1)
			str = str .. nickname
			return str
 
		end		
 
	end
 
	return str;
 
end
OutputAutocompletes player names in the server. IRC style.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox