Jump to content

Anti-Spam


Lachuks

Recommended Posts

Hello there! I have problem with spamming in GlobalChat and I don't know how to avoid it. I hope someone can help me.

I want to - when someone start to spam he will get muted for 10 mins or just get kicked out of server.

There is the code:

globalchat = true

function globalchatstate(playerSource)
    if getElementData(playerSource, "admin") == true or getElementData(playerSource, "sadmin") == true or getElementData(playerSource, "smanager") == true or getElementData(playerSource, "owner") == true then
        if globalchat == true then
            globalchat = false
            outputChatBox(getPlayerName(playerSource).." has deactivated the Global Chat!", getRootElement(), 255, 0, 0)
        elseif globalchat == false then
            globalchat = true
            outputChatBox(getPlayerName(playerSource).." has activated the Global Chat!", getRootElement(), 255, 0, 0)
        end
    end
end
addCommandHandler("globalstate", globalchatstate)

function GlobalChat ( playerSource, commandname, ... )
    if globalchat == true then
        local playerName = getPlayerName ( playerSource )
        if(isPlayerMuted ( playerSource ) ~= true) then
            if(... ~= nil) then
                local arg = {...}
                local text = table.concat( arg, " " )

                    if ( getElementData( playerSource , "gang")  == "randomgraestrt" ) then
                    outputChatBox ( "[#ffffffGlobalChat#ffffff] -"..playerName..":#787878 "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Admin" ) ) then
                    outputChatBox ( "[#FF9219Server Owner#ffffff] - "..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "SuperMod" ) ) then
                    outputChatBox ( "[#ED05DDSuper Moderator#ffffff] - "..playerName.." :#FFFFFF o "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Supporter" ) ) then
                    outputChatBox ( "[#0A5E9ASupporter#ffffff] - "..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Moderator" ) ) then
                    outputChatBox ( "[#06900DModerator#ffffff] - "..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "ServerManager" ) ) then
                    outputChatBox ( ""..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Administrator" ) ) then
                    outputChatBox ( "[#C9B607Administrator#ffffff] - "..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "SuperAdministrator" ) ) then
                    outputChatBox ( ""..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) and isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "VIP" ) ) then
                    outputChatBox ( "[#2efe64VIP#ffffff] - "..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)
                    elseif ( getElementData( playerSource , "gang")  == "Admins" ) then
                    outputChatBox ( "#ffffff[GlobalChat] - "..playerName.." :#FFFFFF  "..text, getRootElement(), 255, 255, 255, true)

                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "VIP" ) ) then
                    outputChatBox ( "[#2efe64VIP#ffffff] - "..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Supporter" ) ) then
                    outputChatBox ( "[#0A5E9ASupporter#ffffff] - "..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Moderator" ) ) then
                    outputChatBox ( "[#06900DModerator#ffffff] - "..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "SuperMod" ) ) then
                    outputChatBox ( "[#ED05DDSuper Moderator#ffffff] - "..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("Administrator" ) ) then
                    outputChatBox ( "[#C9B607Administrator#ffffff] - "..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("SuperAdministrator" ) ) then
                    outputChatBox ( ""..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ("ServerManager" ) ) then
                    outputChatBox ( ""..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "Admin" ) ) then
                    outputChatBox ( "[#9A0A0AServer Owner#ffffff] - "..playerName.."#FFFFFF]: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "CommunityFounder" ) ) then
                    outputChatBox ( ""..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(playerSource)), aclGetGroup ( "CommunitySupporter" ) ) then
                    outputChatBox ( ""..playerName.."#FFFFFF: "..text, getRootElement(), 255, 255, 255, true)
                else
                    outputChatBox ( "#ffffff[GlobalChat] - "..playerName.."#FFFFFF: "..string.gsub(text, '#%x%x%x%x%x%x', ''), getRootElement(), 255, 255, 255, true)
                end
            else
                outputChatBox ( "Usage: /global <text>",playerSource,255,255,0)
            end
        else
            outputChatBox ( "You are muted, you cant write now!",playerSource,255,255,0)
        end
    else
        outputChatBox(playerName.." deactivateted the global chat!", playerSource, 255, 255, 0)
    end
end
addCommandHandler("GlobalChat",GlobalChat)

 

Edited by Emix
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...