Help with 1 command
#5

Quote:
Originally Posted by ColdRain
Посмотреть сообщение
what i mean when i type

/write 0 Hello! 5 how are you

the sentence cant be colored 2 colors its stay black only! i want when i type like this /write 0 Hello 5How are you 4 Fine??

like sentence be colors more than 1 color!
Aaa, you want that in a command, let me make it please.
______________________
EDIT: This should work:
pawn Код:
if(strcmp(cmd, "/write", true) == 0 && PlayerAdminLevel[playerid] >= 1)
{
    if(IsAdminOrRecon[playerid] == 0)
    {
        SendClientMessage(playerid,COLOR_ERROR,"Please Login Into Your Mod/Admin Account! Use /adminlog");
        return 1;
    }
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; }
    new offset = idx, result[128], string[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx], idx++; }
    result[idx - offset] = EOS;
    if(!strlen(result))
    {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /write [Colour] [Text]");
        SendClientMessage(playerid, COLOR_WHITE, "Colours: #1 = Blue | #2 = Pink | etc.");
        //#1Just #2an #3example#4!
        return 1;
    }
    format(string,256,"%s", result), SendClientMessageToAll(COLOR_BLACK, ColouredText(string));
    return 1;
}
   
stock ColouredText(text[]) //Thanks to RyDeR`
{
    enum colorEnum { colorName[16], colorID[7] } ;
    new
        colorInfo[][colorEnum] =
        {
            { "1",           "1B1BE0" }, //Blue
            { "2",           "E81CC9" }, //Pink
            { "3",         "DBED15" }, //Yellow
            { "4",     "8CED15" }, //Lightgreen
            { "5",      "15D4ED" }, //Lightblue
            { "6",            "FF0000" }, //Red
            { "7",           "BABABA" }, //Grey
            { "8",          "FFFFFF" }, //White
            { "9",         "DB881A" }, //Orange
            { "10",          "37DB45" }, //Green
            { "11",         "7340DB" } //Purple
        },
        string[(128 + 32)], tempString[16], pos = -1, x;
    strmid(string, text, 0, 128, sizeof(string));

    for( ; x != sizeof(colorInfo); ++x)
    {
        format(tempString, sizeof(tempString), "#%s", colorInfo[x][colorName]);

        while((pos = strfind(string, tempString, true, (pos + 1))) != -1)
        {
            new tempLen = strlen(tempString), tempVar, i = pos;
            format(tempString, sizeof(tempString), "{%s}", colorInfo[x][colorID]);

            if(tempLen < 8)
            {
                for(new j; j != (8 - tempLen); ++j)
                {
                    strins(string, " ", pos);
                }
            }
            for( ; ((string[i] != 0) && (tempVar != 8)) ; ++i, ++tempVar)
            {
                string[i] = tempString[tempVar];
            }
            if(tempLen > 8)
            {
                strdel(string, i, (i + (tempLen - 8)));
            }
            x = -1;
        }
    }
    return string;
}
Tell me if you get any error.
Reply


Messages In This Thread
Help with 1 command - by ColdRain - 19.12.2011, 14:27
Respuesta: Help with 1 command - by [DOG]irinel1996 - 19.12.2011, 14:34
Re: Help with 1 command - by ColdRain - 19.12.2011, 14:35
Re: Help with 1 command - by Hoborific - 19.12.2011, 14:39
Respuesta: Re: Help with 1 command - by [DOG]irinel1996 - 19.12.2011, 14:39
Re: Help with 1 command - by ColdRain - 19.12.2011, 14:56
Respuesta: Help with 1 command - by [DOG]irinel1996 - 19.12.2011, 14:58
Re: Help with 1 command - by ColdRain - 19.12.2011, 15:00
Respuesta: Re: Help with 1 command - by [DOG]irinel1996 - 19.12.2011, 15:03
Re: Help with 1 command - by ColdRain - 19.12.2011, 15:03

Forum Jump:


Users browsing this thread: 1 Guest(s)