Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Language Filter (https://forums.graalonline.com/forums/showthread.php?t=73726)

cbk1994 04-28-2007 11:59 PM

Language Filter
 
This is a bad word filter on I worked just for the sake of keeping up my scripting skills (no current jobs).
HTML Code:

-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:
PHP Code:

this.words = { "word""peace""dude" }; 

can be changed to
PHP Code:

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:
PHP Code:

// Created by Chris Zakuto
//#CLIENTSIDE
function onCreatedNULL )
{
  
this.words =
  {
    
"mac",
    
"for",
    
"lyfe"
  
};
}
function 
onPlayerChatsNULL )
{
  
  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.0temp.temp.chat.length(); temp.++ )
  {
    if ( 
temp.chat.substringtemp.i) != " " )
    {
      
temp.chars.add( { temp.temp.spactemp.chat.substringtemp.i), temp.spac } );
      
temp.rchat temp.rchat temp.chat.substringtemp.i);
    }
    else
    {
      
temp.spac ++;
    }
  }
  for ( 
temp.atemp.chars )
  {
    
temp.= ( temp.rchat.length() - temp.a[0] ) + 1;
    
    for ( 
temp.0temp.temp.ntemp.++ )
    {
      for ( 
temp.ythis.words )
      {
        if ( 
temp.== temp.rchat.substringtemp.a[0], temp.) )
        {
          
temp.filter temp.rchat.substringtemp.a[0], temp.);
          
temp.filter2 temp.filter.length();
          if ( 
temp.zz != NULL )
          {
            
temp.zz "";
          }
          for ( 
temp.var = 0temp.var < temp.filter2temp.var ++ )
          {
            
temp.zz temp.zz "*";
          }
          
player.chat "[*]";
        }
      }
    }
  }



Novo 04-29-2007 12: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 01:01 AM

Quote:

Originally Posted by Novo (Post 1303984)
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 01:20 AM

@Novo: lawl! u got pwnt!

@cbkbud: Good job, man. ;p

Novo 04-29-2007 01:24 AM

http://forums.graalonline.com/forums...ad.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 01:40 AM

Graal has one internally? o_O

Sulukra 04-29-2007 01:41 AM

Quote:

Originally Posted by Novo (Post 1303984)
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 02:00 AM

:oo: i remember it blocking th words chair and trashcan

Rapidwolve 04-29-2007 02:39 AM

Quote:

Originally Posted by cbkbud (Post 1303976)
(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 04:15 AM

Quote:

Originally Posted by Rapidwolve (Post 1304012)
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 04: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 04:29 AM

Quote:

Originally Posted by DustyPorViva (Post 1304061)
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 04: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 04:42 AM

nice idea! (you ppl takin' notes?)

Twinny 04-29-2007 05: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 08:40 AM

Quote:

Originally Posted by Twinny (Post 1304079)
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 04: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 10: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 12:02 AM

Quote:

Originally Posted by ff7chocoboknight (Post 1304162)
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 01:15 AM

Quote:

Originally Posted by Riot (Post 1304376)
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 12:06 PM

Quote:

Originally Posted by ff7chocoboknight (Post 1304162)
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
PHP Code:

//#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 09:08 PM

You can easily check which one receives faster by script.

Example:
PHP Code:

//#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 01: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 09:13 PM

Quote:

Originally Posted by cbkbud (Post 1304729)
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 09:26 PM

Quote:

Originally Posted by Deadly_Killer (Post 1304629)
You can easily check which one receives faster by script.

Example:
PHP Code:

//#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 10:49 PM

Quote:

Originally Posted by Deadly_Killer (Post 1304905)
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 06:02 AM

Quote:

Originally Posted by cbkbud (Post 1303976)
This is a bad word filter on I worked just for the sake of keeping up my scripting skills (no current jobs).
HTML Code:

-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:
PHP Code:

this.words = { "word""peace""dude" }; 

can be changed to
PHP Code:

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:
PHP Code:

// Created by Chris Zakuto
//#CLIENTSIDE
function onCreatedNULL )
{
  
this.words =
  {
    
"mac",
    
"for",
    
"lyfe"
  
};
}
function 
onPlayerChatsNULL )
{
  
  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.0temp.temp.chat.length(); temp.++ )
  {
    if ( 
temp.chat.substringtemp.i) != " " )
    {
      
temp.chars.add( { temp.temp.spactemp.chat.substringtemp.i), temp.spac } );
      
temp.rchat temp.rchat temp.chat.substringtemp.i);
    }
    else
    {
      
temp.spac ++;
    }
  }
  for ( 
temp.atemp.chars )
  {
    
temp.= ( temp.rchat.length() - temp.a[0] ) + 1;
    
    for ( 
temp.0temp.temp.ntemp.++ )
    {
      for ( 
temp.ythis.words )
      {
        if ( 
temp.== temp.rchat.substringtemp.a[0], temp.) )
        {
          
temp.filter temp.rchat.substringtemp.a[0], temp.);
          
temp.filter2 temp.filter.length();
          if ( 
temp.zz != NULL )
          {
            
temp.zz "";
          }
          for ( 
temp.var = 0temp.var < temp.filter2temp.var ++ )
          {
            
temp.zz temp.zz "*";
          }
          
player.chat "[*]";
        }
      }
    }
  }



ur script dont work...

killerogue 05-03-2007 06:29 AM

Quote:

Originally Posted by theHAWKER (Post 1305192)
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 07:41 AM

Quote:

Originally Posted by Chandler (Post 1304909)
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,
PHP Code:

//#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.

Quote:

Originally Posted by theHAWKER (Post 1305192)
ur script dont work...

Did you try and debug the script?

Chandler 05-03-2007 05:10 PM

Quote:

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

If you do,
PHP Code:

//#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 12:04 AM

Quote:

Originally Posted by killerogue (Post 1305194)
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 12:24 AM

Quote:

Originally Posted by theHAWKER (Post 1305331)
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 12:30 AM

Quote:

Originally Posted by Skyld (Post 1305334)
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 02:50 AM

Quote:

Originally Posted by theHAWKER (Post 1305336)
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


All times are GMT +2. The time now is 10:06 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.