Gravestone Posted February 28, 2016 Posted February 28, 2016 I want to disable color codes from the chat and from player's nickname. The color doesn't appear in chat but it outputs in chatbox as a blank message. This is my chat script, if needed: addEventHandler('onPlayerChat', g_Root, function(msg, type) if type == 0 then cancelEvent() local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. msg:gsub('#%x%x%x%x%x%x', ''), g_Root, r, g, b, true) outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) end end ) Clan war system http://sh.st/7r4nI
Wisam Posted February 28, 2016 Posted February 28, 2016 Here, that should work try it function deletecc() for k, v in ipairs (getElementsByType("player")) do local name = getPlayerName(v) if (string.find(name,"#%x%x%x%x%x%x")) then local name = string.gsub(name,"#%x%x%x%x%x%x","") setPlayerName(v,name) cancelEvent() end end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),deletecc) function removeCC(oldNick,newNickname) local name = getPlayerName(source) if newNickname then name = newNickname end if (string.find(name,"#%x%x%x%x%x%x")) then local name = string.gsub(name,"#%x%x%x%x%x%x","") setPlayerName(source,name) if (newNickname) then cancelEvent() end end end addEventHandler("onPlayerJoin",getRootElement(),removeCC) addEventHandler("onPlayerChangeNick",getRootElement(),removeCC) ☣ Plauge Arma II DayZ Mod Server ☣ Here's the link to stay tuned with the server progress and features: https://forum.mtasa.com/viewtopic.php?f=114&t=96675 Get Ready to play DayZ like you never did before
Gravestone Posted February 28, 2016 Author Posted February 28, 2016 Didn't work. No errors in the debugscript either. Clan war system http://sh.st/7r4nI
1LoL1 Posted February 28, 2016 Posted February 28, 2016 Try this: addEventHandler("onPlayerChat", getRootElement(), function(msg, type) if type == 0 then cancelEvent() local r, g, b = getPlayerNametagColor(source) local msg = msg:gsub("#%x%x%x%x%x%x", "") outputChatBox(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")..": #FFFFFF"..msg, getRootElement(), r, g, b, true) outputServerLog( "CHAT: " .. name .. ": " .. msg ) end end))
Gravestone Posted February 28, 2016 Author Posted February 28, 2016 'It outputs in chatbox as a blank message' if color coded. I mean if a player types message color coded it should show error like: Message should not contain color codes. Clan war system http://sh.st/7r4nI
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