Problem.
#1

Hello again, I have a small problem with function which is detecting bad words in string, and if there is one, it changes the bad word letters to *. The problem is that in chat it works fine, but in commands - no. For example, I have command /classchat, the string is always null if I am using that function wheo formating.

pawn Код:
YCMD:classchat(playerid, params[], komandos)
{
    if (isnull(params))
    {
        return SendClientMessage(playerid, COLOR_RED, "» Komandos naudojimas: {FFFF00}/©lasschat [tekstas]");
    }
    new szRadio[128];
    format(szRadio, 128, "[RACIJA] %s %s (%d): {FF0000}%s", GetClassRang(playerid, iClass[playerid]), GetPlayerNameEx(playerid), playerid, >>>ChangeSwear(params)<<<);
    foreach(new i: Player)
    {
        if (iChannel[i] == iChannel[playerid])
        {
            SendClientMessage(i, COLOR_LIGHTBLUE, szRadio);
        }
    }
    return true;
}
If I am using this way, params is always null, I mean what ever you write (for e.g /classchat TEST), its always null!

But, if I do this way:

pawn Код:
YCMD:classchat(playerid, params[], komandos)
{
    if (isnull(params))
    {
        return SendClientMessage(playerid, COLOR_RED, "» Komandos naudojimas: {FFFF00}/©lasschat [tekstas]");
    }
    new szRadio[128];
    format(szRadio, 128, "[RACIJA] %s %s (%d): {FF0000}%s", GetClassRang(playerid, iClass[playerid]), GetPlayerNameEx(playerid), playerid, >>>params<<<);
    foreach(new i: Player)
    {
        if (iChannel[i] == iChannel[playerid])
        {
            SendClientMessage(i, COLOR_LIGHTBLUE, szRadio);
        }
    }
    return true;
}
Everything works fine then.

The function:

pawn Код:
stock ChangeSwear(Text[], Symbol = '*')
{
    new iWords = sizeof(BadWords), i;
    for (new BadWord; BadWord != iWords; ++BadWord)
    {
        while ((i = strfind(Text, BadWords[BadWord], true)) != -1)
        {
            for (new x = (i + strlen(BadWords[BadWord])); i != x; ++i)
            {
                Text[i] = Symbol;
            }
        }
    }
    return true;
}
Reply
#2

You are not returning the converted "params" on the function but "true".
Try:
pawn Код:
stock ChangeSwear(Text[], Symbol = '*')
{
    new iWords = sizeof(BadWords), i;
    for (new BadWord; BadWord != iWords; ++BadWord)
    {
        while ((i = strfind(Text, BadWords[BadWord], true)) != -1)
        {
            for (new x = (i + strlen(BadWords[BadWord])); i != x; ++i)
            {
                Text[i] = Symbol;
            }
        }
    }
    return Text;
}
Reply
#3

I'll give a try later, thanks for fast reply
Reply
#4

I tried your method, but its the same.
Reply
#5

Hmm put back the function to return true; instead of return Text;
And try this
pawn Код:
YCMD:classchat(playerid, params[], komandos)
{
    if (isnull(params))
    {
        return SendClientMessage(playerid, COLOR_RED, "» Komandos naudojimas: {FFFF00}/©lasschat [tekstas]");
    }
    new szRadio[128];
    ChangeSwear(params);
    format(szRadio, 128, "[RACIJA] %s %s (%d): {FF0000}%s", GetClassRang(playerid, iClass[playerid]), GetPlayerNameEx(playerid), playerid,params);
    foreach(new i: Player)
    {
        if (iChannel[i] == iChannel[playerid])
        {
            SendClientMessage(i, COLOR_LIGHTBLUE, szRadio);
        }
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)