19.07.2012, 19:06
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.
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:
Everything works fine then.
The function:
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;
}
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;
}
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;
}