Rat32 Posted March 14, 2015 Posted March 14, 2015 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 ) addEventHandler ( "onPlayerChat", getRootElement(), function ( message, messageType ) if messageType == 1 then cancelEvent() end end) Why this doesn't work? Sends a double message, does not close the event.
3B00DG4MER Posted March 14, 2015 Posted March 14, 2015 use getDistanceBetweenPoints3D better SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
3B00DG4MER Posted March 14, 2015 Posted March 14, 2015 Daf***k it's not your Problem, then why you post it ?! SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
xXMADEXx Posted March 14, 2015 Posted March 14, 2015 There is probably another script that cancels and sends a message onPlayerChat. The Ultimate Lua Tutorial! | MTA PHP SDK
Et-win Posted March 14, 2015 Posted March 14, 2015 Daf***kit's not your Problem, then why you post it ?! Why this doesn't work? Sends a double message, does not close the event. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
3B00DG4MER Posted March 14, 2015 Posted March 14, 2015 He didn't wrote that at first time * He edited it and colshape for that i think gives lagg, why don't u use math better than creating colshapes get distance then check if distance is lower then 15 or something then cancel event and output again SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
Moderators IIYAMA Posted March 15, 2015 Moderators Posted March 15, 2015 It is probably sending double messages because you are using the freeroam resource, which is also using this event. Or some other resource. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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