Jump to content

Help Me About Badword Filtering


WillyRL

Recommended Posts

Halo all,

Before i'm very sorry for my bad english, I'm From Indonesia , and i have problem with script ,

Okay to the point, I have a Chat script, and i want to filtering the badword , like this

  
            if string.find ( msg, "rabbit" ) then --disallow links 
            outputChatBox ( "Do not Using Badword In This Server!!", playersource, 255, 0, 0 ) 
            return 
        end 

It just can filter 1 word, So my question is , how can i filtering the word from .txt or .xml files , example

i make a badwords database , named badwords.txt or badwords.xml . Like this

turtle

rabbit

worker

It just example

How to write the code to catch or get badwords from badwords.txt

Thank you Guys, I'm really appreciate it :D

Link to comment

Hello , if you want more than 1 word , then use Table ,

Bad = {":O", ":O"} 
  
function BadWords ( message, messageType ) 
    local Findingdots = string.gsub(message, "([%s%_%*%+%?%.%(%)%[%]%{%}%\%/%|%^%$%-])", '') 
    for i, Findingbad in ipairs(Bad) do 
        if string.find( message, Findingbad) then 
            setPlayerMuted(source, true) 
            outputChatBox ( getPlayerName ( source ).." has mute bad words", getRootElement(), 255, 255, 0, true ) 
        elseif string.find( Findingdots, Findingbad) then 
            setPlayerMuted(source, true) 
            outputChatBox ( getPlayerName ( source ).." has mute bad words", getRootElement(), 255, 255, 0, true ) 
        end 
    end 
end 
addEventHandler ( "onPlayerChat", getRootElement(), BadWords ) 

Link to comment

I mean like this,

I'm make a database with .xml or .txt

in the database , is the words i want block or filter in my server.

so when i found a new bad word , i'm just need to open the badword.txt or badword.xml and add the word to there.

so the user cant use that word, Thank you anyway.

Link to comment

You can use this code :

addEventHandler("onPlayerChat",getRootElement(), 
function(message) 
if (string.find(message,"fu*ck")) or (string.find(message,"dick")) then       --- use or for multiple words you want to block 
cancelEvent()                                                                                         --- cancel the event, the bad word would not show 
setPlayerMuted(source,true) 
outputChatBox("You were muted for saying a bad word .. ",source,255,0,0,true) 
setTimer(setPlayerMuted,60000,1,source,false) 
setTimer(outputChatBox,60000,1,"You are unmuted, don't say that word again !",source,0,255,0,true) 
end 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...