Jump to content

[Question] Ignore Script


DePemy

Recommended Posts

So, I was wondering.

Recently, i got some really annoying fightings going on in my server.

I later talked to both of the guys and noticed that one of them had some real issues with himself. He really wanted to ignore the guy, but since he can read the chat. He wasn't able to do so..

My question:

Is there any ignore script or something (not mute) available as a resource? I would be really happy and this would solve a lot of problems. If someone wants to script it if it's not done yet, i might want to talk about paying. Well.. Atleast if you explain the script to me because i would love to learn how to do that..

Hope you guys can help me out!

Kind Regards!

Edited by Guest
Link to comment
Not tested.
  
local ignorelist = {} 
  
addCommandHandler("ignore", 
    function (player, cmd, ignored) 
        if (not ignored) then 
            -- Usage: /ignore  
            return 
        end 
        local ignored = getPlayerFromName(ignored) 
        if (not ignored) then 
            -- Player doesn't exist 
            return 
        end 
        if (ignored == player) then 
            -- You can't ignore yourself 
            return 
        end 
         
        if (not ignorelist[ignored]) then 
            ignorelist[ignored] = {} 
        end 
         
        if (not ignorelist[ignored][player]) then 
            ignorelist[ignored][player] = true 
            outputChatBox("* You ignore now ".. getPlayerName(ignored), player, 0, 255, 0, true) 
        else 
            ignorelist[ignored][player] = false 
            outputChatBox("* You do not ignore ".. getPlayerName(ignored) .." #00FF00anymore", player, 0, 255, 0, true) 
        end 
    end 
) 
  
addEventHandler("onPlayerChat", root, 
    function (message, messageType) 
        -- Cancel event to prevent doubles 
        cancelEvent() 
        
        -- Get the name from the writer 
        local name = getPlayerName(source) 
        
        -- Write to log (cancelEvent prevents logging) 
        outputServerLog("CHAT ".. name ..": ".. message) 
        
        -- Send the message 
        if (messageType == 0) then 
            local players = getElementsByType("player") 
            for _, player in ipairs(players) do 
                if (not ignorelist[source] and not ignorelist[source][player]) then 
                    outputChatBox(name ..": ".. message, player, 255, 255, 255, true) 
                end 
            end 
        elseif (messageType == 1) then 
            local players = getElementsByType("player") 
            for _, player in ipairs(players) do 
                if (not ignorelist[source] and not ignorelist[source][player]) then 
                    outputChatBox("* ".. name .." ".. message, player, 255, 130, 130, true) 
                end 
            end  
        elseif (messageType == 2) then 
            local team = getPlayerTeam(source) 
            if (team) then 
                local players = getPlayersInTeam(team) 
                for _, player in ipairs(players) do 
                    if (not ignorelist[source] and not ignorelist[source][player]) then 
                        outputChatBox("(Team) ".. name ..": ".. message, player, 255, 255, 255, true) 
                    end 
                end 
            end 
        end 
    end 
) 
  

Made a META.XML .. Tried it.. Nothing happend. Tried to add it in Admin ACL. Nothing happend.. Got any clues? It would be really awsome!

Link to comment
  • MTA Team

Tested & works.

local ignorelist = {} 
  
addCommandHandler("ignore", 
    function (player, cmd, ignored) 
        if (not ignored) then 
            -- Usage: /ignore  
            outputChatBox("Usage: /ignore ", player, 200, 200, 200) 
            return 
        end 
        local ignored = getPlayerFromName(ignored) 
        if (not ignored) then 
            -- Player doesn't exist 
            outputChatBox("Ignore: Player doesn't exist", player, 200, 200, 200) 
            return 
        end 
        if (ignored == player) then 
            -- You can't ignore yourself 
            outputChatBox("Ignore: You can't ignore yourself", player, 200, 200, 200) 
            return 
        end 
        
        if (not ignorelist[ignored]) then 
            ignorelist[ignored] = {} 
        end 
        
        if (not ignorelist[ignored][player]) then 
            ignorelist[ignored][player] = true 
            outputChatBox("* You ignore now ".. getPlayerName(ignored), player, 0, 255, 0, true) 
        else 
            ignorelist[ignored][player] = false 
            outputChatBox("* You do not ignore ".. getPlayerName(ignored) .." #00FF00anymore", player, 0, 255, 0, true) 
        end 
    end 
) 
  
addEventHandler("onPlayerChat", root, 
    function (message, messageType) 
        -- Cancel event to prevent doubles 
        cancelEvent() 
        
        -- Get the name from the writer 
        local name = getPlayerName(source) 
        
        -- Write to log (cancelEvent prevents logging) 
        outputServerLog("CHAT ".. name ..": ".. message) 
        
        -- Send the message 
        if (messageType == 0) then 
            local players = getElementsByType("player") 
            for _, player in ipairs(players) do 
               if (not (ignorelist[source] and ignorelist[source][player])) then 
                    outputChatBox(name ..": ".. message, player, 255, 255, 255, true) 
                end 
            end 
        elseif (messageType == 1) then 
            local players = getElementsByType("player") 
            for _, player in ipairs(players) do 
                if (not (ignorelist[source] and ignorelist[source][player])) then 
                    outputChatBox("* ".. name .." ".. message, player, 255, 130, 130, true) 
                end 
            end 
        elseif (messageType == 2) then 
            local team = getPlayerTeam(source) 
            if (team) then 
                local players = getPlayersInTeam(team) 
                for _, player in ipairs(players) do 
                    if (not (ignorelist[source] and ignorelist[source][player])) then 
                        outputChatBox("(Team) ".. name ..": ".. message, player, 255, 255, 255, true) 
                    end 
                end 
            end 
        end 
    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...