PDA

View Full Version : Chat Filter


xAndrewx
03-03-2008, 12:12 PM
I find it the best thing since the slice of bread!


//#CLIENTSIDE
function onPlayerChats()
{
if (player.chat == "unstick me")
{
return false;
}

temp.filters = {
{ {"no", "nah", "nay"}, {"ar", "yar matey", "aye laddy"}},
{ {"hello", "hi", "hey", "hiya"}, {"'ey matey", "avast"}},
{ {"***"}, {"scallywag", "scallywag"}},
{ {"****"}, {"arrrrrrrrg", "fuk", "arrg", "arrrrrrrrrrrrrrrrrrrg"}},
{ {"nig", "******", "ngr", "nigro", "negro"}, {"blackskinned folk", "blacker folk", "cursed people"}},
{ {"****"}, {"scurvy", "davey jones waste"}},
{ {"****", "****", "dik"}, {"mast", "treasure chest"}},
{ {"douchebag"}, {"waterdog", "water dog"}},
{ {"daz"}, {"black beard", "blackbeard"}},
{ {"staf", "staff"}, {"crew", "maties"}},
{ {"vulcan"}, {"deckboy", "deck boy"}},
{ {"yes", "yeah", "yea"}, {"yar", "yaaar"}},
{ {"people", "person", "guy", "man"}, {"folk", "mate"}},
{ {"there"}, {"ahoy"}},
{ {"money", "cash"}, {"dubloon", "dubloons"}}
};

temp.chat = player.chat.tokenize();

for (temp.i: temp.chat)
{
for (temp.f: temp.filters)
{
for (temp.g: temp.f[0])
{
temp.newChat = false;

if (temp.g == temp.i.lower())
{
temp.newChat = randomstring(temp.f[1]);
}
else
if (temp.i.lower().starts(temp.g))
{
temp.newChat = randomstring(temp.f[1]) @ temp.i.substring(temp.g.length());
}
else
if (temp.i.lower().ends(temp.g))
{
temp.newChat = temp.i.substring(0, temp.g.length()) @ randomstring(temp.f[1]);
}

if (temp.newChat != false)
{
temp.chat.replace(temp.c, temp.newChat);
}

}
}
temp.c++;
}

temp.newChat = "";

for (temp.c: temp.chat)
{
temp.newChat @= temp.c @ " ";
}

player.chat = temp.newChat;
}

cbk1994
03-04-2008, 02:41 AM
Been there done that.

http://forums.graalonline.com/forums/showthread.php?t=73726

kia345
03-04-2008, 03:01 AM
cursed people

I'm so glad I accidentally clicked this thread, I lol'd way harder than I should have.

Tolnaftate2004
03-04-2008, 03:22 AM
This is a fairly weak filter. It would probably be better to use all non-word characters as delimiters for tokens (or the like), if you want it to be stronger.

Darklux
03-04-2008, 12:19 PM
I don't like swear filters. The one on gk is quite script and people swear or make racist remarks all the time => it does not work at all.

Frankie
03-04-2008, 09:41 PM
Pirate day on Era! lmao

cbk1994
03-04-2008, 11:07 PM
I like swear filters, but most people do not, so I find it best to add optional clientside filters, though a custom chat system is required.