Jump to content

Anti Spam Help me


1LoL1

Recommended Posts

Please someone help me at all it does not unmute here is my client and server, and even who will spam my GlobalChate so that it's even there could Mute

-- Client

------------------------------------------------------------------------------------ 
local spamCount = 0 
local repeatedMessages = { } 
local repeatedMessageCount = 0 
local banCount = 5 
local muteCount = 3 
local decreaseTime = 4 
local oldTick 
local warned = false 
function resetRepeatedMessages ( ) 
    repeatedMessages = nil 
    repeatedMessages = { } 
end 
setTimer ( resetRepeatedMessages, 15000, 0 ) 
---------------------------------------------------- 
function getPlayerUncoloredName (player) 
local nick = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") 
return nick 
end 
  
function echo (message) 
outputChatBox(message, 255,0,0) 
end 
  
function antispamCheckFunc ( message ) 
if string.find(message, "say") then 
    if spamCount > banCount then 
        decreaseSpamCount ( ) 
    end 
    local newTick = getTickCount ( ) 
    if spamCount == 0 then 
        oldTick = getTickCount ( ) 
    end  
    if spamCount > 0 and newTick-oldTick > 15000 then 
        spamCount = 0 
        triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 60*3, '[!] #ff5500'..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..' #ff5500has been muted for 3 minutes', 'Spam') 
    end 
    if spamCount > 5 and ( newTick-oldTick ) < spamCount * 600 then 
        spamCount = 0 
        if warned then 
            triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 120*60, '[!] #ff5500 '..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..' #ff5500has been muted for 30 minutes', 'Repeated Spam flood' ) 
        else 
            warned = true 
            triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 10*60, '[!] #ff5500 '..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..' #ff5500has been muted for 10 minutes', 'Spam flood' ) 
            echo ( "*Warning: Next time ban for 1 hour!" ) 
        end 
        return 1 
    end 
    local found = false 
    for k, var in ipairs ( repeatedMessages ) do 
        --outputDebugString ( 'Message: "'..tostring ( var [ 1 ] )..'" called ' ..tostring ( var [ 2 ] )..' times ', 0, 60, 60, 220 ) 
        if var [ 1 ] == message then 
            if not type ( var [ 2 ] ) == "number" then 
                var [ 2 ] = 0 
            end 
            var [ 2 ] = var [ 2 ] + 1 
            if var [ 2 ] > 10 then 
                triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 5*60, '[!] #ff5500'..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..'#FE4141 has been muted for 5 minutes', 'Repeating the same phrase' )              
                var [ 2 ] = 7 
            elseif var [ 2 ] > 6 then 
                 
                --echo ( "*Warning: Do not say the same again and again!" ) 
                 
            end 
            found = true 
            break 
        end 
    end 
    if not found then 
        table.insert ( repeatedMessages, { message, 0 } ) 
    end 
    spamCount = spamCount + 1 
    setTimer ( decreaseSpamCount, decreaseTime * 1000, 1 ) 
end 
end 
--addEvent ( "onLocalPlayerChat", true ) 
addEventHandler ( "onClientConsole", root, antispamCheckFunc ) 
------------------------------------------------------------------------------------ 
function decreaseSpamCount ( ) 
    if spamCount > 0 then 
        if spamCount > banCount then 
            spamCount = 0 
            if warned then 
                triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 30*60, '[!] #ffffff'..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..'#4876FF has been muted for 30 minutes', 'Repeated Spam flood' ) 
            else 
                warned = true 
                triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 10*60, '[!] #ffffff'..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..'#4876FF has been muted for 10 minutes', 'Spam flood' ) 
                echo ( "*Warning: Next time ban for 2 hours!" ) 
            end 
        elseif spamCount > muteCount then 
            triggerServerEvent ( 'onPlayerSpam', getLocalPlayer ( ), 'mute', 3*60, '[!] #ffffff '..getPlayerUncoloredName ( getLocalPlayer ( ) ) ..'#4876FF has been muted for 3 minutes',  'Spam' ) 
            spamCount = 0 
        end 
        spamCount = spamCount - 1 
    end 
