PDA

View Full Version : Language Filter


cbk1994
04-29-2007, 12:59 AM
This is a bad word filter on I worked just for the sake of keeping up my scripting skills (no current jobs).

-Features
-- If player says a word in the list (not capital sensitive) it is replaced by *
-- Will stop all of the following & more (for example, the word cat):
--- cat
--- scat--- scats
--- s cat
--- s cat s
--- c at
--- ca t
-- Very easy to customize.


This is very easy to customize, all you need to do is add words to this.words; for example:

this.words = { "word", "peace", "dude" };
can be changed to

this.words = { "hi", "yo", "peace", "happy" };

or so.

You can find this.words in the onCreated function. Here is the code.

Code for Weapon/GUI-Script -Filter:

// Created by Chris Zakuto
//#CLIENTSIDE
function onCreated( NULL )
{
this.words =
{
"mac",
"for",
"lyfe"
};
}
function onPlayerChats( NULL )
{

if ( temp.chars != NULL )
{
temp.chars.clear();
}

temp.chat = player.chat;
if ( temp.rchat != NULL )
{
temp.rchat = "";
}
if ( temp.spac != NULL )
{
temp.spac = 0;
}
for ( temp.i = 0; temp.i < temp.chat.length(); temp.i ++ )
{
if ( temp.chat.substring( temp.i, 1 ) != " " )
{
temp.chars.add( { temp.i - temp.spac, temp.chat.substring( temp.i, 1 ), temp.spac } );
temp.rchat = temp.rchat @ temp.chat.substring( temp.i, 1 );
}
else
{
temp.spac ++;
}
}
for ( temp.a: temp.chars )
{
temp.n = ( temp.rchat.length() - temp.a[0] ) + 1;

for ( temp.x = 0; temp.x < temp.n; temp.x ++ )
{
for ( temp.y: this.words )
{
if ( temp.y == temp.rchat.substring( temp.a[0], temp.x ) )
{
temp.filter = temp.rchat.substring( temp.a[0], temp.x );
temp.filter2 = temp.filter.length();
if ( temp.zz != NULL )
{
temp.zz = "";
}
for ( temp.var = 0; temp.var < temp.filter2; temp.var ++ )
{
temp.zz = temp.zz @ "*";
}
player.chat = " ";
}
}
}
}
}

Novo
04-29-2007, 01:54 AM
Or... Use Graal's internal swear filter? It's been out for a long time. I forgot how it was set up, but it was files in a folder that could even block swearing in PMs.

cbk1994
04-29-2007, 02:01 AM
Or... Use Graal's internal swear filter? It's been out for a long time. I forgot how it was set up, but it was files in a folder that could even block swearing in PMs.

I just love it when people flame other people for making something nice, and then say OMG THATS NOT NECCESARY! Go milk a cow Novo.

ff7chocoboknight
04-29-2007, 02:20 AM
@Novo: lawl! u got pwnt!

@cbkbud: Good job, man. ;p

Novo
04-29-2007, 02:24 AM
http://forums.graalonline.com/forums/showthread.php?t=48781

I never mentioned anything about how one can script. I merely said that there is better solutions for people whom are interested. Personally, I feel that you're being a hypocrite.

Rapidwolve
04-29-2007, 02:40 AM
Graal has one internally? o_O

Sulukra
04-29-2007, 02:41 AM
Or... Use Graal's internal swear filter? It's been out for a long time. I forgot how it was set up, but it was files in a folder that could even block swearing in PMs.

I recall that it didn't work too well - atleast, on Valikorlia, it tended to do weird stuff like block the word jello and laser. It was just weird.

ff7chocoboknight
04-29-2007, 03:00 AM
:oo: i remember it blocking th words chair and trashcan

Rapidwolve
04-29-2007, 03:39 AM
(not capital sensitive)


If you want it to be case sensitive use lowercase() and make both the array and the parser lowercase, thats what I did o-o

cbk1994
04-29-2007, 05:15 AM
If you want it to be case sensitive use lowercase() and make both the array and the parser lowercase, thats what I did o-o

Why would I want it case senitive?

cat and cAT don't make that much of a difference ...

Personally, Novo, I think you're being a hypocrite. Please look at the date on that post, 2003. I am almost positive it has been removed.

DustyPorViva
04-29-2007, 05:25 AM
Only problem I have with filters that detect words even with spaces is when you stay things like, "I was watching them and he was hit", the last two words gets censored out. But really no way to get around that.

