Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-12-16, 15:28


mis14







Wiek: 25
Na forum: 4065 dni
Posty: 185

Piwa: 73

Respekt: -149

witam chc? zrobi? system anty spam lecz nie chc? ?e po 1 napisaniu w??cza si? anty spam tylko po wys?aniu 10 wiadomo?ci na okres 30 s kod

--[[
    Resource: OURGame
    Developers: Split <split.programista@gmail.com>
    Copyright <split.programista@gmail.com> 2015-2016
    You have no right to use this code without my permission.
]]
wiadomosci= {}
words = {"22003",":220","78.157","23.235","22015","22010","22020","22017","mtasa://"}

local czas = 1*60*1000 --1 minuta


local getplayernamex = getPlayerName

local function getPlayerName(plr)
if not plr then return end
if isElement(plr) then
return getplayernamex(plr):gsub("#%x%x%x%x%x%x","")
end
end

function getPlayerName2(plr)
if not plr then return end
if isElement(plr) then
return getPlayerName(plr):gsub("#%x%x%x%x%x%x","")
end
end

local function wtf(player)
if not player then return end
if isElement ( player ) then
    if not wiadomosci[player] then return end
    wiadomosci[player].text = nil; 
    wiadomosci[player].warnings = 0 
end 
end


function sprawdzmute(plr,msg)
    if not wiadomosci[plr] then
        wiadomosci[plr] = {
            lastmessage = { },
            text = { },
            toggle = false,
            unmute = { },
            warnings = 0,
        }
    end
    if wiadomosci[plr].warnings >= 6 then
        kickPlayer(plr,"SPAM")
         triggerClientEvent(root, "admin:rendering", root, "* "..getPlayerName(plr).."("..getElementData(plr,"id")..") zosta?(a) wyrzucony(a) przez system. Powod: Spam")
    return true end
    if wiadomosci[plr].toggle then local pozostalyczas,_,_ = getTimerDetails(wiadomosci[plr].unmute); pozostalyczas = pozostalyczas/1000/60;local tekst=("* Posiadasz mute! Pozostaly czas to %.2f minut!"):format(pozostalyczas); outputChatBox(tekst,plr,255,0,0);   wiadomosci[plr].warnings = wiadomosci[plr].warnings + 10 cancelEvent() return true end
    if wiadomosci[plr].warnings > 4 and not wiadomosci[plr].toggle then
                    wiadomosci[plr].toggle = true
                    wiadomosci[plr].unmute = setTimer ( function ( player ) if isElement ( player ) then wiadomosci[player].toggle = false end end, czas, 1, plr )
                    local pokazczas = czas/1000
                    local tekst = ("[Anty-SPAM] Dosta?e? muta za spam! na "..pokazczas.." sekund(-y).")
                    outputChatBox(tekst, plr, 0, 170, 255)
            return true end
    if wiadomosci[plr].text == msg then
            if wiadomosci[plr].toggle ~= true then
                    wiadomosci[plr].toggle = true
                    wiadomosci[plr].unmute = setTimer ( function ( player ) if isElement ( player ) then wiadomosci[player].toggle = false end end, czas, 1, plr )
                    local pokazczas = czas/1000
                    local tekst = ("[Anty-SPAM] Dosta?e? muta za spam! na "..pokazczas.." sekund(-y).")
                    outputChatBox(tekst, plr, 0, 170, 255)
            return true end
    end
    if isTimer(wiadomosci[plr].lastmessage) then killTimer(wiadomosci[plr].lastmessage) end
   wiadomosci[plr].lastmessage = setTimer ( wtf, 5000, 50, plr )
   wiadomosci[plr].warnings = wiadomosci[plr].warnings + 1
   wiadomosci[plr].text = msg
   return false
end


