Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.2]Getting the name of the player who sent a message to the chat?


Recommended Posts

Hello! I'm using the ClientChatReceivedEvent to check for specific words in the message, then giving a sound to the player. But I don't want the sound to play, if the current Player writes that specific word. So I need to get the name of the player who sent the message. I already tried the ClientChatReceivedEvent.message.func_150260_c(); method (which returns the message just as you see it in the chat) and then extracting the players name, but that does not work on servers with custom chat formats, since I search for "<" and ">". Is there any way to get the name without searching for specific symbols in the message and extracting them?

 

Thanks in advance :)

 

~bl4ck

↑↑↑↑↑↑↑↑↑↑ Click it please? :3 ↑↑↑↑↑↑↑↑↑↑

Link to post
Share on other sites

Hi

 

Some ideas to try

(1) when a client sends a chat message, it could remember it, and if it receives the identical message within (say) 1 - 2 seconds, it knows that it was almost certainly the sender

or

(2) you could search the incoming message for each of the player names, discard any which don't match, and pick the best of any that do match (the one with the earliest match position in the string)

or

(3) write your own "play sound" packet, i.e. the client searches the chat message it is about to send for the specific word, and if it is present, sends a packet to the server which then does "play the sound on all clients except the original client".

 

-TGG

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.