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.

Contrenature 06-18-2009 10:59

Re: Native : ColorChat
 
ConnorMcLeod, i need example, have some info plugins about shopping!
What i doo, i put in sma include chatcolor line.. like amxmodx, engine, fakemeta and other, yea.
Then, i have that code, some line:

client_print_color(id,print_chat, "[AMXX] ^3SMS Code - ^4Bla Bla Bla %s Server - to number blablabla, 1 SMS",name)

Need use "^3" or simple ^3 before text.
Correct me please, if i have mistakes.. :oops::)

ConnorMcLeod 06-18-2009 11:08

Re: Native : ColorChat
 
2nd arg is the color that will show when you use ^3 or !t, not the print location as you can only display it in chat.

Code:
client_print_color(id, DontChange, "[AMXX] ^3SMS Code - ^4Bla Bla Bla %s Server - to number blablabla, 1 SMS", name)

Contrenature 06-18-2009 12:32

Re: Native : ColorChat
 
Thank you werry mutch :) its work :)
I love you!

ConnorMcLeod 06-18-2009 15:17

Re: Native : ColorChat
 
4 Attachment(s)
Example on how to use it with default adminchat retailed.

Don't use the Get Plugin link
This plugin is just an example, the web compiler won't give you a working plugin, compile it locally if you want to use it.


+ Added to default adminchat, for admins, say #c text, where c can be r, b, g for the 3 teamx colors.

Eugene. 06-21-2009 05:41

Re: [Native] ColorChat
 
thanks, good job man.

ConnorMcLeod 06-23-2009 01:54

Re: [Native] ColorChat
 
Updated.

Added comments through code, hope color change when id=0 is fixed.

xPaw 06-23-2009 04:22

Re: [Native] ColorChat
 
I would make like this
PHP Code:

public client_putinserver(id)
{
    if( !
is_user_botid ) && !is_user_hltvid ) )
        
g_bConnected[id] = true;


So we dont need 2nd bool for bots :)

PHP Code:

    if( bColorChange )
    {
        
// if no color passed, set 1st color to green
        
szMessage[0] = 0x03
    
}
    else
    {
        
// if color specified, set 1st color to team color
        
szMessage[0] = 0x04
    


Wrong comments :mrgreen: change places

ConnorMcLeod 06-23-2009 10:38

Re: [Native] ColorChat
 
1. No, so bots are still usable as reference for team change color.
2. yes

-edit-
v0.1.0
Now fixed colorchange when id=0 and ML was used.
Reason was i was altering TeamInfo once by MSG_BROADCAST, then send multiple MSG_ONE_UNRELIABLE. In fact, that way doesn't work for "some" reasons, now send as many TeamInfo msgs as SayText msgs num.

Asplii 06-23-2009 14:46

Re: [Native] ColorChat v0.1.0
 
Can you add only Grey, Red and Blue colors, it have been nice if you do that:)

ConnorMcLeod 06-23-2009 15:38

Re: [Native] ColorChat v0.1.0
 
Quote:

Originally Posted by Asplii (Post 855268)
Can you add only Grey, Red and Blue colors, it have been nice if you do that:)

I don't understand, all you can do with colorchat can be done with this plugin.

supergreg 06-23-2009 16:56

Re: [Native] ColorChat v0.1.0
 
Thank you, it is very useful and works very well, both in the modified adminchat and in my own plugin, excellent!

Only one very small thing; It is confusing that this thread is called colorchat, and you refer to the plugin as "colorchat", but doing #include <colorchat> will not work as the file itself is called chatcolor.inc - I just wanted to let you know before everyone starts using it - if you want to change this filename it should be now before everyone starts using it ;)

Hawk552 08-14-2009 15:21

Re: [Native] ColorChat v0.1.0
 
I find this rather useless and I don't see why this was made into a plugin. Why didn't you just post this in the code snippets section? I don't really want to unapprove this but I also find it difficult to approve. I'm going to ask BAILOPAN about this case.

ConnorMcLeod 08-14-2009 15:55

Re: [Native] ColorChat v0.1.0
 
Because of all this plugins using that colorchat include so that code is duplicated in all of them.
Anyway, the plugin is released, feel free to unapprove.

supergreg 08-14-2009 18:24

Re: [Native] ColorChat v0.1.0
 
I really like this, I have included it into several of the plugins we use on our servers, as well as the ones I hack away at myself. I really like the idea of collecting widely used functions like these in separate files+methods. Thanks a bunch!

I have one question regarding the adminchat on page 2; When regular players use "say_team @", their message is now displayed BOTH in regular teamchat as well as amxchat (picture). Is this caused by us running ultimate_chat where admin is set to see all text, or is this a bug that should be fixed? We didn't have this problem before switching to the adminchat on page 2 here, and have been running ultimate_chat all along.

ConnorMcLeod 08-15-2009 03:15

Re: [Native] ColorChat v0.1.0
 
This is cause by ultimate chat, which one of the plugin have you declared in first in plugins.ini ? (Should be adminchat to avoid that bug)

Hawk552 08-15-2009 16:48

Re: [Native] ColorChat v0.1.0
 
I didn't really get a useful reply from BAILOPAN, although he stated that he agrees with me in that this would be useful as a snippet.

For this reason, I have decided to move this plugin to the code snippets section. I am also marking it as approved (so it appears in your plugin list).

in0x0rable7 08-19-2009 05:31

Re: [Native] ColorChat v0.1.0
 