end 

-- Server

function unmuteSpammer (serial, account) 
--if isPlayerMuted(player) then 
--setPlayerMuted(player, false) 
  
--outputChatBox("#41FE5B[!]#84F994 " .. string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") .. " #41FE5Bhas been automatically unmuted!",getRootElement(), 255,0,0,true) 
--end 
mysql_query(handle, "UPDATE prohresky SET muted = 'false' WHERE prohresky.serial = '" .. serial .. "'") 
end 
  
  
  
addEvent("onPlayerSpam", true) 
  
addEventHandler("onPlayerSpam", getRootElement(), 
  
function (action, time, message, reason) 
if (isPlayerMuted(source) == false) then 
outputChatBox(message .. " (" .. reason .. ")", getRootElement(), 255,0,0,true) 
  
if action == "mute" then  
local time2 = time * 1000 
setPlayerMuted(source, true) 
--outputChatBox(time2) 
serialu = serialu + 1 
serialy[serialu] = getPlayerSerial(source) 
local nick = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "") 
setTimer(unmuteSpammer, time2, 1, serialy[serialu], getPlayerAccount(source)) 
setElementData(source, "muted", true) 
  
mysql_query(handle, "INSERT INTO `DM_svr`.`prohresky` (`serial`, `muted`) VALUES ('" .. getPlayerSerial(source) .. "', 'true')") 
  
  
elseif action == "ban" then 
--outputChatBox("Mas ban..")   
end 
end 
  
end) 
  
addCommandHandler("testing", 
function(player) 
outputChatBox(tostring(isPlayerMuted(player))) 
end) 
  
addEventHandler("onPlayerJoin", getRootElement(), 
  
function () 
  
local result = mysql_query(handle,"SELECT * FROM prohresky WHERE serial='"..getPlayerSerial(source).."'") 
    --if mysql_result(result,1,1)==login then 
        for i,v in mysql_rows(result) do 
            if (v[1] == getPlayerSerial(source)) and not (v[2] == "false") then 
                setPlayerMuted(source, true) 
                outputChatBox("[!] #ff5500" .. string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "") .. " #ff5500has been automatically muted!", getRootElement(), 255,0,0,true) 
            end 
              
        end 
    --end 
     
     
    mysql_free_result(result)  
  
end) 
  
function unmutePlayers () 
  
players = getElementsByType("player") 
  
