5150 Posted November 26, 2015 Share Posted November 26, 2015 yeah yeah i know this post has probably been posted about 42 million times, but none of the posts give a straight forward answer... so i have admin tags, and i get double messages on the admin messages. i want to combine playercolors and my admin script into one resource if possible, but honestly all i want is to have tags while my players have colors. heres the admin tag script, and playercolors Playercolors local lowerBound,upperBound = unpack(get"color_range") g_Root = getRootElement () g_ResourceRoot = getResourceRootElement ( getThisResource () ) addEventHandler ( "onResourceStart", g_ResourceRoot, function() for i,player in ipairs(getElementsByType"player") do processPlayer ( player ) end end ) function processPlayer ( player ) player = player or source local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) setPlayerNametagColor(player, r, g, b) end addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) addEventHandler('onPlayerChat', g_Root, function(msg, type) if type == 0 then cancelEvent() local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') outputChatBox( name.. ': #FFFFFF' .. msg, g_Root, r, g, b, true) outputServerLog( "CHAT: " .. name .. ": " .. msg ) end end ) getPlayerColor = getPlayerNametagColor getPlayerColour = getPlayerNametagColor admin tags 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("Admin")) then cancelEvent(true) outputChatBox("#990000|OWNER| #999999" .. name .. ":#f7fc00 " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: #990000~|OWNER|~ " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then cancelEvent(true) outputChatBox("#000000~SuperModerator~ #66FF00" .. name ..":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: #00a2fc~SuperModerator~" .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then cancelEvent(true) outputChatBox("#3366ff~Moderator~ #00ff00" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: #00ff00~Moderator~ " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Trainee")) then cancelEvent(true) outputChatBox(" #FFFF00~Trainee~ " .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: #FFFF00~Vip~" .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then cancelEvent(true) outputChatBox(" #00a2fc~|OWNER|~ " .. name .. ":#f7fc00 " .. text, root, 255, 255, 255, true) outputServerLog("CHAT: #00a2fc~|OWNER|~" .. 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
The Don Posted November 26, 2015 Share Posted November 26, 2015 actually i don't get what you really want but maybe this will work with you function chatbox(text, msgtype) local root = getRootElement() local account = getAccountName(getPlayerAccount(source)) local name = getPlayerName(source) local color = string.format("#%02X%02X%02X", getPlayerNametagColor(source)) if (msgtype == 0) then cancelEvent() if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#990000|OWNER| "..color.."" .. name .. ":#f7fc00 " .. text, root, 255,255,255, true) outputServerLog("CHAT: #990000~|OWNER|~ " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#000000~SuperModerator~ "..color.."" .. name ..":#FFFFFF " .. text, root, 255,255,255, true) outputServerLog("CHAT: #00a2fc~SuperModerator~" .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#3366ff~Moderator~ "..color.."" .. name .. ":#FFFFFF " .. text, root, 255,255,255, true) outputServerLog("CHAT: #00ff00~Moderator~ " .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Trainee")) then outputChatBox(" #FFFF00~Trainee~ "..color.."" .. name .. ":#FFFFFF " .. text, root, 255,255,255, true) outputServerLog("CHAT: #FFFF00~Vip~" .. name .. ": " .. text) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then outputChatBox(" #00a2fc~|OWNER|~ "..color.."" .. name .. ":#f7fc00 " .. text, root, 255,255,255, true) outputServerLog("CHAT: #00a2fc~|OWNER|~" .. name .. ": " .. text) end elseif (msgtype == 2) then end end addEventHandler("onPlayerChat", root, chatbox) Link to comment
5150 Posted November 26, 2015 Author Share Posted November 26, 2015 i was looking to stop the double messages when i start my admin tags resource. player names are okay, but for admins it sends one colored, and one tagged message. does this script stop that? Link to comment
The Don Posted November 26, 2015 Share Posted November 26, 2015 yes of course because you're using two events ( onPlayerChat ) delete all your tag code and try the code in my post Link to comment
5150 Posted November 26, 2015 Author Share Posted November 26, 2015 cool, it worked thanks Link to comment
5150 Posted November 26, 2015 Author Share Posted November 26, 2015 you know what... i thought it worked because i tested it with another staff member without playercolors and it worked, but now player colors is on with the admin tags and im getting them again Link to comment
ALw7sH Posted November 26, 2015 Share Posted November 26, 2015 If the freeroam is running that's why thr messages being double Link to comment
5150 Posted November 26, 2015 Author Share Posted November 26, 2015 but i need freeroam Link to comment
5150 Posted November 26, 2015 Author Share Posted November 26, 2015 i deleted the chat line in the freeroam script, so now all i have chat related is my admin tags and playercolors Link to comment
ALw7sH Posted November 26, 2015 Share Posted November 26, 2015 i deleted the chat line in the freeroam script, so now all i have chat related is my admin tags and playercolors and it's still being doubled? Link to comment
5150 Posted November 27, 2015 Author Share Posted November 27, 2015 yes. my player colors works fine, but basically the script puts my name with a tag, (so like |OWNER| [PMG]DeathWatch5150[L]: TEXTTEXTTEXT) but as a separate output. so it will be: Admin tag output: Playercolors output: because the admin tags creates a new output. if i delete playercolors, only staff can see their messages (because of tags), but if i keep it, staff has 2 messages Link to comment
5150 Posted November 27, 2015 Author Share Posted November 27, 2015 basically what i need is something either in playercolors or my admin script saying people in the "everyone" ACL will have random chat colors, but my staff will have their tags Link to comment
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