Custom chat tag

Release your plugins here!
cssbestrpg
Senior Member
Posts: 309
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Custom chat tag

Postby cssbestrpg » Mon Jan 11, 2021 3:36 pm

Download: https://github.com/srpg/chat_tag
Chat commands: color color name and tag tagname

For example color red changes you tag color to red and tag example changes tag to ['Example']Playername:message in chat
User avatar
satoon101
Project Leader
Posts: 2698
Joined: Sat Jul 07, 2012 1:59 am

Re: Custom chat tag

Postby satoon101 » Wed Oct 20, 2021 2:17 pm

I have a couple tips for you, if you are interested. First, line 303 will error in CS:GO since the variable naco is only defined in the else clause (variable is named team_color, which does seem more appropriate anyway, for CS:GO):
https://github.com/srpg/chat_tag/blob/m ... #L297-L303

I would definitely recommend using proper names for variables instead of naco/chco. As line 7 of the Zen of Python states: "Readability counts".

I also created a similar plugin a while back:
https://github.com/satoon101/ChatPrefix

My plugin doesn't allow tags to be changed on the fly, so there are obvious differences between the two plugins. It hooks the usermessage itself instead of using a SayFilter, which will catch all of the intended recipients and the specific message formatting with location (when applicable). Feel free to use it as a guide and ask any questions if you have any.

I would also highly recommend using SayCommand or TypedSayCommand instead of a SayFilter for tag/color. Here is a more detailed tutorial about TypedSayCommand:
http://wiki.sourcepython.com/developing ... mands.html

If you need any examples of SayCommand, just search the forums.

I would also recommend building your menu once instead of every single time someone uses the 'color' command. Also, definitely look into f-strings in Python, they're much cleaner than using %s everywhere.
Image
cssbestrpg
Senior Member
Posts: 309
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: Custom chat tag

Postby cssbestrpg » Wed Oct 20, 2021 4:54 pm

satoon101 wrote:I have a couple tips for you, if you are interested. First, line 303 will error in CS:GO since the variable naco is only defined in the else clause (variable is named team_color, which does seem more appropriate anyway, for CS:GO):
https://github.com/srpg/chat_tag/blob/m ... #L297-L303

I would definitely recommend using proper names for variables instead of naco/chco. As line 7 of the Zen of Python states: "Readability counts".

I also created a similar plugin a while back:
https://github.com/satoon101/ChatPrefix

My plugin doesn't allow tags to be changed on the fly, so there are obvious differences between the two plugins. It hooks the usermessage itself instead of using a SayFilter, which will catch all of the intended recipients and the specific message formatting with location (when applicable). Feel free to use it as a guide and ask any questions if you have any.

I would also highly recommend using SayCommand or TypedSayCommand instead of a SayFilter for tag/color. Here is a more detailed tutorial about TypedSayCommand:
http://wiki.sourcepython.com/developing ... mands.html

If you need any examples of SayCommand, just search the forums.

I would also recommend building your menu once instead of every single time someone uses the 'color' command. Also, definitely look into f-strings in Python, they're much cleaner than using %s everywhere.

Thanks for the tips, i just updated the code fix for csgo.
I also changed code use f-strings instead use %s.
Here can see the commit
cssbestrpg
Senior Member
Posts: 309
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: Custom chat tag

Postby cssbestrpg » Sat Oct 23, 2021 7:26 pm

Update:
- Fixed sending too many times a message when is more than 1 player at the server.
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: Custom chat tag

Postby daren adler » Tue Oct 26, 2021 10:33 pm

How to change color of players name ?, like {EXILE}™GuitarSlayer in red.
cssbestrpg
Senior Member
Posts: 309
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: Custom chat tag

Postby cssbestrpg » Wed Oct 27, 2021 4:34 am

daren adler wrote:How to change color of players name ?, like {EXILE}™GuitarSlayer in red.

You can't, i didn't make players name color changeable.
Only things can change is tag and tag color
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: Custom chat tag

Postby daren adler » Wed Oct 27, 2021 6:49 am

OK, np, works good.
cssbestrpg
Senior Member
Posts: 309
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: Custom chat tag

Postby cssbestrpg » Wed Oct 27, 2021 7:28 am

Does the database save correctly in hl2dm?
Since it only get saved when player disconnect and round end.
If doesn't save correctly then i can make update to ensure to save database.
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: Custom chat tag

Postby daren adler » Wed Oct 27, 2021 2:59 pm

I do know that when i leave and come back my stuff stays the same. other then that i dont know,,i do know that i got no menu that comes up or anything
cssbestrpg
Senior Member
Posts: 309
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: Custom chat tag

Postby cssbestrpg » Wed Oct 27, 2021 3:35 pm

daren adler wrote:I do know that when i leave and come back my stuff stays the same. other then that i dont know,,i do know that i got no menu that comes up or anything

I just made update that ensures now when player change tag/tag color the database is saved.
In github can download the update i just made

Edit:
I just noticed my small mistake, that i just fixed
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: Custom chat tag

Postby daren adler » Wed Oct 27, 2021 10:29 pm

OK. ty

Return to “Plugin Releases”

Who is online

Users browsing this forum: No registered users and 4 guests