Page 1 of 1

player_say hook?

Posted: Sun May 11, 2014 11:17 am
by Tuck
I think i read about this somewhere, however i cannot find it anymore, looked through the forums a half hour now searching for all kinda weird terms :/

Would be great with a link for the example or just a quick example in a reply

player_say hook: as in when people talk we can choose to display it or not.

thanks in advance

Posted: Sun May 11, 2014 1:45 pm
by satoon101
You mean a SayFilter?

Syntax: Select all

from commands.say import SayFilter

@SayFilter
def my_say_filter(playerinfo, teamonly, command):
if <something>:

# Block the message from being displayed in chat
return False

Posted: Sun May 11, 2014 1:51 pm
by Tuck
That was exactly it thanks, i never though of "filter" :/

Is there anyway to change the text as in es u had to return the args again, or none (or something like that)

Or would it just be returning False to all and using saytext to display ?

Posted: Sun May 11, 2014 1:58 pm
by satoon101
You can use SayText(2) to display your own message. You can also do what ES does, and call the "say" command again:

Syntax: Select all

from commands.say import SayFilter
from engines.server import EngineServer
from players.helpers import edict_from_playerinfo

@SayFilter
def my_say_filter(playerinfo, teamonly, command):
if <something>:

command = 'say_team' if teamonly else 'say'

# Force the player to say something
EngineServer.client_command(edict_from_playerinfo(
playerinfo, '{0} This is some new text'.format(command))

# Block the message from being displayed in chat
return False


The plugin itself does not support returning a new value and calling the client command on its own (nor will it). You must do this yourself.