OnPlayerText
#1

What's wrong with this code?
pawn Код:
public OnPlayerText(playerid, text[])
{
    new pname[24];
    GetPlayerName(playerid, pname, sizeof(pname));

    new str[128];
    format(str, sizeof(str), "%s[%i]: %s", pname, playerid, text);

    if(TextColor[playerid] == None)
    {
        SendClientMessageToAll(0xFFFFFFAA, str);
    }
    if(TextColor[playerid] == Red)
    {
        SendClientMessageToAll(0xFF0000AA, str);
    }
    if(TextColor[playerid] == Orange)
    {
        SendClientMessageToAll(0xFFA500AA, str);
    }
    if(TextColor[playerid] == Yellow)
    {
        SendClientMessageToAll(0xFFFF00AA, str);
    }
    if(TextColor[playerid] == Green)
    {
        SendClientMessageToAll(0x00FF00AA, str);
    }
    if(TextColor[playerid] == Blue)
    {
        SendClientMessageToAll(0x0000FFAA, str);
    }
    if(TextColor[playerid] == Purple)
    {
        SendClientMessageToAll(0x800080AA, str);
    }
    if(TextColor[playerid] == Grey)
    {
        SendClientMessageToAll(0x808080AA, str);
    }
    if(TextColor[playerid] == Cyan)
    {
        SendClientMessageToAll(0x00FFFFAA, str);
    }
    if(TextColor[playerid] == Pink)
    {
        SendClientMessageToAll(0xFF00FFAA, str);
    }
    return 0;
}
It sends the message in every color.

pawn Код:
public OnPlayerConnect(playerid)
{
    TextColor[playerid] = None;
        return 1;
}
Reply
#2

put return 0; after each SendClientMessageToAll

that should work.
Reply
#3

This is not how PAWN works, you cannot do something like
pawn Код:
TextColor[playerid] = Blue;
unless you have something like
pawn Код:
#define Blue 1
This is just an example. Please read the PAWN lang .pdf files!
Reply
#4

Okay, that worked, but now it's not setting the color of the text.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == TextDialog)
    {
        if(!response) return 1;
        switch(listitem)
        {
            case 0:
            {
                TextColor[playerid] = Red;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected red text.");
            }
            case 1:
            {
                TextColor[playerid] = Orange;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected orange text.");
            }
            case 2:
            {
                TextColor[playerid] = Yellow;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected yellow text.");
            }
            case 3:
            {
                TextColor[playerid] = Green;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected green text.");
            }
            case 4:
            {
                TextColor[playerid] = Blue;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected blue text.");
            }
            case 5:
            {
                TextColor[playerid] = Purple;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected purple text.");
            }
            case 6:
            {
                TextColor[playerid] = Grey;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected grey text.");
            }
            case 7:
            {
                TextColor[playerid] = Cyan;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected cyan text.");
            }
            case 8:
            {
                TextColor[playerid] = Pink;
                SendClientMessage(playerid, 0xFFFFFFAA, "You have selected pink text.");
            }
        }
    }
    return 1;
}
Quote:
Originally Posted by AndreT
Посмотреть сообщение
This is not how PAWN works, you cannot do something like
pawn Код:
TextColor[playerid] = Blue;
unless you have something like
pawn Код:
#define Blue 1
This is just an example. Please read the PAWN lang .pdf files!

EDIT: I do.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)