itHyperoX Posted March 14, 2017 Share Posted March 14, 2017 (edited) so, i making a "chat system", but i got some problems. Here is the code cancelableworld = { ":~", ":Oyou", "bitch" } addEventHandler("onPlayerChat", root, function(message, msgTyp) local message = string.lower(message) for i,v in ipairs(cancelableworld) do if (string.find(message, cancelableworld[i])) then outputChatBox("*NO*", source, 255, 0, 0, false) cancelEvent() end end end) --————————————————————————————————————————————————————————— --————————————————————————————————————————————————————————— --< CustomChat >-- addEventHandler ( "onPlayerChat", root, local Level = getElementData(source,"Level" or 0) function(message) outputChatBox("#4C7759[LVL "..Level.."] #FFFFFF"..getPlayerName(source)..": #FFFFFF"..message,getRootElement(),255,2555,255,true) end) The script first half is canceling the worlds, but the second is enable the world. So i cancel the "Weid" worlds, but it keep showing on the chat, becase the second half not ignor that. I want to make, when player typing blocked worlds in chat, thats not showing up, what should i do? Edited March 14, 2017 by TheMOG Link to comment
Fist Posted March 14, 2017 Share Posted March 14, 2017 (edited) i think problem is here if (string.find(message, cancelableworld[i])) then pretty sure it has to be like this instead if (string.find(message, v)) then Edited March 14, 2017 by Fist Link to comment
NeXuS™ Posted March 14, 2017 Share Posted March 14, 2017 Thats not the case Fist, both method is working.You'll have to melt those two codes together. If you need further help, feel free to ask here. Link to comment
itHyperoX Posted March 14, 2017 Author Share Posted March 14, 2017 Yes i need little help about this Link to comment
Dzsozi (h03) Posted March 14, 2017 Share Posted March 14, 2017 I think you can just make it inside one function, maybe something like this, I'm not quite sure tho. cancelableworld = { ":~", ":Oyou", "bitch" } addEventHandler("onPlayerChat", root, function(message, msgTyp) local Level = getElementData(source,"Level" or 0) outputChatBox("#4C7759[LVL "..Level.."] #FFFFFF"..getPlayerName(source)..": #FFFFFF"..message,getRootElement(),255,2555,255,true) local message = string.lower(message) for i,v in ipairs(cancelableworld) do if (string.find(message, cancelableworld[i])) then outputChatBox("*NO*", source, 255, 0, 0, false) cancelEvent() end end end) Link to comment
itHyperoX Posted March 14, 2017 Author Share Posted March 14, 2017 keep showing the 2 messages. First is the word second is "No" Link to comment
^iiEcoo'x_) Posted March 14, 2017 Share Posted March 14, 2017 local Table = { "Rank", "TheMoG", } addEventHandler("onPlayerChat",getRootElement(), function ( msg ) for i,v in pairs ( Table ) do if ( string.find ( msg , v ) ) then cancelEvent() outputChatBox( " No " , source ) end end end ) Try This Link to comment
itHyperoX Posted March 14, 2017 Author Share Posted March 14, 2017 (edited) @#_iMr.[E]coo the problem is i need that when player is on chat, showing the "Level" etc.. you can get it what i need in Dzsozi reply Edited March 14, 2017 by TheMOG Link to comment
^iiEcoo'x_) Posted March 14, 2017 Share Posted March 14, 2017 (edited) local aData = "Level" addEventHandler("onPlayerChat",getRootElement(), function ( aMsg ) if ( getElementData ( source , aData ) == true ) then cancelEvent () outputChatBox ("[ level "..getElementData ( source , aData ).." ] "..getPlayerName ( source ).." : "..aMsg , root ) end end ) Edited March 14, 2017 by #_iMr.[E]coo Link to comment
Dzsozi (h03) Posted March 14, 2017 Share Posted March 14, 2017 Just now, #_iMr.[E]coo said: local aData = "Level" addEventHandler("onPlayerChat",getRootElement(), function ( aMsg ) if ( getElementData ( source , aData ) == true ) then outputChatBox ("[ level "..getElementData ( source , aData ).." ] "..getPlayerName ( source ).." : "..msg , root ) end end ) You just made it more complex, that's not what he needs, his problem is that he don't want some words being shown, but because of the two onPlayerChat events he still can see the word he doesn't want to show. It could be an option to check on the other event - where you show the level of the chatting player - if the message has a bad word, but you would have to check it everywhere if you make another onPlayerChat event, I think there is an easier way where you don't have to check the bad words everytime. 1 Link to comment
^iiEcoo'x_) Posted March 14, 2017 Share Posted March 14, 2017 correction code Dzsozi cancelableworld = { ":~", ":Oyou", "bitch" } addEventHandler("onPlayerChat", root, function(message, msgTyp) local Level = getElementData(source,"Level") outputChatBox("#4C7759[LVL "..Level.."] #FFFFFF"..getPlayerName(source)..": #FFFFFF"..message,getRootElement(),255,255,255,true) local message = string.lower(message) for i,v in ipairs(cancelableworld) do if (string.find(message, cancelableworld[i])) then cancelEvent() outputChatBox("*NO*", source, 255, 0, 0, false) end end end) Link to comment
itHyperoX Posted March 14, 2017 Author Share Posted March 14, 2017 duplicated chat messages, Keep showing the cancelablewords Link to comment
NeXuS™ Posted March 14, 2017 Share Posted March 14, 2017 (edited) Try this one: addEventHandler("onPlayerChat", root, function(message, msgTyp) local message = string.lower(message) for i,v in ipairs(cancelableworld) do if (string.find(message, cancelableworld[i])) then outputChatBox("*NO*", source, 255, 0, 0, false) cancelEvent() return end end local Level = getElementData(source,"Level" or 0) outputChatBox("#4C7759[LVL "..Level.."] #FFFFFF"..getPlayerName(source)..": #FFFFFF"..message,getRootElement(),255,2555,255,true) end) Edited March 14, 2017 by Patrik91 1 Link to comment
itHyperoX Posted March 14, 2017 Author Share Posted March 14, 2017 i succesfully fixed, thanks anyway. 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