-RoCk-Alex Posted July 21, 2012 Posted July 21, 2012 why this script has double post function chatbox(text, msgtype) local account = getAccountName(getPlayerAccount(source)) local name = getPlayerName(source) local tag = getElementData(source, "ID") or 0 local r, g, b = getPlayerNametagColor(source) local hex = RGBToHex(r, g, b) if (msgtype == 0) then if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then cancelEvent(true) outputChatBox(" #cccccc[".. tag .."] #8B1A1A[HEADADMIN] ".. hex .."".. name ..": #FFFFFF".. text, root, 255, 255, 255, true) outputServerLog("CHAT: [HEADADMIN] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then cancelEvent(true) outputChatBox("#cccccc[".. tag .."] #FF0000[ADMIN] ".. hex .."" .. name ..": #FFFFFF" .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [ADMIN] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then cancelEvent(true) outputChatBox("#cccccc[".. tag .."] #00FF00[MODERATOR] ".. hex .."" .. name .. ": #FFFFFF" .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [MODERATOR] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then cancelEvent(true) outputChatBox("#cccccc[".. tag .."] #FFFFFF".. hex .."" .. name .. ": #FFFFFF" .. text, root, 255, 255, 255, true) outputServerLog("CHAT: " .. name .. ": " .. text) end 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
ishinam Posted July 21, 2012 Posted July 21, 2012 Why are you writing cancelevent again and again, just do this once function chatbox(text, msgtype) if (msgtype == 0) then cancelEvent() end end addEventHandler("onPlayerChat",root, chatbox) It shouldn't be repeating 2 times, maybe you are in 2 acl groups or i don't know
-RoCk-Alex Posted July 21, 2012 Author Posted July 21, 2012 still double post function chatbox23(text, msgtype) if (msgtype == 0) then cancelEvent() end end addEventHandler("onPlayerChat",root, chatbox23) function chatbox(text, msgtype) local account = getAccountName(getPlayerAccount(source)) local name = getPlayerName(source) local tag = getElementData(source, "ID") or 0 local r, g, b = getPlayerNametagColor(source) local hex = RGBToHex(r, g, b) if (msgtype == 0) then if isObjectInACLGroup("user." .. account, aclGetGroup("HeadAdmin")) then outputChatBox(" #cccccc[".. tag .."] #8B1A1A[HEADADMIN] ".. hex .."".. name ..": #FFFFFF".. text, root, 255, 255, 255, true) outputServerLog("CHAT: [HEADADMIN] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#cccccc[".. tag .."] #FF0000[ADMIN] ".. hex .."" .. name ..": #FFFFFF" .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [ADMIN] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#cccccc[".. tag .."] #00FF00[MODERATOR] ".. hex .."" .. name .. ": #FFFFFF" .. text, root, 255, 255, 255, true) outputServerLog("CHAT: [MODERATOR] " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#cccccc[".. tag .."] #FFFFFF".. hex .."" .. name .. ": #FFFFFF" .. text, root, 255, 255, 255, true) outputServerLog("CHAT: " .. name .. ": " .. text) end 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
Moderators Sarrum Posted July 21, 2012 Moderators Posted July 21, 2012 Open freeroam/fr_server.lua, find event onPlayerChat, delete event handler.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now