ff7chocoboknight
04-29-2007, 05:29 AM
Only problem I have with filters that detect words even with spaces is when you stay things like, "I was watching them and he was hit", the last two words gets censored out. But really no way to get around that.
hate it when that happens

DustyPorViva
04-29-2007, 05:37 AM
A suggestion.
Perhaps you can kind of give your script a little AI. It might be a little burdening on the script, but maybe an idea for you, or anyone else who wants to try, is to document every character that is used as a substitute for every letter of the alphabet.
Such as....
s={"s","$"};
h={"h","|-|"};
m={"m","/\/\","|\/|"};
t={"t","+","7"};
and have the check use it as a reference for letters, and if any of those letters match one of the letters above, and end up translating into a curse word, censor it.
If that makes sense.

ff7chocoboknight
04-29-2007, 05:42 AM
nice idea! (you ppl takin' notes?)

Twinny
04-29-2007, 06:22 AM
I know N-Pulse uses the inbuilt filter.

By the way, i would have used function ChatBar.onAction() then check ChatBar.text rather than onPlayerChats()

Chandler
04-29-2007, 09:40 AM
I know N-Pulse uses the inbuilt filter.

By the way, i would have used function ChatBar.onAction() then check ChatBar.text rather than onPlayerChats()

ok


I'd use the thing Novo suggested.

ff7chocoboknight
04-29-2007, 05:48 PM
using onPlayerChats() shows the players chat for a second then its blocked I use this split second by saying the message over and over showing the message before the words are blocked eachtime (i do this on Zone)

cbk1994
04-29-2007, 11:14 PM
It doesn't do that actually ...

Also, I made a major correction with the spacing. (edited my original post). If you are using this code you must update it for it to work!

Riot
04-30-2007, 01:02 AM
using onPlayerChats() shows the players chat for a second then its blocked I use this split second by saying the message over and over showing the message before the words are blocked eachtime (i do this on Zone)
The internal system only does this for you. It is censored before it is sent to other players.

cbk1994
04-30-2007, 02:15 AM
The internal system only does this for you. It is censored before it is sent to other players.

Well what I made seems to block it right away, though we don't have much lag on the server ...

Twinny
04-30-2007, 01:06 PM
using onPlayerChats() shows the players chat for a second then its blocked I use this split second by saying the message over and over showing the message before the words are blocked eachtime (i do this on Zone)

Where as

//#CLIENTSIDE
function ChatBar.onAction()
{
if (ChatBar.text == "test!")
{
ChatBar.text = "Filtered!";
}
}


This will set the player.chat as 'Filtered' instantly. ChatBar.onAction goes before onplayerchats(). If you were to set player.chat as "", the onplayerchats event won't even be called.

Deadly_Killer
04-30-2007, 10:08 PM
You can easily check which one receives faster by script.

Example:

//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "test") {
player.chat = "Test";
}
}

function ChatBar.onAction() {
if (ChatBar.text == "test") {
ChatBar.text = "Too Fast";
}
}


You will notice that when you say test, onPlayerChats would try to change it to Test. Though, it isn't as fast as reading the GUI Chat Bar which will make you say Too Fast before onPlayerChats is even called.

cbk1994
05-01-2007, 02:29 AM
I understand that it is faster, I'm not worried about that. It works fine on my server, deal with it.

Deadly_Killer
05-01-2007, 10:13 PM
I understand that it is faster, I'm not worried about that. It works fine on my server, deal with it.

Why do you think we are trying to bash you? We are only giving suggestions to improve your coding.

Chandler
05-01-2007, 10:26 PM
You can easily check which one receives faster by script.

Example:

//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "test") {
player.chat = "Test";
}
}

function ChatBar.onAction() {
if (ChatBar.text == "test") {
ChatBar.text = "Too Fast";
}
}


You will notice that when you say test, onPlayerChats would try to change it to Test. Though, it isn't as fast as reading the GUI Chat Bar which will make you say Too Fast before onPlayerChats is even called.

Would be better if you used echo to find which one is called first.

cbk1994
05-01-2007, 11:49 PM
Why do you think we are trying to bash you? We are only giving suggestions to improve your coding.

I'm sorry, I've been in a bad mood lately. I overreacted, sorry everybody. I will add this to my code.

theHAWKER
05-03-2007, 07:02 AM
This is a bad word filter on I worked just for the sake of keeping up my scripting skills (no current jobs).

