Print to client console?
Posted: Wed Jan 13, 2016 3:31 pm
by decompile
Hey,
I modified the chat system to give players different chatranks with different colors for my ranking system with SayText2 but I noticed that the console is empty when a player writes something. (Ingame works everything fine, except the chat message into the console)
So how can I actually send something to a clients console? Do i need to use PlayerIter too?
Posted: Wed Jan 13, 2016 3:38 pm
by necavi
Posted: Wed Jan 13, 2016 10:11 pm
by decompile
Thank you, works!
But before I wanna use that im just asking if its kinda possible that for example SayText2 color codes can be stripped for the console?
Code: Select all
FFFFFFfix pls [FF0000ECN Frag [LF1]FFFFFF] : FFFFFFNice record, dude!
I remember that for example es(c).tell it stripped all the color codes for the console
Syntax: Select all
# > Find Colors
re1='(#)' # Any Single Character 1
re2='(\\d+)' # Integer Number 1
re3='(,)' # Any Single Character 2
re4='(\\d+)' # Integer Number 2
re5='(,)' # Any Single Character 3
re6='(\\d+)' # Integer Number 3
rg = re.compile(re1+re2+re3+re4+re5+re6,re.IGNORECASE|re.DOTALL)
m = re.findall(rg,message)
Posted: Thu Jan 14, 2016 7:26 pm
by Ayuto
ESC never stripped any colors, because it never sent them to the console. The (non-complete) code you have posted is used to replace occurences like #255,0,0 with the proper color code. Try this:
Syntax: Select all
import re
RE_STRIP_COLORS = re.compile(r'\x07[a-fA-F0-9]{6}|\x08[a-fA-F0-9]{8}')
def strip_colors(msg):
"""Strip all colors starting with \x07 or \x08 from the given string."""
return RE_STRIP_COLORS.sub('', msg)
Posted: Fri Jan 15, 2016 12:53 pm
by decompile
Thank you, works.