Print to client console?

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Print to client console?

Postby decompile » Wed Jan 13, 2016 3:31 pm

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?
necavi
Developer
Posts: 129
Joined: Wed Jan 30, 2013 9:51 pm

Postby necavi » Wed Jan 13, 2016 3:38 pm

decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Wed Jan 13, 2016 10:11 pm

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)
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Thu Jan 14, 2016 7:26 pm

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)
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Fri Jan 15, 2016 12:53 pm

Thank you, works.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 132 guests