OnPlayerChat not being called until second message onwards
2 replies, posted
My hook for OnPlayerChat is not being called for the first message i send for my custom chat script. Only from the second message onwards, it starts working as intended. On the first message, "2" is just printed. On the second message onwards, "4", then "2", is printed. What's wrong?
https://files.facepunch.com/forum/upload/483843/fa231d77-4865-4fdf-86ab-a183820584d3/image.png
You're creating the hook when chat.AddText is called, so the hook won't be registered the first time. This isn't the right approach however, you shouldn't be creating a hook every time the function is called. You need to add the hook outside of the function.
Thank you!
Sorry, you need to Log In to post a reply to this thread.