Es.addons.registerSayFilter

From EventScripts Community Encyclopedia



Method: addons.registerSayFilter

Module: es
Class: (no class)
EventScripts version: 2.0

Method Overview

Table of Contents

Contents


Description

  • Hooks all text being said, and enables you to edit it before it is said, or block it

Arguments

  • userid - The userid of the player who said something
  • text - What they typed
  • teamonly - True: using team only chat, False: "Global" chat


Examples

  • Block All text chat:
import es
 
def load():
    es.addons.registerSayFilter(sayFilter)
 
def unload():
    es.addons.unregisterSayFilter(sayFilter)
    
def sayFilter(userid, text, teamonly):
    return (0,0,0) # return False values 
  • Block Teamonly Chat:
import es
 
def load():
    es.addons.registerSayFilter(sayFilter)
 
def unload():
    es.addons.unregisterSayFilter(sayFilter)
    
def sayFilter(userid, text, teamonly):
    if teamonly:
        return (0,0,0) # return False values
    else:
        return (userid, text, teamonly) # change nothing 
  • Make all text "global" (eg/ no teamonly)
import es
 
def load():
    es.addons.registerSayFilter(sayFilter)
 
def unload():
    es.addons.unregisterSayFilter(sayFilter)
    
def sayFilter(userid, text, teamonly):
        return (userid, text, False)

Notes

If your editing or reading the text, you may want to do

text = text.strip('"')
before hand.

MUST return a value for userid, text and teamonly otherwise a TypeError will occur ('NoneType' object is not iterable)

def sayFilter(userid, text, teamonly):
    if text == myCommand:
        es.msg('#lightgreen' + text)
        return (False, False, False)
    return (userid, text, teamonly) # Always ensure 3 values are returned 

See Also

</python>

blog comments powered by Disqus