WillyRL Posted June 8, 2014 Share Posted June 8, 2014 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 turtlerabbit 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 Link to comment
Max+ Posted June 8, 2014 Share Posted June 8, 2014 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
WillyRL Posted June 8, 2014 Author Share Posted June 8, 2014 I need the system , with database separate with the script , can you help me? Link to comment
Max+ Posted June 8, 2014 Share Posted June 8, 2014 I need the system , with database separate with the script , can you help me? Sorry , i dont Know about databases .. . , Link to comment
Cadell Posted June 8, 2014 Share Posted June 8, 2014 what u mean with database you storing log in database? and want bad word get remove from chat + logs? Link to comment
WillyRL Posted June 9, 2014 Author Share Posted June 9, 2014 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
Cadell Posted June 9, 2014 Share Posted June 9, 2014 instead of that i suggest you to use table it will be easy just attach table in chat if word found it give desire output u want Link to comment
WillyRL Posted June 10, 2014 Author Share Posted June 10, 2014 Thank you for help guys , Really appreciate it Link to comment
qaisjp Posted June 10, 2014 Share Posted June 10, 2014 Here are the functions you could use: addEventHandler cancelEvent fileRead fileOpen fileClose fileGetSize xmlLoadFile xmlNodeGetValue xmlFindChildren string.find outputChatBox Link to comment
#1ERuPTiON Posted June 12, 2014 Share Posted June 12, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now