Jump to content

help with anti-spam


adithegman

Recommended Posts

hello guys, i have a problem with the anti-spam and hope you guys can solve it :) it outputChatBox well cuz' i see for ex Adithegman has been muted... but it doesn't mute me for 1 min, i can still speak note: this is server-side

antiSpam = {} 
function antiChatSpam() 
    if isTimer(antiSpam[source]) then 
        cancelEvent()   
        outputChatBox("#ffffff"..getPlayerName(source).." has been #ff0000muted #fffffffor for 60 seconds, reason: #ff0000spam", getRootElement(), 255, 255, 0,true) 
        setPlayerMuted ( source, true ) 
        setTimer ( autoUnmute, 60000, 1, source) 
    else 
        antiSpam[source] = setTimer(function(source) antiSpam[source] = nil end, 1000, 1, source) 
    end 
end 
addEventHandler("onPlayerChat", root, antiChatSpam) 
  
local commandSpam = {} 
 function preventCommandSpam( command ) 
 if command == "say" then 
    if (not commandSpam[source]) then 
        commandSpam[source] = 1 
    elseif (commandSpam[source] == 5) then 
        cancelEvent() 
        outputChatBox("#ffffff"..getPlayerName(source).." has been #ff0000muted #fffffffor for 60 seconds, reason: #ff0000spam!", getRootElement(), 255, 255, 0,true) 
        setPlayerMuted( source, true ) 
        setTimer ( autoUnmute, 60000, 1, source) 
    else 
        commandSpam[source] = commandSpam[source] + 1 
    end 
  end 
end 
addEventHandler("onPlayerCommand", root, preventCommandSpam) 
setTimer(function() commandSpam = {} end, 1000, 0) 
  
function autoUnmute ( source ) 
    setPlayerMuted ( source, false ) 
end 

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