addEventHandler('onPlayerChat', root, function(msg, type)
    cancelEvent()
    if not getElementData(source,"player:uid") then cancelEvent() triggerClientEvent(root, "admin:rendering", root, "* "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").."("..getElementData(source,"id")..") zosta?(a) wyrzucony(a) przez system. Powod: Najpierw sie zaloguj")
    kickPlayer (source, "System:Najpierw sie zaloguj")
    return end
    local tick=getTickCount()
    if sprawdzmute(source,msg) then cancelEvent() return end
    if type==0 then
        cancelEvent()
        if ninjaban(msg) and not getAdmin(source, 4) then
        triggerClientEvent(root, "admin:rendering", root, "* "..getPlayerName(source).."("..getElementData(source,"id")..") zosta?(a) wyrzucony(a) przez system. Powod: Reklama")
        kickPlayer (source, "System:Reklama")
        return end
        local resultA=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_punish WHERE typ=? AND active=1 AND serial=? AND time>NOW() LIMIT 1","mute", getPlayerSerial(source))
        if #resultA > 0 then 
            outputChatBox(" " ,source, 255,255,255,true)
            outputChatBox("#ff0000&#10008; #ffffffZosta?e? zmutowany do: #ff0000"..resultA[1].time.." #ffffffpow?d:#ff0000 "..resultA[1].reason ,source, 255,255,255,true)
                    outputChatBox(" " ,source, 255,255,255,true)
        return end
        if not isElement(source) then return end
        local x,y,z=getElementPosition(source)
        local sphere=createColSphere(x,y,z, 30)
        local players=getElementsWithinColShape(sphere, 'player')
        --if #players == 1 then
        --    destroyElement(sphere)
        --    outputChatBox("W pobli?u nie znaleziono ?adnych graczy, wiadomo?? nie zosta?a wys?ana.", source, 255, 255, 255)
        --    return
        --end
        for i,v in pairs(players) do
                id=getElementData(source,"id")
            outputChatBox("#FFFFFF"..getPlayerName(source).." [#0061F4ID:"..id.."#FFFFFF]: "..msg:gsub("#%x%x%x%x%x%x",""), v, _, _, _, true)
        end
        destroyElement(sphere)

        local desc = string.format("Czat Lokalny> %s(%d): %s",getPlayerName(source),id,msg:gsub("#%x%x%x%x%x%x",""))
        --triggerClientEvent(root, "admin:addText", root, desc)
        triggerClientEvent(root, "onDebugMessage", resourceRoot, desc:gsub("#%x%x%x%x%x%x",""),1, "CZAT")
        triggerEvent("admin:addText", resourceRoot, desc:gsub("#%x%x%x%x%x%x",""),math.random(0,99))
        x,y,z=getElementPosition(source)
        exports["ogrpg-db"]:dbSet("insert into Logi_chat_lokalny values(NULL,NOW(),?,?,?,?)",getPlayerName(source),msg,getPlayerSerial(source),toJSON({math.floor(x),math.floor(y),math.floor(z)},true))
        elseif type==1 then
        cancelEvent()
        if ninjaban(msg) and not getAdmin(source, 4) then
        kickPlayer (source, "System:Reklama")
        triggerClientEvent(root, "admin:rendering", root, "* "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").."("..getElementData(source,"id")..") zosta?(a) wyrzucony(a) przez system. Powod: Reklama")
        return end
        local x,y,z=getElementPosition(source)
        local sphere=createColSphere(x,y,z, 30)
        local players=getElementsWithinColShape(sphere, 'player')
        destroyElement(sphere)
        for i,v in pairs(players) do
            id=getElementData(source,"id")
            outputChatBox("** "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").." "..msg:gsub("#%x%x%x%x%x%x",""), v, 255, 128, 255)
        end
        local q = string.format(">>/ME "..getPlayerName(source).."("..getElementData(source,"id").."): "..msg:gsub("#%x%x%x%x%x%x",""))
        triggerEvent("admin:addText", resourceRoot, q:gsub("#%x%x%x%x%x%x",""),math.random(0,99))
        triggerClientEvent("onDebugMessage", resourceRoot, q,1, "/ME")
    x,y,z=getElementPosition(source)
        exports["ogrpg-db"]:dbSet("insert into Logi_chat_lokalny_me values(NULL,NOW(),?,?,?,?)",getPlayerName(source),msg,getPlayerSerial(source),toJSON({math.floor(x),math.floor(y),math.floor(z)},true))
    end
end)


addCommandHandler('do', function(source, cmd, ...)
    local text=table.concat({...}, ' ')
    if not text then return end
        if ninjaban(text) and not getAdmin(source, 4) then
        triggerClientEvent(root, "adminRender", root, ""..getPlayerName(source).." zosta? wyrzucony przez System, pow?d: Reklama")
        kickPlayer (source, "System:Reklama")
        return end
    local msg=table.concat({...}, " ")
    if sprawdzmute(source,msg) then return cancelEvent() end
    local resultA=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_punish WHERE typ=? AND active=1 AND serial=? AND time>NOW() LIMIT 1","mute", getPlayerSerial(source))
        if #resultA > 0 then 
            outputChatBox("#ff0000&#10008; Jeste? zmutowany, nie mo?esz korzysta? z tej komendy!! ("..resultA[1].time..")" ,source, 255,255,255,true)
        return end
    local x,y,z=getElementPosition(source)
    local sphere=createColSphere(x,y,z, 30)
    local players=getElementsWithinColShape(sphere, 'player')
    destroyElement(sphere)


    for i,v in ipairs(players) do
        outputChatBox("** "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").." "..msg, v, 071,074,081)
    end
local q = string.format(">>/DO "..getPlayerName(source).."("..getElementData(source,"id").."): "..msg:gsub("#%x%x%x%x%x%x",""))
        triggerEvent("admin:addText", resourceRoot, q:gsub("#%x%x%x%x%x%x",""),math.random(0,99))
        triggerClientEvent("onDebugMessage", resourceRoot, q,1, "/DO")
        x,y,z=getElementPosition(source)
        exports["ogrpg-db"]:dbSet("insert into Logi_chat_lokalny_do values(NULL,NOW(),?,?,?,?)",getPlayerName(source),msg,getPlayerSerial(source),toJSON({math.floor(x),math.floor(y),math.floor(z)},true))
    end)


addCommandHandler('me', function(source, cmd, ...)
    local text=table.concat({...}, ' ')
    if not text then return end
        if ninjaban(text) and not getAdmin(source, 4) then
        triggerClientEvent(root, "adminRender", root, ""..getPlayerName(source).." zosta? wyrzucony przez System, pow?d: Reklama")
        kickPlayer (source, "System:Reklama")
        return end
    local msg=table.concat({...}, " ")
    if sprawdzmute(source,msg) then return cancelEvent() end
    local resultA=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_punish WHERE typ=? AND active=1 AND serial=? AND time>NOW() LIMIT 1","mute", getPlayerSerial(source))
        if #resultA > 0 then 
            outputChatBox("#ff0000&#10008; Jeste? zmutowany, nie mo?esz korzysta? z tej komendy!! ("..resultA[1].time..")" ,source, 255,255,255,true)
        return end
    local x,y,z=getElementPosition(source)
    local sphere=createColSphere(x,y,z, 30)
    local players=getElementsWithinColShape(sphere, 'player')
    destroyElement(sphere)


    for i,v in ipairs(players) do
        outputChatBox("** "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").." "..msg, v, 071,074,081)
    end
local q = string.format(">>/DO "..getPlayerName(source).."("..getElementData(source,"id").."): "..msg:gsub("#%x%x%x%x%x%x",""))
        triggerEvent("admin:addText", resourceRoot, q:gsub("#%x%x%x%x%x%x",""),math.random(0,99))
        triggerClientEvent("onDebugMessage", resourceRoot, q,1, "/DO")
        x,y,z=getElementPosition(source)
        exports["ogrpg-db"]:dbSet("insert into Logi_chat_lokalny_do values(NULL,NOW(),?,?,?,?)",getPlayerName(source),msg,getPlayerSerial(source),toJSON({math.floor(x),math.floor(y),math.floor(z)},true))
    end)

--function globalMessage(thePlayer, cmd, ...)
    --if getElementData(thePlayer, "player:premium") == false then outputChatBox("Musisz posiada? status premium by pisa? na czacie globalnym!",thePlayer) return end
    --local message = table.concat ( { ... }, " " )
    --local name = getPlayerName(thePlayer)
    --outputChatBox("#FF0000[GLOBAL]#00FF00"..name..": #FFFFFF"..message, getRootElement(), 255, 255, 255, true)
    --end
--addCommandHandler("global", globalMessage)



addCommandHandler('vmoje', function(plr, cmd)
    local uid=getElementData(plr,'player:uid')
    if not uid then return end
    outputChatBox('* Twoje pojazdy (zrespione na mapie): ', plr)
    outputChatBox('====================================', plr)

    local vehicles=getElementsByType('vehicle')
    for i,v in pairs(vehicles) do
        if getElementData(v,'vehicle:ownedPlayer') and getElementData(v,'vehicle:ownedPlayer')==uid then
            outputChatBox("* Nazwa: "..getVehicleNameFromModel(getElementModel(v))..", ID: "..getElementData(v,"vehicle:id"), plr)
        end
    end
end)


function ninjaban(ip)
    -- must pass in a string value
    if ip == nil or type(ip) ~= "string" then
        return false
    end

    -- check for format 1.11.111.111 for ipv4
    local chunks = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
    if (#chunks == 4) then
        for _,v in pairs(chunks) do
            if (tonumber(v) < 0 or tonumber(v) > 255) then
                return false
            else
            return true
            end
        end
    else
        return false
    end

    return false
end






Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Bartix33
Wysłany: 2018-12-19, 23:36


Samotny

5life.pl






Wiek: 22
Na forum: 3492 dni
Posty: 34
Nick w MP: Jabol

Piwa: 81

Respekt: 20,5

Czas sobie ustawiasz w

Kod:

local czas = 1*60*1000 --1 minuta


i tutaj sobie zmie? do informacji na czacie

Kod:

local pokazczas = czas/1000
local tekst = ("[Anty-SPAM] Dosta?e? muta za spam! na "..pokazczas.." sekund(-y).")


Postaw piwo autorowi tego posta
 

 
Tagi: anty :: spam
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » anty spam Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku