#Paper Posted January 2, 2011 Share Posted January 2, 2011 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
Castillo Posted January 2, 2011 Share Posted January 2, 2011 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 Link to comment
Aibo Posted January 2, 2011 Share Posted January 2, 2011 i think it works 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
Castillo Posted January 2, 2011 Share Posted January 2, 2011 My bad, i'm sleepy thats why Link to comment
#Paper Posted January 2, 2011 Author Share Posted January 2, 2011 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 thanks bro, it works! 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