player_say hook?

Please post any questions about developing your plugin here. Please use the search function before posting!
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

player_say hook?

Postby Tuck » Sun May 11, 2014 11:17 am

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
-Tuck
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun May 11, 2014 1:45 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun May 11, 2014 1:51 pm

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 ?
-Tuck
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun May 11, 2014 1:58 pm

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 44 guests