[Ayuda] Como evitar que puedan hablar con Colores
#9

Intenta con esto... Es parecido a lo que usaba en mi server antes de pasar a 0.3d

pawn Код:
#define strcpy(%0,%1,%2) \
    strcat((%0[0] = '\0', %0), %1, %2)

public OnPlayerText(playerid, text[])
{
    new color, msg[128];
    strcpy(msg, text, sizeof(msg)); //Copia el texto a otra variable
    color = FindColourInStr(msg, sizeof(msg)) //Busca un color :P
    while(color != -1)
    {
        strdel(msg, color, color+7); //Quita el color
        color = FindColourInStr(msg, sizeof(msg)); //Busca otro color
    }
    //Ahora "msg" tiene el mensaje sin codigos de color
    #define text msg //Asi te evitas cambiar todos los "text" a "msg" :P
    //Lo que ya tenias en OnPlayerText aqui
    #undef text
    SendPlayerMessageToAll(playerid, msg); //Envia el mensaje con los colores removidos
    return 0; //Recuerda esto... Asн no se envia el mensaje que tiene los colores
}

stock FindColourInStr(string[], len)
{
    for(new i; i < len; i++)
    {
        if(string[i] == EOS) break;
        if(string[i] == 0x7B && i+7 < len)
        {
            new hex[7];
            strmid(hex, string, i+1, i+7);
            if(IsHex(hex) && strlen(hex) == 6 && string[i+7] == 0x7D)
            {
                return i;
            }
        }
    }
    return -1;
}

stock IsHex(str[]) //By ******
{
        new
                i,
                cur;
        if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) i = 2;
        while (str[i])
        {
                cur = str[i++];
                if ((cur < '0') || (cur > '9' && cur < 'A') || (cur > 'F' && cur < 'a') || (cur > 'f')) return 0;
        }
        return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)