AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Color print from language file (https://forums.alliedmods.net/showthread.php?t=85788)

-=hunter=- 02-16-2009 06:38

Color print from language file
 
Hello all! Can you help me with little problem?
I don't know how to print in chat color message from language file.
Example language file:
Code:

[en]
HELLO = ^x03Hello

Example script file:
Code:

new msg[100];
format(msg,99,"%L",LANG_PLAYER,"HELLO");
message_begin( MSG_ONE, svc_saytext, { 0, 0, 0 }, plr );
write_byte( plr );
write_string( msg );
message_end( );

I can't understand but prints "^x03Hello". I want that prints "Hello" in blue color.

AntiBots 02-16-2009 07:18

Re: Color print from language file
 
you have id you dont need to do LANG_PLAYER


format(msg, 99, "^x03%L", plr,"HELLO");

PS: in txt you cant put ^x03 you must put in the format

-=hunter=- 02-16-2009 08:03

Re: Color print from language file
 
Quote:

Originally Posted by AntiBots
PS: in txt you cant put ^x03 you must put in the format

Yes, this is a problem.
If i put ^x03 in format(...,...,...) then server prints fine color text. If i put ^x03 in language file then server prints simple(not color) text :(
There is a magic method to solve this problem (maybe with help of other function)? :)

AntiBots 02-16-2009 08:56

Re: Color print from language file
 
with ^^x03 you test?

-=hunter=- 02-16-2009 09:21

Re: Color print from language file
 
I was wrong in first post - server printed x03Hello.
I tested ^^x03, but server prints ^x03 :(

-=hunter=- 02-18-2009 06:43

Re: Color print from language file
 
I think that this is a bug of amxmodx so ^n works from lang file but ^x not works.
I solved this problem, but this method not good.
If in lang file to use ,example, ^^x03 then
in script should to add:
Code:

while( contain (msg, "^^x03" ) != -1 )
            replace(msg,99, "^^x03", "^x03" )


Arkshine 02-18-2009 06:51

Re: Color print from language file
 
Why would you want such replacement to define color ?

It would be more easy to use !g for green color, !t for team color etc.. ( or anything in this way ) Why do you bother with ^x03 and such. -_-

-=hunter=- 02-18-2009 07:22

Re: Color print from language file
 
arkshine
I tested !g but not works for me :(
Can you to print your code with !g ? Please

Arkshine 02-18-2009 07:36

Re: Color print from language file
 
Before sending your message just replace the code.

replace(msg,99, "!g", "^x03" )

-=hunter=- 02-18-2009 07:42

Re: Color print from language file
 
Thanks :)


All times are GMT -4. The time now is 16:52.

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