Remove Unsafe Characters
Posted: Tue Aug 23, 2016 9:39 am
Hey,
Im currently on thinking about adding a "player connect/disconnect announcer" and thought about what fixes are needed since players can completly modify their names.
After abit of google research I created a function which returns a save name which i can use in Saytext2
I havent tested it yet. + I dont know what happens when a player joins with "%s"
Im currently on thinking about adding a "player connect/disconnect announcer" and thought about what fixes are needed since players can completly modify their names.
After abit of google research I created a function which returns a save name which i can use in Saytext2
Syntax: Select all
unsafeLetters = [r"\a", r"\b", r"\f", r"\n", r"\r", r"\t", r"\v", r"%s"]
def getSaveString(string):
""" Strips colorcodes and newlinecharacters"""
newstring = ""
for x in string:
if ord(x) > 8:
newstring += x
newstring = repr(newstring)
for x in unsafeLetters:
newstring = newstring.replace(x, r"\\"+x)
newstring = eval(newstring)
return newstring
I havent tested it yet. + I dont know what happens when a player joins with "%s"