BorderLine Posted April 18, 2012 Share Posted April 18, 2012 Hi everyone. Well to make less flood in my server, i make this local chatRadius = 50 function sendMessageToNearbyPlayers( message, messageType ) if messageType == 0 then local posX, posY, posZ = getElementPosition( source ) local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) destroyElement( chatSphere ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do local red, green, blue = getPlayerNametagColor(source) outputChatBox( getPlayerName(source)..": #ffffff"..message, nearbyPlayer, red, green, blue, true ) end end end addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) function blockChatMessage() cancelEvent() end addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage ) But the teamchat was removed. If i speak with "Y" dont show message How i can put back again? im searched in forum and i readed the wiki but i dont know how do. If someone can helpme thanks for your time Link to comment
Castillo Posted April 18, 2012 Share Posted April 18, 2012 Your problem is the "blockChatMessage" function, it'll cancel all chat messages, no matters if is not a team message, you have to use cancelEvent on "sendMessageToNearbyPlayers" function. local chatRadius = 50 function sendMessageToNearbyPlayers ( message, messageType ) if ( messageType == 0 ) then local posX, posY, posZ = getElementPosition ( source ) local chatSphere = createColSphere ( posX, posY, posZ, chatRadius ) local nearbyPlayers = getElementsWithinColShape ( chatSphere, "player" ) destroyElement ( chatSphere ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do local red, green, blue = getPlayerNametagColor ( source ) outputChatBox( getPlayerName ( source )..": #ffffff".. message, nearbyPlayer, red, green, blue, true ) end cancelEvent ( ) end end addEventHandler ( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) Link to comment
BorderLine Posted April 18, 2012 Author Share Posted April 18, 2012 Working.. Thanks man 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