Raised This Month: $12 Target: $400
 3% 

Solved Colorchat bug in latest version of AmxModX 1.8.3


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hembi
Member
Join Date: Mar 2013
Location: Hungary
Old 07-20-2018 , 21:57   Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #1

Hello!

I would like to report a problem of the integrated ColorChat in the 1.8.3-dev-git5169.

I modified some plugins from this version of AmxModX like adminhelp, mapsmenu, etc., because I would like to display colored info messages to the players.
When I modified the help messages and added some color symbols to the lang file, the messages stayed in normal colors and the symbols are replaced with a space char.
I found the problem, the sentence first character was an "Í" after I changed to "I" the coloring worked, so there is a problem with the UTF-8 characters.

I've been wasting a lot of my time, because I do not know about the show_activity_key function which is finally a simple client_print. This function can not print colored messages and also replace the color symbols from the lang with a space. It would be nice if you can add a new show_activity_key_colored function and some other member like me will pay more attention to this function.

Last edited by Arkshine; 07-28-2018 at 02:37.
Hembi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-21-2018 , 15:18   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #2

Show your code so we can see what's going on.
__________________

Last edited by OciXCrom; 07-21-2018 at 16:09.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Hembi
Member
Join Date: Mar 2013
Location: Hungary
Old 07-22-2018 , 09:23   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #3

You can check it:
Code:
Code:
@Task_DisplayMessage(id)
{
	client_print_color(id, print_chat, "%L", id, "TYPE_HELP", HelpCommand, SearchCommand);

	if (CvarTimeLimit > 0.0)
	{
		new timeleft = get_timeleft();

		if (timeleft > 0)
		{
			client_print_color(id, print_chat, "%L", id, "TIME_INFO_1", timeleft / 60, timeleft % 60, CvarNextmap);
		}
		else if (CvarNextmap[0] != EOS)
		{
			client_print_color(id, print_chat, "%L", id, "TIME_INFO_2", CvarNextmap);
		}
	}
}
Lang:
Quote:
TYPE_HELP = Írj '^4amx_help^1'-et a konzolba hogy láthasd a parancsokat.
Hembi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-22-2018 , 16:31   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #4

If you want to add colors to the show_activity() functions, I suggest you use the cromchat include file - https://forums.alliedmods.net/showthread.php?t=295046

After downloading the file, you can replace ALL chat messages of that type in just 2 simple steps:

1. Add #include <cromchat> in the plugin.
2. Add the color codes in the plugin's lang file.

And you're done.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-23-2018 , 13:11   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #5

This is not how you use this native, please read the documentation: https://www.amxmodx.org/api/amxmodx/client_print_color
__________________
Arkshine is offline
Hembi
Member
Join Date: Mar 2013
Location: Hungary
Old 07-23-2018 , 18:00   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
This is not how you use this native, please read the documentation: https://www.amxmodx.org/api/amxmodx/client_print_color
Thank you for the link, I checked it.
Here is a short example code:
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Test ColorChat"
#define VERSION "1.0"
#define AUTHOR "Hembi"


public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	
	register_dictionary("test.txt");
	register_clcmd("say test", "print_colored_message_utf8");
	register_clcmd("say test2", "print_colored_message_normal");
	register_clcmd("say test3", "print_colored_message_asdescribed");
}

public print_colored_message_utf8(id)
{
	client_print_color(id, id, "%L", id, "TEST_LANG"); //PlayerID who will see the message, PlayerID who send it, message (lang place-holder), PlayerID to get the user lang setting, lang-key.
}

public print_colored_message_normal(id)
{
	client_print_color(id, id, "%L", id, "TEST_LANG2"); //PlayerID who will see the message, PlayerID who send it, message (lang place-holder), PlayerID to get the user lang setting, lang-key.
}

public print_colored_message_asdescribed(id)
{
	client_print_color(id, id, "%L", id, "TEST_LANG3"); //PlayerID who will see the message, PlayerID who send it, message (lang place-holder), PlayerID to get the user lang setting, lang-key.
}
The lang file:
Code:
[hu]
TEST_LANG = Írj '^4test^1'-et a chatbe, hogy színes szöveget láss.
TEST_LANG2 = Irj '^4test^1'-et a chatbe, hogy színes szöveget láss.
TEST_LANG3 = ^3Írj '^4test^1'-et a chatbe, hogy színes szöveget láss.
The outputs are:
Quote:
test: Írj ' test '-et a chatbe, hogy színes szöveget láss.
test2: Irj 'test'-et a chatbe, hogy színes szöveget láss.
test3: Írj 'test'-et a chatbe, hogy színes szöveget láss.

As you can see only the first one is wrong which start a special letter.
The last sentence also start with a special letter, but I started the line with a color code as described in the native examples.
In my opinion it is okay to work that way, but it does not work properly. I do not see any warning/note in the native description that the message must be started with a color code and the message which start with a normal letter does not need this modification.
Hembi is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-24-2018 , 09:45   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #7

Internally it already inserts ^1 at the start of a string otherwise the color won't work, yeah, there was a bug with a check and unicode characters (https://github.com/alliedmodders/amxmodx/pull/504).

Thanks for reporting, should be fixed in the latest build.
__________________
Arkshine is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-24-2018 , 12:55   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #8

About using colors with show_activity - I submitted a pull request for a complete overhaul of those functions - https://github.com/alliedmodders/amxmodx/pull/505

For now you can use cromchat.inc as I mentioned before.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Hembi
Member
Join Date: Mar 2013
Location: Hungary
Old 07-26-2018 , 12:57   Re: Colorchat bug in latest version of AmxModX 1.8.3
Reply With Quote #9

Quote:
Originally Posted by Arkshine View Post
Internally it already inserts ^1 at the start of a string otherwise the color won't work, yeah, there was a bug with a check and unicode characters (https://github.com/alliedmodders/amxmodx/pull/504).

Thanks for reporting, should be fixed in the latest build.
Thank you Arkshine!

OciXCrom, thank you your include works properly and does not provide this bug. Thanks the pull request and you work with it too.
Hembi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:48.


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