Jump to content

Ignore Script Help


DePemy

Recommended Posts

Hey guys,

So a couple months ago I made an ignore script, altought it has some bugs with it,

I was wondering if you guys can help me out with it..

The ignoring thing works great, but the problem is that i have to enter to CORRECT name of the player, that's with the color codes included.

Is there any way to fix this? I would really appreciate any help!

Here's the code.

Code removed against copy-cats

Please help me out

Kind regards,

Remy

Edited by Guest
Link to comment
  
local ignorelist = {} 
  
function getPlayerFromPartialName(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player, name_ 
            end 
        end 
    end 
end 
  
addCommandHandler("ignore", 
    function (player, cmd, ignored) 
        if (not ignored) then 
            -- gebruik: /ignore  
            outputChatBox("Usage: /ignore ", player, 200, 200, 200) 
            return 
        end 
        local ignored, name = getPlayerFromPartialName(ignored) 
        if (not ignored) then 
            -- Speler bestaat niet 
            outputChatBox("Ignore: Player doesn't exist", player, 200, 200, 200) 
            return 
        end 
        if (ignored == player) then 
            -- Jezelf niet muten 
            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 ".. name, player, 0, 255, 0, true) 
        else 
            ignorelist[ignored][player] = false 
            outputChatBox("* You do not ignore ".. name .." #00FF00anymore", player, 0, 255, 0, true) 
        end 
    end 
) 
  
addEventHandler("onPlayerChat", root, 
    function (message, messageType) 
        -- Cancel Event zodat je geen dubbele ignores krijgt 
        cancelEvent() 
        
        -- naam van schrijver 
        local name = getPlayerName(source) 
        
        -- Schrijg in log Cancel event weerhoud het van loggen 
        outputServerLog("CHAT ".. name ..": ".. message) 
        
        -- Stuur bericht 
        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
  
local ignorelist = {} 
  
function getPlayerFromPartialName(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player, name_ 
            end 
        end 
    end 
end 
  
addCommandHandler("ignore", 
    function (player, cmd, ignored) 
        if (not ignored) then 
            -- gebruik: /ignore  
            outputChatBox("Usage: /ignore ", player, 200, 200, 200) 
            return 
        end 
        local ignored, name = getPlayerFromPartialName(ignored) 
        if (not ignored) then 
            -- Speler bestaat niet 
            outputChatBox("Ignore: Player doesn't exist", player, 200, 200, 200) 
            return 
        end 
        if (ignored == player) then 
            -- Jezelf niet muten 
            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 ".. name, player, 0, 255, 0, true) 
        else 
            ignorelist[ignored][player] = false 
            outputChatBox("* You do not ignore ".. name .." #00FF00anymore", player, 0, 255, 0, true) 
        end 
    end 
) 
  
addEventHandler("onPlayerChat", root, 
    function (message, messageType) 
        -- Cancel Event zodat je geen dubbele ignores krijgt 
        cancelEvent() 
        
        -- naam van schrijver 
        local name = getPlayerName(source) 
        
        -- Schrijg in log Cancel event weerhoud het van loggen 
        outputServerLog("CHAT ".. name ..": ".. message) 
        
        -- Stuur bericht 
        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 
) 
  

Uh nope, the gsub buggs it all..

Link to comment
  
  
local ignorelist = {} 
  
function getPlayerFromPartialName(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 
  
addCommandHandler("ignore", 
    function (player, cmd, ignored) 
        if (not ignored) then 
            -- gebruik: /ignore  
            outputChatBox("Usage: /ignore ", player, 200, 200, 200) 
            return 
        end 
        local ignored, name = getPlayerFromPartialName(ignored), getPlayerName(ignored) 
        if (not ignored) then 
            -- Speler bestaat niet 
            outputChatBox("Ignore: Player doesn't exist", player, 200, 200, 200) 
            return 
        end 
        if (ignored == player) then 
            -- Jezelf niet muten 
            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 ".. name, player, 0, 255, 0, true) 
        else 
            ignorelist[ignored][player] = false 
            outputChatBox("* You do not ignore ".. name .." #00FF00anymore", player, 0, 255, 0, true) 
        end 
    end 
) 
  
addEventHandler("onPlayerChat", root, 
    function (message, messageType) 
        -- Cancel Event zodat je geen dubbele ignores krijgt 
        cancelEvent() 
        
        -- naam van schrijver 
        local name = getPlayerName(source) 
        
        -- Schrijg in log Cancel event weerhoud het van loggen 
        outputServerLog("CHAT ".. name ..": ".. message) 
        
        -- Stuur bericht 
        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
  
  
local ignorelist = {} 
  
function getPlayerFromPartialName(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 
  
addCommandHandler("ignore", 
    function (player, cmd, ignored) 
        if (not ignored) then 
            -- gebruik: /ignore  
            outputChatBox("Usage: /ignore ", player, 200, 200, 200) 
            return 
        end 
        local ignored, name = getPlayerFromPartialName(ignored), getPlayerName(ignored) 
        if (not ignored) then 
            -- Speler bestaat niet 
            outputChatBox("Ignore: Player doesn't exist", player, 200, 200, 200) 
            return 
        end 
        if (ignored == player) then 
            -- Jezelf niet muten 
            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 ".. name, player, 0, 255, 0, true) 
        else 
            ignorelist[ignored][player] = false 
            outputChatBox("* You do not ignore ".. name .." #00FF00anymore", player, 0, 255, 0, true) 
        end 
    end 
) 
  
addEventHandler("onPlayerChat", root, 
    function (message, messageType) 
        -- Cancel Event zodat je geen dubbele ignores krijgt 
        cancelEvent() 
        
        -- naam van schrijver 
        local name = getPlayerName(source) 
        
        -- Schrijg in log Cancel event weerhoud het van loggen 
        outputServerLog("CHAT ".. name ..": ".. message) 
        
        -- Stuur bericht 
        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 
) 
  

And again still doesnt work..

Isnt it supposed to be something like this?

for _,thePlayer in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then 
            return thePlayer 
        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...