GM:PlayerSay

From Garry's Mod
Jump to: navigation, search
 GM:PlayerSay( )

Contents

Description

Called when a player dispatched a chat message. For the clientside equivalent, see GM:OnPlayerChat.

Arguments

Player sender

The player which sent the message.

Arguments

string text

The message's content

Arguments

boolean teamChat

Is team chat?

Returns

string

What to show instead of original text.
Set to "" to stop the message from displaying.

Examples

Example

Will put "[Global]" in front of the players message if they type "/all".

hook.Add("PlayerSay", "PlayerSayExample", function( ply, text, team )
	-- Make the chat message entirely lowercase
	if ( string.lower( text ) == "/all" ) then
		return "[Global] " .. string.sub( text, 5 ) -- add [Global] in front of the players text then display
	end
end)


Examples

Example

Create a chat command to kill the player who said it

hook.Add( "PlayerSay", "Killurself", function(ply, text, public)
	if ( string.lower( text ) == "!kill" ) then
		ply:Kill()
		return ""
	end
end)


Personal tools
Navigation