Jump to content

[APORTE] Global chat + antispam IP + preventive


Recommended Posts

Este es un global chat con muteador permanente, es decir, aunque se reconecte, no va a impedir que siga muteado, ale, que se jodan los spammers una vez más.

https://community.multitheftauto.com/index.php?p=resources&s=details&id=12177

precio_mensaje = 0 --pos eso ._. el precio, si se deja en 0 no se quitará dinero, una tonteria si se va a usar en DayZ 
segundos_flood = 10 --segundos antes de poder hablar de nuevo 
--[[ 
[*] -> El jugador que spamee una direccion IP de un servidor, es automaticamente MUTEADO para siempre 
]] 
spam = {} 
permamute = {} 
ip = { 
--[[ INIT 4 SLOT ]] 
"%d%d%d%.%d%d%d%.%d%d%d%.%d", 
"%d%d%d%.%d%d%d%.%d%d%.%d", 
"%d%d%d%.%d%d%d%.%d%.%d", 
"%d%d%d%.%d%d%.%d%d%d%.%d", 
"%d%d%d%.%d%d%.%d%d%.%d", 
"%d%d%d%.%d%d%.%d%.%d", 
"%d%d%d%.%d%.%d%d%d%.%d", 
"%d%d%d%.%d%.%d%d%.%d", 
"%d%d%d%.%d%.%d%.%d", 
--[[ INIT 3 SLOT ]] 
"%d%d%.%d%d%d%.%d%d%d%.%d", 
"%d%d%.%d%d%d%.%d%d%.%d", 
"%d%d%.%d%d%d%.%d%.%d", 
"%d%d%.%d%d%.%d%d%d%.%d", 
"%d%d%.%d%d%.%d%d%.%d", 
"%d%d%.%d%d%.%d%.%d", 
"%d%d%.%d%.%d%d%d%.%d", 
"%d%d%.%d%.%d%d%.%d", 
"%d%d%.%d%.%d%.%d", 
--[[ INIT 2 SLOT ]] 
"%d%.%d%d%d%.%d%d%d%.%d", 
"%d%.%d%d%d%.%d%d%.%d", 
"%d%.%d%d%d%.%d%.%d", 
"%d%.%d%d%.%d%d%d%.%d", 
"%d%.%d%d%.%d%d%.%d", 
"%d%.%d%d%.%d%.%d", 
"%d%.%d%.%d%d%d%.%d", 
"%d%.%d%.%d%d%.%d", 
"%d%.%d%.%d%.%d" 
} 
addEventHandler("onPlayerJoin", root, 
    function () 
        if permamute[getPlayerSerial(source)] then 
        setPlayerMuted(source, true) 
        end 
    end 
) 
addEventHandler("onPlayerChat", root, 
    function (msg, tipo) 
        while msg:find("#%x%x%x%x%x%x") do 
        msg = msg:gsub("#%x%x%x%x%x%x", "") 
        end 
        if spam[getPlayerSerial(source)] then 
            if spam[getPlayerSerial(source)] > getTickCount() then 
            outputChatBox("#FF5000[Global Chat]#FF0000 No puedes floodear en chat global ["..tostring(math.floor(spam[getPlayerSerial(source)]/1000)).. "segundos restantes]", source, 0,0,0,true) 
            end 
        else 
        spam[getPlayerSerial(source)] = getTickCount() + (1000*segundos_flood) 
        end 
        if getPlayerMoney(source) <= precio_mensaje then 
        outputChatBox("#FF5000[Global Chat]#FF0000 Necesitas "..tostring(precio_mensaje).." para hablar por global", source, 0,0,0,true) 
        return 
        end 
    takePlayerMoney(source, precio_mensaje) 
        for k,v in ipairs(ip) do 
            if string.find(msg, v) then 
            outputChatBox("#FF5000[Global Chat]#FF0000 Has sido muteado permanentemente por spamear",source, 0,0,0,true) 
            permamute[getPlayerSerial(source)] = true 
            spam[getPlayerSerial(source)] = getTickCount() +(1000*segundos_flood) 
            setPlayerMuted(source, true) 
            return 
            end 
        end 
        if tipo == 0 then 
        outputChatBox("#FF0000[GLOBAL]#FFFFFF "..getPlayerName(source).."#FFFFFF: "..msg, root, 0,0,0,true) 
        outputServerLog("[GLOBAL] "..getPlayerName(source):gsub("#%x%x%x%x%x%x").."["..getPlayerSerial(source).."] > "..msg) 
        spam[getPlayerSerial(source)] = getTickCount() + (1000*segundos_flood) 
        end 
    end 
) 

Edited by Guest
Link to comment
Sólo leyendo el código encontré un bug para evadir el anti-hexa :x

Cual bug es?

  
text = "##000000ff0000 Hello" 
print(text:gsub("#%x%x%x%x%x%x", "")) -- #ff0000 Hello   1 
  

Para solucionarlo,

  
text = "##000000ff0000 Hello" 
  
while text:find("#%x%x%x%x%x%x") do 
text = text:gsub("#%x%x%x%x%x%x", "")  
end 
  
print(text) -- Hello 
  

También te faltó el tercer argumento del gsub

Link to comment
Sólo leyendo el código encontré un bug para evadir el anti-hexa :x

Cual bug es?

  
text = "##000000ff0000 Hello" 
print(text:gsub("#%x%x%x%x%x%x", "")) -- #ff0000 Hello   1 
  

Para solucionarlo,

  
text = "##000000ff0000 Hello" 
  
while text:find("#%x%x%x%x%x%x") do 
text = text:gsub("#%x%x%x%x%x%x", "")  
end 
  
print(text) -- Hello 
  

También te faltó el tercer argumento del gsub

Mañana lo integro. No sabia que habia ese bug.. tendre que reescriptear al servidor.

37900128.jpg

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