Jump to content

problems


Nerses

Recommended Posts

Good evening to you all dear friends. I would like to share with you with some kind of script which blocks the message in the form of Ip addresses of servers, you can say Anti spam. But now to another

function playerChat(message, messageType) 
cancelEvent() 
if (messageType == 0) then 
if pregFind(message, "([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})") then 
outputChatBox("Reklama!", source, 255, 0, 0, true) 
return 
end 
outputChatBox(getPlayerName(source)..": #FFFFFF"..message, getRootElement(), 211, 211, 211, true) 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), playerChat) 

But now to another, when I paste this script to your server, I began to duplicate the chat. The fact that I have a script TAG. Can anyone help me to resolve this issue? Here is the code TAG:

function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then 
     cancelEvent(true) 
        outputChatBox("#FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
     cancelEvent(true) 
        outputChatBox("#0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT:  #0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
     cancelEvent(true) 
        outputChatBox(" #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
     cancelEvent(true) 
        outputChatBox(name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FFFFFF" .. name .. ": " .. text) 
     end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 

Thanks in advance

Link to comment
function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if pregFind(message, "([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})") then 
    cancelEvent(true) 
    outputChatBox("Reklama!", source, 255, 0, 0, true) 
    return 
    end 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then 
     cancelEvent(true) 
        outputChatBox("#FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
     cancelEvent(true) 
        outputChatBox("#0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT:  #0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
     cancelEvent(true) 
        outputChatBox(" #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
     cancelEvent(true) 
        outputChatBox(name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FFFFFF" .. name .. ": " .. text) 
     end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 

Link to comment
function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if pregFind(message, "([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})") then 
    cancelEvent(true) 
    outputChatBox("Reklama!", source, 255, 0, 0, true) 
    return 
    end 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then 
     cancelEvent(true) 
        outputChatBox("#FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
     cancelEvent(true) 
        outputChatBox("#0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT:  #0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
     cancelEvent(true) 
        outputChatBox(" #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
     cancelEvent(true) 
        outputChatBox(name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FFFFFF" .. name .. ": " .. text) 
     end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 

this now throws an error

[2014-11-08 01:24:01] WARNING: [gameplay]/bptag/tag.lua:6: Bad argument @ 'pregFind' [Expected string at argument 1, got nil] 

Link to comment

oh sorry i forget to change the name of first argument

function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if pregFind(text, "([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})[^[:digit:]^[:cntrl:]]{1,3}([0-9]{1,3})") then 
    cancelEvent(true) 
    outputChatBox("Reklama!", source, 255, 0, 0, true) 
    return 
    end 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then 
     cancelEvent(true) 
        outputChatBox("#FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FF0000[#FF0000Хозяин#FF0000] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
     cancelEvent(true) 
        outputChatBox("#0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT:  #0000FF[#0000FFАдмин#0000FF] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
     cancelEvent(true) 
        outputChatBox(" #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #00FF00[#00FF00Гл.#00FF00Админ#00FF00] #FFFFFF" .. name .. ": " .. text) 
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
     cancelEvent(true) 
        outputChatBox(name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FFFFFF" .. name .. ": " .. text) 
     end 
  
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    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...