Furious^ONE! Posted July 2, 2016 Share Posted July 2, 2016 Hello, i want add ban player if he say ip MTA, but this script don't work.. can you help me please ? local insults = { "mtasa://" } local replace_sentence = { "#ff0000ยก#@!" } local max_insult = 3; local uebereinstimmungsrate = 4; local handle_type = 1; -- handle_type 1 = replaces the offense with a gay word -- handle_type 2 = kicks a user searches for "max_insult" from the server. -- handle_type 3 = recursively also sets up terms (not being completed) -- handle_type 4 = undertakes nothing addEventHandler("onPlayerChat", root, function(message, _type) for index, val in pairs(insults) do local new_val = val:lower(); local message = message:lower(); local match = false; local laufwert = 0; if message:len() > new_val:len() then laufwert = new_val:len(); elseif message:len() < new_val:len() then laufwert = message:len(); elseif message:len() == new_val:len() then laufwert = new_val:len(); end if ( handle_type == 3 ) then local currentLaufwert = 1; local match = false; local break_schleife = false; laufwert = message:len(); local inte_laufwert = 1; local search_in_text_match = false while ( inte_laufwert < laufwert+1 and search_in_text_match == false ) do if ( string.byte(tostring(message), inte_laufwert) == string.byte(new_val) ) then search_in_text_match = true if inte_laufwert == 1 then outputDebugString("A"); end end inte_laufwert = inte_laufwert+1 end if search_in_text_match then while ( (currentLaufwert < laufwert+1) and ( break_schleife == false ) ) do if ( string.byte(tostring(message), currentLaufwert+inte_laufwert) ) then if ( string.byte(tostring(message), currentLaufwert+inte_laufwert) ~= string.byte(tostring(new_val), currentLaufwert) ) then break_schleife = true else if ( currentLaufwert >= uebereinstimmungsrate ) then match = true break_schleife = true end end currentLaufwert = currentLaufwert+1 end end end elseif ( handle_type == 2 ) then local currentLaufwert = 1; local break_schleife = false; while ( (currentLaufwert < laufwert+1) and ( break_schleife == false ) ) do if ( string.byte(tostring(message), currentLaufwert) ~= string.byte(tostring(new_val), currentLaufwert) ) then break_schleife = true else if ( currentLaufwert >= uebereinstimmungsrate ) then match = true break_schleife = true end end currentLaufwert = currentLaufwert+1 end if ( match ) then cancelEvent(); handle_match(1); break; end elseif ( handle_type == 1 ) then local currentLaufwert = 1; local break_schleife = false; while ( (currentLaufwert < laufwert+1) and ( break_schleife == false ) ) do if ( string.byte(tostring(message), currentLaufwert) ~= string.byte(tostring(new_val), currentLaufwert) ) then break_schleife = true else if ( currentLaufwert >= uebereinstimmungsrate ) then match = true break_schleife = true end end currentLaufwert = currentLaufwert+1 end if ( match ) then cancelEvent(); handle_match(2); break; end end end end) function handle_match(_type) if ( _type == 1 ) then local oriVal = getElementData(source, "b_count") if ( oriVal == false ) then setElementData(source, "b_count", 1); oriVal = 1; else oriVal = oriVal+1 setElementData(source, "b_count", oriVal) end if ( oriVal > max_insult ) then kickPlayer(source, source, "") else outputChatBox(string.format("", oriVal, val), source, 255, 0, 0) end elseif ( _type == 2 ) then local rand = math.random(1, #replace_sentence); outputChatBox(string.format("", replace_sentence[rand]), root, 255, 255, 255, true); end outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) outputChatBox (" ",getRootElement(), 255, 255, 0,true ) Link to comment
Walid Posted July 2, 2016 Share Posted July 2, 2016 try something like this: local words = {"mtasa://","22003"} addEventHandler("onPlayerChat",root, function (msg,type) if type == 0 or type == 1 or type == 2 then for i, v in pairs(words) do if string.find(msg,string.lower(v)) then local playerName = getPlayerName(source) local r,g,b = getPlayerNametagColor(source) outputChatBox(playerName..": advertiser was detected and he got kicked" , root,r,g,b, false) banPlayer (source, false, false, true,"Console", "Don't advertise!") end end end cancelEvent() 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