TheCapn Posted March 1, 2014 Posted March 1, 2014 Hello guys, I've taken this following script from the wiki and I've changed it for my purpose. It seems to work correctly in fact, but : For exemple, when I say on the chat box : Hello guys how are you ... I have this -> Franklin_Walker dit : Hello guys, how are you 0 I don't know where this "0" comes from, but maybe you could explain me Here's my code : function sayHandler(...) message = table.concat({...}, " ") local sender = getPlayerName(source) local posX, posY, posZ = getElementPosition(source) local saySphere = createColSphere( posX, posY, posZ, sayRadius ) local nearbyPlayers = getElementsWithinColShape( saySphere, "player" ) destroyElement( saySphere ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do outputChatBox(""..sender.." dit : "..message.."", nearbyPlayer, 255, 255, 255, true) end end addEventHandler( "onPlayerChat", getRootElement(), sayHandler ) function basicChatMessage() cancelEvent() end addEventHandler( "onPlayerChat", getRootElement(), basicChatMessage ) Regards,
WhoAmI Posted March 1, 2014 Posted March 1, 2014 function sayHandler(...) message = table.concat({...}, " ") local sender = getPlayerName(source) local posX, posY, posZ = getElementPosition(source) local saySphere = createColSphere( posX, posY, posZ, sayRadius ) local nearbyPlayers = getElementsWithinColShape( saySphere, "player" ) destroyElement( saySphere ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do outputChatBox(sender.." dit : "..message, nearbyPlayer, 255, 255, 255, true) end end addEventHandler( "onPlayerChat", getRootElement(), sayHandler ) Try this.
pa3ck Posted March 1, 2014 Posted March 1, 2014 You are not cancelling the event, so I don't know whats the point having this script though.
Wei Posted March 1, 2014 Posted March 1, 2014 sayRadius = 50 function sayHandler(message, msgType) local sender = getPlayerName(source) local posX, posY, posZ = getElementPosition(source) saySphere = createColSphere( posX, posY, posZ, sayRadius ) nearbyPlayers = getElementsWithinColShape( saySphere, "player" ) destroyElement( saySphere ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do outputChatBox(""..sender.." dit : "..message.."", nearbyPlayer, 255, 255, 255, true) end end addEventHandler( "onPlayerChat", getRootElement(), sayHandler )
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