AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to make colored messages? (https://forums.alliedmods.net/showthread.php?t=84637)

Owyn 01-29-2009 09:25

how to make colored messages?
 
how to make printed text green?
here is msg sending function
Code:

public cmdChat(id, level, cid)
{
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED

    new message[192], name[32], players[32], inum, authid[32], userid
   
    read_args(message, 191)
    remove_quotes(message)
    get_user_authid(id, authid, 31)
    get_user_name(id, name, 31)
    userid = get_user_userid(id)
    get_players(players, inum)
   
    log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message)
    log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message)
   
    format(message, 191, "(ADMINS) %s :  %s", name, message)
    console_print(id, "%s", message)
   
    for (new i = 0; i < inum; ++i)
    {
        if (access(players[i], g_AdminChatFlag))
            client_print(players[i], print_chat, "%s", message)
    }
   
    return PLUGIN_HANDLED
}


Arkshine 01-29-2009 09:35

Re: how to make colored messages?
 
.Owyn., there are already a lot of threads about colored message in chat, try to search a bit before, please.

Owyn 01-29-2009 09:49

Re: how to make colored messages?
 
i've seen some topics but if i try
format(message, 191, "(ADMINS) %s : ^x04%s", name, message) it doesn't work

BOYSplayCS 01-29-2009 10:29

Re: how to make colored messages?
 
PHP Code:

static GREEN[] = "^x04"

new gameSayText

public plugin_int() {
     
gameSayText get_user_msgid("SayText")
}

public 
some_function(id) {
     new 
messge[124]
     
format(message,123,"^x04TEXTGOESHERE")    
     
print_message(id,message)


print_message(idmesg[]) {
     
message_begin(MSG_ONEgameSayText, {0,0,0}, id)
     
write_byte(id)
     
write_string(mesg)
     
message_end()



Owyn 01-29-2009 10:54

Re: how to make colored messages?
 
thank you i got it to work, but what for did you make static GREEN? =0

BOYSplayCS 01-29-2009 10:57

Re: how to make colored messages?
 
Your welcome.

static GREEN[] doesn't equal zero. It equals ^x04, it can't contain anything else.

However, you can make different colors with different values.

xPaw 01-29-2009 11:18

Re: how to make colored messages?
 
it didnt was used in your code :D

SnoW 01-29-2009 11:21

Re: how to make colored messages?
 
Quote:

Originally Posted by .Owyn. (Post 752221)
thank you i got it to work, but what for did you make static GREEN? =0

Quote:

Originally Posted by BOYSplayCS (Post 752224)
static GREEN[] doesn't equal zero. It equals ^x04, it can't contain anything else.

He didn't mean anything with equaling or zero, it was only a smile like :o
:mrgreen:
Anyway, ye "^x04" means green, to see the colors -> Search.

hleV 01-29-2009 12:34

Re: how to make colored messages?
 
My version (using it in my plugins).
Code:
#include <amxmodx>   new g_iSayText, g_iMaxPlayers;   public plugin_cfg() {         g_iSayText = get_user_msgid("SayText");         g_iMaxPlayers = get_maxplayers(); }   stock print(iCl, const szMsg[], {Float, Sql, Result,_}:...) {         static szBuffer[192];         szBuffer[0] = 0x01;         vformat(szBuffer[1], 190, szPrefix, 3);         if (iCl && iCl <= g_iMaxPlayers)         {                 message_begin(MSG_ONE, g_iSayText, {0, 0, 0}, iCl);                 write_byte(iCl);                 write_string(szBuffer);                 message_end();         }         else if (!iCl)         {                 for (iCl = 1; iCl <= g_iMaxPlayers; iCl++)                 {                         if (!is_user_connected(iCl))                                 continue;                                                 message_begin(MSG_ONE, g_iSayText, {0, 0, 0}, iCl);                         write_byte(iCl);                         write_string(szBuffer);                         message_end();                 }         }           return 1; }

Owyn 01-29-2009 13:21

Re: how to make colored messages?
 
О__о
i can't understand it


All times are GMT -4. The time now is 01:38.

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