Jump to content

Solved.


RaiN_

Recommended Posts

i am trying create an anti divulgation script, but don't works

my code:

function Divulguer (message,messageType) 
 if string.find ( message, "%d+.%d+.%d+.%d+:%d+" ) or string.find ( message, "%d+.%d+.%d+.%d+" ) or string.find ( message, "mtasa://" ) then 
    --banPlayer ( source, true, false, true, "x", 0 ) -- Removed For Testing.... 
      outputChatBox ( "IP Found !", root ) 
else 
     outputChatBox ( "No IP Found !", root ) 
    end 
end 
addEventHandler ( "onPlayerChat", root, Divulguer ) 

Edited by Guest
Link to comment

You can use:

string.find(message, "mtasa://%d+.%d+.%d+.%d+") -- Matches a complete mtasa IP 
string.find(message, "mtasa://") -- if "mtasa://" exists in the message. 
string.find(message, "%d+.%d+.%d+.%d+") -- if there is an IP in the message.  

Link to comment
  
addEventHandler("onPlayerChat",root,function(message) 
    local Pattern = "[mtasa://]?%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?[:%d%d%d%d%d?]?"; -- simple pattern for detecting an IP address; 
    if message:find(Pattern) then -- if the message contains an IP address; 
        cancelEvent(); -- cancel the chat event; 
        local Result,Matches = message:gsub(Pattern,""); -- remove the IPs, no need to ban the player for a simple IP, maybe he wrote it by mistake; 
        outputServerLog("WARNING! - "..tostring(Matches).." IPs detected in chat message \""..message.."\". Removing them."); 
        outputChatBox(Result,root); -- output the new message with no IPs to the chatbox; 
    end 
end); 
  

  • Like 1
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...