I'm getting error:
"L 08/19/2009 - 12:25:28: [AMXX] Plugin "adminchat.amxx" failed to load: Module/Library "chatcolor" required for plugin. Check modules.ini."
when I start my server. I don't know what could cause it. adminchat.amxx is the plugin from 2nd page in this topic. I completed it (.sma) locally (without any errors) and chatcolor.inc is in include folder.

xPaw 08-19-2009 06:50

Re: [Native] ColorChat v0.1.0
 
Get chatcolor.sma too...

in0x0rable7 08-19-2009 07:16

Re: [Native] ColorChat v0.1.0
 
Thanks, my mistake.
This stuff would be really great if another amxx plugin wouldn't be neccesary.

supergreg 09-10-2009 21:47

Re: [Native] ColorChat v0.1.0
 
I'm using this to print to amx_chat if the connecting user is an admin.
Problems arise when users have one of the color triggers as part of their nicks, for instance "r!tual is an admin" shows up as rual is an admin.
So I need to escape that, I am just wondering how to escape only the nicks/user input while still maintaining my intended colorchange triggers.

Any help appreciated.

Exolent[jNr] 09-10-2009 21:52

Re: [Native] ColorChat v0.1.0
 
Well, the easiest solution is to replace all the !t with !!t, and the same pattern for the others.

supergreg 09-13-2009 10:12

Re: [Native] ColorChat v0.1.0
 
Thanks Exolent, I tried the following which as this screenshot shows did not stop the !t from being interpreted as a color shift trigger. Posting the code I use to print these lines. Any help appreciated.

PHP Code:

formatex(g_szMessageBIG_BUFF"%s is an admin, webnick: %s"colorPrintEscape(g_szNicks[id]), g_szWebNicks[id]);
 
adminMsg(g_szMessage);

colorPrintEscape(var[])
{
    new 
cleanVar[MED_BUFF 1];
    
copy(cleanVarMED_BUFF, var);
    
replace_all(cleanVarMED_BUFF"!t""!!t");
    
replace_all(cleanVarMED_BUFF"!g""!!g");
    
replace_all(cleanVarMED_BUFF"!n""!!n");
    return 
cleanVar;
}

adminMsg(message[])
{
    new 
players[32], numi;
    
get_players(playersnum);

    
format(messageBIG_BUFF"^1(^4ADMINS^1): %s"message);
    for(
0numi++)
    {
        new 
player players[i];
        if(!
is_user_bot(player) && access(playerADMIN_CHAT)) {
            
client_print_color(playerDontChangemessage);
        }
    }
    return 
true;



Exolent[jNr] 09-13-2009 13:44

Re: [Native] ColorChat v0.1.0
 
Hmm. I guess I wasn't thinking clearly to catch that.
I guess you are going to have to modify the ColorChat function to fix this.

I suggest removing the !x syntax from the function, and then you can remember to use ^1, ^3, and ^4 yourself.
Here is the relationship:
!n = ^1
!t = ^3
!g = ^4

thegodfather420 10-12-2009 22:40

Re: [Native] ColorChat v0.1.0
 
Hey Connor I am having trouble installing this plugin. I think this is a great plugin and would like to use it.

*Have put in plugins folder and scripting folder. and enabled it in plugins.ini. What else do I need to do. Thankyou, Steve

ot_207 10-13-2009 03:01

Re: [Native] ColorChat v0.1.0
 
This should be installed as a normal plugin.
Compile the sma, place the amxx file in plugins folder, after that add it in plugins.ini.
Also you need to put that include file (chatcolor.inc) in scripting/include folder.
After this you are prepared to make plugins using this extension.

eltipo14 10-18-2009 16:43

Greetings, ConnorMcLeod
 
Greetings, ConnorMcLeod. I wonder how I could do to put color messages that come in chat, as an example: if I have the plugin high_ping_kicker, chat messages in the default color come in yellow, if I want to leave the letters in colors or each word in a single color, as it could, that you do with all the plugins so you can differentiate them in chat to have the colors in a certain order, because they come without applying any color. This would facilitate a more pleasant view of chat, and for persons with visual problems would help them avoid straining the eyes. Thanks beforehand for any help.

ot_207 10-18-2009 16:45

Re: [Native] ColorChat v0.1.0
 
client_print(id, print_chat, ......)
Change into
client_print_color(id, Whatcoloryouwant, .....)

eltipo14 10-18-2009 17:26

Re: [Native] ColorChat v0.1.0
 
Quote:

Originally Posted by ot_207 (Post 966362)
client_print(id, print_chat, ......)
Change into
client_print_color(id, Whatcoloryouwant, .....)

Thank you for a prompt response, Where you say Whatcoloryouwant, ahy probe positioning, color letters: example: write, compile and gives me error, so I will put the code, so please explain to me how would I explain to a child.
Testing and told me, but I think I learned not to make, to compile gave me error.
piece of code :

public showWarn (param [])
client_print (param [0], print_chat,&quot; Players with ping above% D will be kicked!&quot;, get_cvar_num (&quot;amx_hpk_ping&quot;))

ConnorMcLeod 10-18-2009 17:54

Re: [Native] ColorChat v0.1.0
 
Please put your code between [ php ] tags or just remove it.

The answer is in first post :
Quote:

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

eltipo14 10-18-2009 18:41

Re: [Native] ColorChat v0.1.0
 
1 Attachment(s)
Thank ConnorMcLeod and apology step you file, you can have if I take a hand, just want to change its color, you could tell me you need to amend or include this code, to put color messages that will run in chat, so you'll know who to ask for more .


All times are GMT -4. The time now is 18:40.

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