DjMixCuma Posted April 10, 2012 Share Posted April 10, 2012 Hi! How to block using colors on chat and how to block changing name on game?? Link to comment
Castillo Posted April 10, 2012 Share Posted April 10, 2012 I guess by colors on chat you mean HEX colors, e.g: #00FF00Hello #FF0000World, if so, then you can use this: -- server side: addEventHandler ( "onPlayerChat", root, function ( msg, msgType ) if ( msgType == 0 ) then local r, g, b = getPlayerNametagColor ( source ) outputChatBox ( getPlayerName ( source ) ..": #FFFFFF".. msg, root, r, g, b ) cancelEvent ( ) end end ) About blocking the nick changer, you can cancel the onPlayerChangeNick with cancelEvent. Link to comment
DjMixCuma Posted April 10, 2012 Author Share Posted April 10, 2012 I guess by colors on chat you mean HEX colors, e.g: #00FF00Hello #FF0000World, if so, then you can use this:-- server side: addEventHandler ( "onPlayerChat", root, function ( msg, msgType ) if ( msgType == 0 ) then local r, g, b = getPlayerNametagColor ( source ) outputChatBox ( getPlayerName ( source ) ..": #FFFFFF".. msg, root, r, g, b ) cancelEvent ( ) end end ) About blocking the nick changer, you can cancel the onPlayerChangeNick with cancelEvent. I have this onPlayerChat, and i can use #00FF00 for example. I'm blocking onPlayerChangeNick with cancelEvent and i cant see message but nick changing. Link to comment
Jaysds1 Posted April 10, 2012 Share Posted April 10, 2012 (edited) try this: Nick Cancel addEventHandler("onPlayerChangeNick",root,function(oldN,newN) cancelEvent(true,"Sorry, you can not change your nick.") --Cancel event if (not wasEventCancelled()) then outputDebugString("Sorry, the event was not cancelled, please go back to the forums for more help") end --if even wasn't cancelled, output that it wasn't end) Edited April 12, 2012 by Guest Link to comment
DjMixCuma Posted April 12, 2012 Author Share Posted April 12, 2012 try this: Nick CanceladdEventHandler("onPlayerChangeNick",root,function(oldN,newN) cancelEvent("Sorry, you can not change your nick.") --Cancel event if (not wasEventCancelled()) then outputDebugString("Sorry, the event was not cancelled, please go back to the forums for more help") end --if even wasn't cancelled, output that it wasn't end) NOt working. Link to comment
Guest Guest4401 Posted April 12, 2012 Share Posted April 12, 2012 In jaysds1's code, he had bad argument in cancelEvent. 1st argument should had been bool, but it was string bool cancelEvent ( [ bool cancel = true, string reason = "" ] ) Getting on topic, here's the working code : addEventHandler("onPlayerChangeNick",getRootElement(), function() cancelEvent() end ) Link to comment
Kenix Posted April 12, 2012 Share Posted April 12, 2012 addEventHandler( 'onPlayerChangeNick', root, cancelEvent ) Done .. Link to comment
Guest Guest4401 Posted April 12, 2012 Share Posted April 12, 2012 addEventHandler( 'onPlayerChangeNick', root, cancelEvent ) Done .. It doesn't work either, because then cancelEvent would have 1st argument of the player's old nick which is string. So bad argument. Link to comment
Kenix Posted April 12, 2012 Share Posted April 12, 2012 (edited) I not understand addEventHandler( 'onClientPlayerDamage', localPlayer, cancelEvent ) work perfectly but first argument is element ( attacker ). addEventHandler( 'onPlayerChangeNick', root, cancelEvent ) not work, bad argument is string. addEventHandler ( 'onVehicleStartEnter', root, cancelEvent ) not work, bad argument is player Edited April 12, 2012 by Guest Link to comment
MIKI785 Posted April 12, 2012 Share Posted April 12, 2012 Hi!How to block using colors on chat and how to block changing name on game?? All the posts here doesn't block colors in chat... For chat, use this: (server) addEventHandler("onPlayerChat", getRootElement(), function (message, type) if type == 0 then --If it's main chat cancelEvent() --Message won't send local uncolored = string.gsub(message, "#%x%x%x%x%x%x", "") --Delete all HEX codes. local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source) .. ": #ffffff" .. uncolored, getRootElement(), r, g, b, true) --Send message manually outputServerLog("CHAT: "..getPlayerName(source)..": "..message) --Output to log manually end end) For changing the nick in-game, use: (server) addEventHandler("onPlayerChangeNick", getRootElement(), function () cancelEvent() --Nick won't change. outputChatBox("Sorry, you can't change your nick!", source, 255,0,0) end) Link to comment
DjMixCuma Posted May 14, 2012 Author Share Posted May 14, 2012 Hi!How to block using colors on chat and how to block changing name on game?? All the posts here doesn't block colors in chat... For chat, use this: (server) addEventHandler("onPlayerChat", getRootElement(), function (message, type) if type == 0 then --If it's main chat cancelEvent() --Message won't send local uncolored = string.gsub(message, "#%x%x%x%x%x%x", "") --Delete all HEX codes. local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source) .. ": #ffffff" .. uncolored, getRootElement(), r, g, b, true) --Send message manually outputServerLog("CHAT: "..getPlayerName(source)..": "..message) --Output to log manually end end) For changing the nick in-game, use: (server) addEventHandler("onPlayerChangeNick", getRootElement(), function () cancelEvent() --Nick won't change. outputChatBox("Sorry, you can't change your nick!", source, 255,0,0) end) 1. Chat not working, I can use colors. 2. TY! Link to comment
Jaysds1 Posted May 14, 2012 Share Posted May 14, 2012 (For the chat part) try this: addEventHandler("onPlayerChat",root,function(message, type) if type == 0 then --If it's main chat if(string.find(message,"#%x%x%x%x%x%x"))then cancelEvent() --Message won't send local uncolored = string.gsub(message, "#%x%x%x%x%x%x", "") --Delete all HEX codes. local r, g, b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source) .. ": " .. uncolored,root, r, g, b,false) --Send message manually outputServerLog("CHAT: "..getPlayerName(source)..": "..message) --Output to log manually end end end) 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