Need help with MessageToAdmins
#1

I have two colors in my MessageToAdmins, one of them is grey for leave/join messages, others is for admin stuff, like admin chat.. but everytime someone disconnects and an admin use a cmd
it always says it in two colors

here is the code

pawn Код:
public MessageToAdmins(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdminLevel] >=1)
        {
        SendClientMessage(i, AdminColor, string);
        SendClientMessage(i, Grey, string);
        }
    }
    return 1;
}
and dont delete one of the colors i need them both .. please help
Reply
#2

Delete one of the SendClientMessage lines. That loop sends the same message twice.
Reply
#3

I fail to see why you need 2 colours for 1 string? Or you can use colour embedding which was introduced in 0.3c ?
Reply
#4

so how can i edit it to make it works with two colors please show me
Reply
#5

please help, how can i make different loops
Reply
#6

Okay, so you have one function and it's sending you a 2 messages.
You need to do this:
pawn Код:
forward MessageToAdmins(color, const string[]);
public MessageToAdmins(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdminLevel] >=1)
        {
            //SendClientMessage(i, AdminColor, string);   - Delete this because you won't need it.
            SendClientMessage(i, Grey, string); // This function will send message in Grey color!
        }
    }
    return 1;
}
And now make another function...Something like this:
pawn Код:
forward MessageToAdminsFromAdmins(color, const string[]);
public MessageToAdminsFromAdmins(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdminLevel] >=1)
        {
            SendClientMessage(i, AdminColor, string);// And this function will send Message in AdminColor color!
            //SendClientMessage(i, Grey, string);    - Delete this because you won't need it.
        }                                       // Or leave it, I don't care...
    }
    return 1;
}
OR READ THIS: Colour_Embedding

Change the colors you want, this was just an example.
Hope it helps.
Reply
#7

Quote:
Originally Posted by xir
Посмотреть сообщение
it always says it in two colors
Quote:
Originally Posted by xir
Посмотреть сообщение
and dont delete one of the colors i need them both
Wut?
Reply
#8

Quote:
Originally Posted by xir
Посмотреть сообщение
so how can i edit it to make it works with two colors please show me
First i would like to start by saying i havent yet message with 0.3c myself, so this is just going off of what i see :P.


To use multiple colors you would have to add physical color tags into your code, for example:

Код:
MessageToAdmins(0xFFFFFFFF, "This is all white {FF0000}this is all red, {00FF00}and this is all green!");
If you are using anything other than 0.3c you would have to edit your function to support multiple strings and colors, since prior versions to 0.3c dont support multiple colors in a SINGLE client message. You would ideally do something like sscanf where you have a param for the entire string, a parameter for the specifiers (including delimiter), and then an ellipses for the colors. The function would pretty much tokenize the string based on the delimeter and send all the messages one after another with the desired colors.

This would be a bit of an overkill though, you of course can do it easier. Though i dont think this is even what you desire, i think you're looking for the 0.3c solution :P.
Reply
#9

pawn Код:
stock MessageToAdmins(reqlvl, color, msg[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsPlayerAdmin(i) || PlayerInfo[i][pAdminLevel] >= reqlvl)
            SendClientMessage(i, color, msg);
}
USAGE:
MessageToAdmins(LEVEL_NEEDED, COLOR, MESSAGE);
Example, if you wanna send a message to all the admins with level 2 and higher, msg "Hi" , red color:
MessageToAdmins(2, 0xFF0000AA, "Hi");
Reply
#10

Thank you Alex!! Also i dont think i will use color embedding thanks again guys !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)