Jump to content

Censor...


#Paper

Recommended Posts

It don't works:

WorksToCensor = { hacker, hack, cheater, cheat, Hacker, Hack, Cheater, Cheat } 
  
function checkorcensure (message,messageType) 
if string.find(message, #WorksToCensor, 1, true) then 
cancelEvent() 
outputChatBox("Use the /report!", source) 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), checkorcensure) 
  

Link to comment
WorksToCensor = { "hacker", "hack", "cheater", "cheat", "Hacker", "Hack", "Cheater", "Cheat" } 
  
function checkorcensure (message,messageType) 
local strings = split ( message , 32 ) 
for i, v in pairs ( strings ) do 
str = string.lower ( v ) 
for a, b in pairs ( WorksToCensor ) do 
if ( string.find ( str, b ) ) then 
outputChatBox("Use /report!", source) 
cancelEvent() 
end 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), checkorcensure) 

i think it works :P

Link to comment

i think it works :P

yuo should've made str local, and there's no point in splitting the message of you're using string.find, imo.

and "hacker" will already be found by "hack".

WorksToCensor = { "hack",  "cheat" } 
  
function checkorcensure(message,messageType) 
  for k, word in ipairs(WorksToCensor) do 
    if string.find(message:lower(), word, 1, true) then 
      outputChatBox("Use /report!", source) 
      cancelEvent() 
      return 
    end 
  end 
end 
addEventHandler("onPlayerChat", getRootElement(), checkorcensure) 

Link to comment
WorksToCensor = { "hacker", "hack", "cheater", "cheat", "Hacker", "Hack", "Cheater", "Cheat" } 
  
function checkorcensure (message,messageType) 
local strings = split ( message , 32 ) 
for i, v in pairs ( strings ) do 
str = string.lower ( v ) 
for a, b in pairs ( WorksToCensor ) do 
if ( string.find ( str, b ) ) then 
outputChatBox("Use /report!", source) 
cancelEvent() 
end 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), checkorcensure) 

i think it works :P

thanks bro, it works! xD

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