for _, player in ipairs(players) do 
--outputDebugString("unmutePlayers spusteno")  
local serial = getPlayerSerial(player) 
if isPlayerMuted(player) then 
result = mysql_query(handle, "SELECT * FROM prohresky WHERE prohresky.serial = '" .. serial .. "'") 
for i,v in mysql_rows(result) do 
            if (v[1] == getPlayerSerial(player)) and (v[2] == "false") then 
                setPlayerMuted(player, false) 
                mysql_query(handle, "DELETE FROM prohresky WHERE prohresky.serial = '" .. serial .. "'") 
                outputChatBox("#ff5500[!]#ff5500 " .. string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") .. " #ff5500has been automatically unmuted!",getRootElement(), 255,0,0,true) 
            end 
              
        end 
end 
end 
end 
  
setTimer(unmutePlayers, 30000, 0) 
  
voice = true 
  
function adminChangeVoice (player, cmd) 
if hasObjectPermissionTo ( player, "command.toggleVoice", false ) then 
    if voice then 
        voice = false 
        outputChatBox("#FE4141[!] Administrator #FF6F6F" .. string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") .. " #FE4141has disabled voice chat!", getRootElement(), 255, 0,0,true) 
    else 
        voice = true 
        outputChatBox("#41FE5B[!] Administrator #84F994" .. string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") .. " #41FE5B has enabled voice chat!", getRootElement(), 255, 0,0,true) 
    end 
end 
end 
  
addCommandHandler("voice", adminChangeVoice) 
  
addEventHandler("onPlayerVoiceStart", getRootElement(), 
  
function () 
  
if not voice then 
    cancelEvent() 
    return 
end 
  
for i,player in ipairs(getElementsByType("player")) do 
  
if tonumber(getElementData(player, "adminlvl")) > 1 then 
outputChatBox("Hrac " .. string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "") .. " spustil voice!", player) 
end 
end 
end) 
  
function countThat (msg, type) 
if type == 0 then 
if string.find(msg, "!count") then 
    setTimer(outputChatBox, 100, 1, "#ff5500* " .. getPlayerCount(), root, 255, 0, 0, true) 
end 
end 
end 
  
addEventHandler("onPlayerChat", getRootElement(), countThat) 
  

-- GlobalChat Server

function globalMessage ( thePlayer, cmd, ... ) 
    if isPlayerMuted ( thePlayer ) then 
        outputChatBox ( "You are muted!", thePlayer, 255, 0, 0 ) 
        return 
    end 
  
    local message = table.concat ( { ... }, " " ) 
    local name = getPlayerName ( thePlayer ) 
    outputChatBox ( "#009BFFGlobalChat: #FFFFFF".. name ..": #99FF00".. message, getRootElement(), 255, 255, 255, true ) 
end 
addCommandHandler ( "global", globalMessage ) 

Link to comment
  • Moderators
Don't steal code you can't even understand.

Stolen? : o You mean when I download a script so steal? : O: O: O

There is a difference between leaked and stolen code.

A leaked code is the source code of something that shouldn't be available to the public.

A stolen code is a source code that you found on the internet and you just copied and pasted.

We sometimes help scripters with stolen code if we know they are getting better by really watching the wiki and if we see he learned the basis. And yeah, this is not your case, you are just stealing code and try to put them on your server without learning at all by creating a new topic on this forum almost twice a day.

https://wiki.multitheftauto.com/wiki/Main_Page

Link to comment
Don't steal code you can't even understand.

Stolen? : o You mean when I download a script so steal? : O: O: O

There is a difference between leaked and stolen code.

A leaked code is the source code of something that shouldn't be available to the public.

A stolen code is a source code that you found on the internet and you just copied and pasted.

We sometimes help scripters with stolen code if we know they are getting better by really watching the wiki and if we see he learned the basis. And yeah, this is not your case, you are just stealing code and try to put them on your server without learning at all by creating a new topic on this forum almost twice a day.

https://wiki.multitheftauto.com/wiki/Main_Page

When you need help here so I can create a theme and 5 times but prefer to let someone lock ..

Link to comment
A stolen code is a source code that you found on the internet and you just copied and pasted.

False.

You don't steal if you copy/paste a script that doesn't belongs to you . But you DO steal if you copy/paste a script that doesn't belongs to you , but you claim that the script is yours and you made that script.

He didn't said anything about the ownership of the script , but you shouldn't banish him for something he didn't do.

The same thing happens in music , have you ever heard of mixtape ?

It's basically a singer who doesn't have money to buy beats , and uses free ones , that can be downloaded from a public space .

(In our case , MTA:SA Community )

Link to comment
A stolen code is a source code that you found on the internet and you just copied and pasted.

False.

You don't steal if you copy/paste a script that doesn't belongs to you . But you DO steal if you copy/paste a script that doesn't belongs to you , but you claim that the script is yours and you made that script.

He didn't said anything about the ownership of the script , but you shouldn't banish him for something he didn't do.

The same thing happens in music , have you ever heard of mixtape ?

It's basically a singer who doesn't have money to buy beats , and uses free ones , that can be downloaded from a public space .

(In our case , MTA:SA Community )

I write rather let someone lock ...

Link to comment

But helping people who are s***** is annoying.

If he made that script, but now is stuck at some point, there wouldn't be a problem.

But he just copies/steals whatever it somewhere and expects the people on this forum to make it work for him.

No, thanks.

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