AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   custom colour (https://forums.alliedmods.net/showthread.php?t=153845)

zombieplague 03-30-2011 02:43

custom colour
 
is it possible to make your own custom color like red for an example without using any include just like stock.

hornet 03-30-2011 02:51

Re: custom colour
 
Custom colour for what?

EDIT: Are you talking about colour chat?

mottzi 03-30-2011 04:00

Re: custom colour
 
Just search, there are a few stocks.

drekes 03-30-2011 07:50

Re: custom colour
 
I use this:
PHP Code:

fnColorPrint(id, const szMsg[], {FloatSqlResult,_}:...)
{
    static 
iMsgSayTextiMaxPlayers;
    if(!
iMsgSayText)
        
iMsgSayText get_user_msgid("SayText");
    
    if(!
iMaxPlayers)
        
iMaxPlayers get_maxplayers();
        
    static 
Buffer[190], Buffer2[192], iPlayer
    formatex
(Buffer2charsmax(Buffer2), "^x04[%s] ^x01%s"g_szPrefixszMsg);
    
vformat(Buffercharsmax(Buffer), Buffer23);
    
    if(!
iPlayer)
    {
        while(
iPlayer <= iMaxPlayers)
        {
            if(
is_user_connected(++iPlayer))
                break;
        }
    }
    
    
message_begin(id MSG_ONE_UNRELIABLE MSG_ALLiMsgSayText_iPlayer);
    
write_byte(iPlayer);
    
write_string(Buffer);
    
message_end();



zombieplague 03-30-2011 08:01

Re: custom colour
 
how to make red and blue colour ?? i don't want to use team colour. i don't want colourchat. somehow just colour code for my stuff.

drekes 03-30-2011 08:30

Re: custom colour
 
You could change his team, print the msg, and set him back to his original team.
I don't know if there's another solution.

Exolent[jNr] 03-30-2011 17:53

Re: custom colour
 
Quote:

Originally Posted by drekes (Post 1441620)
I use this:
PHP Code:

fnColorPrint(id, const szMsg[], {FloatSqlResult,_}:...)
{
    static 
iMsgSayTextiMaxPlayers;
    if(!
iMsgSayText)
        
iMsgSayText get_user_msgid("SayText");
    
    if(!
iMaxPlayers)
        
iMaxPlayers get_maxplayers();
        
    static 
Buffer[190], Buffer2[192], iPlayer
    formatex
(Buffer2charsmax(Buffer2), "^x04[%s] ^x01%s"g_szPrefixszMsg);
    
vformat(Buffercharsmax(Buffer), Buffer23);
    
    if(!
iPlayer)
    {
        while(
iPlayer <= iMaxPlayers)
        {
            if(
is_user_connected(++iPlayer))
                break;
        }
    }
    
    
message_begin(id MSG_ONE_UNRELIABLE MSG_ALLiMsgSayText_iPlayer);
    
write_byte(iPlayer);
    
write_string(Buffer);
    
message_end();



That could produce false results when printing to 1 player for the first time it is called.
For all the times after the first call, it could cause an error where the player is not connected.

Code:
fnColorPrint(id, const szMsg[], {Float, Sql, Result,_}:...) {     static iMsgSayText, iMaxPlayers;     if(!iMsgSayText)         iMsgSayText = get_user_msgid("SayText");         if(!iMaxPlayers)         iMaxPlayers = get_maxplayers();             static Buffer[190], Buffer2[192]     formatex(Buffer2, charsmax(Buffer2), "^x04[%s] ^x01%s", g_szPrefix, szMsg);     vformat(Buffer, charsmax(Buffer), Buffer2, 3);         new iPlayer = id;         if(!iPlayer)     {         while(iPlayer <= iMaxPlayers)         {             if(is_user_connected(++iPlayer))                 break;         }     }         message_begin(id ? MSG_ONE_UNRELIABLE : MSG_ALL, iMsgSayText, _, iPlayer);     write_byte(iPlayer);     write_string(Buffer);     message_end(); }

drekes 03-30-2011 23:50

Re: custom colour
 
Oh, i see.
Thanks for fixing it.

ConnorMcLeod 03-31-2011 01:37

Re: custom colour
 
You can pass a not connected player as argument 1, it works.

Also, would be better to use the function like this :

fnColorPrint(0, "^4[%s] ^1your name is %s", g_szPrefix, szName)

Then you can remove lot of code :
Also, you had passed iPlayer as last message_begin argument, the receiver is id and not iPlayer.

PHP Code:

fnColorPrint(id, const szMsg[], any:...) 

    static 
iMsgSayText
    if(!
iMsgSayText
        
iMsgSayText get_user_msgid("SayText"); 

    static 
Buffer[190];
    
vformat(Buffercharsmax(Buffer), Buffer23); 

    
message_begin(id MSG_ONE_UNRELIABLE MSG_ALLiMsgSayText, .player=id); 
    
write_byte(id id 1); 
    
write_string(Buffer); 
    
message_end(); 



Note that such a function doesn't allow team color change or ML when you pass id = 0 ( see my sig :D )

drekes 03-31-2011 02:09

Re: custom colour
 
I almost never use ML, I like something like that because i don't have to add the prefix to every sentence i write.
Thanks for the optimisation :)

EDIT: you forgot to change Buffer2 to szMsg
PHP Code:

vformat(Buffercharsmax(Buffer), Buffer23); 

=>
PHP Code:

vformat(Buffercharsmax(Buffer), szMsg3); 



All times are GMT -4. The time now is 14:31.

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