AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [Dyn Native] ColorChat v0.3.2 (04 jul 2013) (https://forums.alliedmods.net/showthread.php?t=94960)

ConnorMcLeod 06-17-2009 17:49

[Dyn Native] ColorChat v0.3.2 (04 jul 2013)
 
16 Attachment(s)
Note that this has been integrated to amxx 1.8.3 core since build 185
Usage here : https://forums.alliedmods.net/showpo...&postcount=232

ColorChat Native




.: Description :.


Colorchat native that can be used by any plugin.

Pro : Instead of using colorchat include that duplicate code in every single plugin in which you use it, use a single plugin to handle colorchat.
Con : Should be a little slower than include, but as you don't plain to send it 1000 times per second, it's not a big deal.

Note : supports ML.



.: Natives :.
  • client_print_color(index, sender, const fmt[], any:...)
  • register_dictionary_colored(const filename[])
    Same as register_dictionary, but transform !g, !t and !n into colors code
    so you can use same ML Keys in normal chat or hudmessage or whereever you want


.: How to use ? :.


You have to start each text with ^4 or ^3 or ^2 or ^1 (or !t, !g, !n in ML files).

In .sma, use ^4 to display green, ^1 to display normal color (yellow by default), and ^3 to display the specified color (2nd arg).
In multilanguage files, use !g to set following text to green, !n to set following text to normal player chat color (yellow by default), and !t to set following text to the color passed in second argument.

Colors for second arg are : a_player_index (use the specified player team color), Red, Blue and Grey.
Those color are applied by ^3 or !t tag.

I've added support for ColorChat stock, all you have to do is to replace at the top of .sma the line :
Code:
#include <colorchat>

with
Code:
#include <chatcolor>



.: Use Example :.


default adminchat edited to use color : http://forums.alliedmods.net/showthr...730#post851730

[img]http://img35.**************/img35/6019/bkzaztecbhop0008.png[/img]




.: Credits :.


Quim, Reymon, Stupok.



__________________
.: Stock Version :.

DON'T USE STOCK VERSION, SEEMS TO HAVE PROBLEM WITH ML Thanks to Nextra who found my mistake, it should works fine now.
If you prefer to use a stock version that doesn't need an extra plugin to work, follow the following link :> Here <




__________________
.: Module Version :.


If you prefer to use a module version, real native is faster, follow the following link :Module Version




__________________

AcidoX 06-17-2009 17:53

Re: Native : ColorChat
 
Nice work man! :)

stupok 06-18-2009 00:50

Re: Native : ColorChat
 
Rockin'! :up:

I think I will finally start using colorchat now :mrgreen:

It looks great, I just noticed two things:

Quote:

Colors for second arg are : DontChange (let original player team color), Red, Green Blue and Grey.
Code:

while( replace() )
->
replace_all()

Knowing your attention to detail, there is probably a good reason to use while() instead of replace_all().

ConnorMcLeod 06-18-2009 00:56

Re: Native : ColorChat
 
Thanks for the blue color :)

Was first using replace_all, but that one check in every loop if string contain 'what[]', store position in string and check is there is enough place left to replace (+ this stock fails as you can get errors with it when you don't set good len params...). Since i'm replacing 2 chars with 2 chars, there shouldn't be any place problem. There could be a better stock though.
From what i've tried, pass directly ^3 or ^4 in calling native works, but from what i remember when was using color chat in the past, some times when multi formating, it is altered, i haven't made enough tests yet to know if this replace stuff can be removed, gonna try to put ^4 in ML keys to see what happen.

Exolent[jNr] 06-18-2009 01:02

Re: Native : ColorChat
 
The problem with "^4" or the others in the ML is that it doesn't read '^' as the escape character. It reads it as "^^4".
So, you can do it with "!g" or "^4" or whatever you prefer, but you will need to end up using replace() to fix it.

ConnorMcLeod 06-18-2009 01:08

Re: Native : ColorChat
 
Quote:

Originally Posted by Exolent[jNr] (Post 851340)
The problem with "^4" or the others in the ML is that it doesn't read '^' as the escape character. It reads it as "^^4".

Ok, so the problem is with ML, so, i keep that !g code stuff, gonna just use ^4 in strings where ML is not used.

[EDIT]

!g code replacement is now only for ML and is proceeded at map start.

senecas 06-18-2009 02:56

Re: Native : ColorChat
 
this may come into conflict with Zombie_plague code.

cuz of " Send_TeamInfo(id, MSG_ONE_UNRELIABLE, g_szTeamName[iColor]) "
user's team on scoreboard will be screwed up when we use GREY(or RED, BLUE, too)

Alucard^ 06-18-2009 05:36

Re: Native : ColorChat
 
that i understand... i have to add !t !g and/or !n into the .sma of my plugins right?

good plugin i think...

and one more question...

its posible to force a color like "red, blue or grey"? for example i want to put a red message for TTs, CTs, and SPECS too...

its posible?

crazyeffect 06-18-2009 06:11

Re: Native : ColorChat
 
C... C... Cool!

ConnorMcLeod 06-18-2009 07:07

Re: Native : ColorChat
 
Quote:

Originally Posted by Alucard^ (Post 851453)
that i understand... i have to add !t !g and/or !n into the .sma of my plugins right?

You [edit]canHAVE TO[/edit] directly pass ^1, ^3 and ^4 in .sma. In other files as ML files you have to use !g etc..

Quote:

Originally Posted by Alucard^ (Post 851453)
its posible to force a color like "red, blue or grey"? for example i want to put a red message for TTs, CTs, and SPECS too...

its posible?

Yes, just pass the color you want, and then use !t.
Color will be user team color if you specify player id + use color = DontChange.


All times are GMT -4. The time now is 00:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.