TheMtaUser555 Posted October 18, 2012 Share Posted October 18, 2012 Nothing happens when I try this ( it's supposed to remove all the HEX code ): addEventHandler('onPlayerChangeNick', root, function(oldNick, newNick) if string.find( newNick, '#%x%x%x%x%x%x') then setPlayerName ( source, oldNick ) end end ) I also tried to use gsub and then setPlayerName, put it spams the chatbox.. Any help would be appreciated Link to comment
Castillo Posted October 18, 2012 Share Posted October 18, 2012 addEventHandler ( 'onPlayerChangeNick', root, function ( oldNick, newNick ) if string.find ( newNick, '#%x%x%x%x%x%x' ) then outputChatBox ( "You can't use HEX codes.", source, 255, 0, 0 ) cancelEvent ( ) end end ) That'll not change the nick if new one has HEX codes, and it'll send a message to the player. Link to comment
Anderl Posted October 19, 2012 Share Posted October 19, 2012 This should do what you want: addEventHandler('onPlayerChangeNick', root, function(_, new) setPlayerName(source, new:gsub('#%x%x%x%x%x%x', '')) end ) Link to comment
TheMtaUser555 Posted October 20, 2012 Author Share Posted October 20, 2012 addEventHandler ( 'onPlayerChangeNick', root, function ( oldNick, newNick ) if string.find ( newNick, '#%x%x%x%x%x%x' ) then outputChatBox ( "You can't use HEX codes.", source, 255, 0, 0 ) cancelEvent ( ) end end ) That'll not change the nick if new one has HEX codes, and it'll send a message to the player. thanks, that worked. I tried using string.find before but it didn't work, I guess it was because I didn't cancel the event Link to comment
Anderl Posted October 20, 2012 Share Posted October 20, 2012 addEventHandler ( 'onPlayerChangeNick', root, function ( oldNick, newNick ) if string.find ( newNick, '#%x%x%x%x%x%x' ) then outputChatBox ( "You can't use HEX codes.", source, 255, 0, 0 ) cancelEvent ( ) end end ) That'll not change the nick if new one has HEX codes, and it'll send a message to the player. thanks, that worked. I tried using string.find before but it didn't work, I guess it was because I didn't cancel the event You might want to try mine, it removes HEX codes automatically. 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