-Features
-- If player says a word in the list (not capital sensitive) it is replaced by *
-- Will stop all of the following & more (for example, the word cat):
--- cat
--- scat--- scats
--- s cat
--- s cat s
--- c at
--- ca t
-- Very easy to customize.


This is very easy to customize, all you need to do is add words to this.words; for example:

this.words = { "word", "peace", "dude" };
can be changed to

this.words = { "hi", "yo", "peace", "happy" };

or so.

You can find this.words in the onCreated function. Here is the code.

Code for Weapon/GUI-Script -Filter:

// Created by Chris Zakuto
//#CLIENTSIDE
function onCreated( NULL )
{
this.words =
{
"mac",
"for",
"lyfe"
};
}
function onPlayerChats( NULL )
{

if ( temp.chars != NULL )
{
temp.chars.clear();
}

temp.chat = player.chat;
if ( temp.rchat != NULL )
{
temp.rchat = "";
}
if ( temp.spac != NULL )
{
temp.spac = 0;
}
for ( temp.i = 0; temp.i < temp.chat.length(); temp.i ++ )
{
if ( temp.chat.substring( temp.i, 1 ) != " " )
{
temp.chars.add( { temp.i - temp.spac, temp.chat.substring( temp.i, 1 ), temp.spac } );
temp.rchat = temp.rchat @ temp.chat.substring( temp.i, 1 );
}
else
{
temp.spac ++;
}
}
for ( temp.a: temp.chars )
{
temp.n = ( temp.rchat.length() - temp.a[0] ) + 1;

for ( temp.x = 0; temp.x < temp.n; temp.x ++ )
{
for ( temp.y: this.words )
{
if ( temp.y == temp.rchat.substring( temp.a[0], temp.x ) )
{
temp.filter = temp.rchat.substring( temp.a[0], temp.x );
temp.filter2 = temp.filter.length();
if ( temp.zz != NULL )
{
temp.zz = "";
}
for ( temp.var = 0; temp.var < temp.filter2; temp.var ++ )
{
temp.zz = temp.zz @ "*";
}
player.chat = " ";
}
}
}
}
}


ur script dont work...

killerogue
05-03-2007, 07:29 AM
ur script dont work...

Rather than telling him his script doesn't work, you could just as possibly be using it wrong dude. =/

Anyway, good job Chris. :)

Twinny
05-03-2007, 08:41 AM
Would be better if you used echo to find which one is called first.

ChatBar.onAction() is called first. Think about it: you press enter on that bar to make the player chat >_<.

If you do,

//#CLIENTSIDE
function ChatBar.onAction()
{
ChatBar.text = "";
}

function onplayerchats()
{
echo("Yay!");
}


You should not be able to see your player say anything nor any output in the F2 log.

ur script dont work...

Did you try and debug the script?

Chandler
05-03-2007, 06:10 PM
ChatBar.onAction() is called first. Think about it: you press enter on that bar to make the player chat >_<.

If you do,

//#CLIENTSIDE
function ChatBar.onAction()
{
ChatBar.text = "";
}

function onplayerchats()
{
echo("Yay!");
}


You should not be able to see your player say anything nor any output in the F2 log.


Yes. BUT STILL USE ECHO!! :)

theHAWKER
05-04-2007, 01:04 AM
Rather than telling him his script doesn't work, you could just as possibly be using it wrong dude. =/

ur always on my back >:(

why dont u just tell me how to use it instead of just picking me off.

i put it in the wepons thing and called it -filter or what ever but it wont work :(

Skyld
05-04-2007, 01:24 AM
ur always on my back >:(

why dont u just tell me how to use it instead of just picking me off.

i put it in the wepons thing and called it -filter or what ever but it wont work :(
Be more specific, will you? Step by step what you did, and what happened at each step would be more useful in helping us to determine why it is not working.

theHAWKER
05-04-2007, 01:30 AM
Be more specific, will you? Step by step what you did, and what happened at each step would be more useful in helping us to determine why it is not working.

umkay:
Step number one: copy and past the script into the weapon named "-filter"
Step number two: test it
Step number three: go on forums and tell the world that it wont work :(

cbk1994
05-04-2007, 03:50 AM
umkay:
Step number one: copy and past the script into the weapon named "-filter"
Step number two: test it
Step number three: go on forums and tell the world that it wont work :(

Did you add any words to the list, and, did you add yourself the weapon?

CountBleck
02-12-2008, 07:02 AM
Awsome. Like it on my playerworld. per+ :D