Bug in Say() method
DamianBajofer opened this issue · 4 comments
DamianBajofer commented
Helias commented
DamianBajofer commented
I haven't .git
directory in my source or eluna-engine.. then i cant use git log
ralver commented
Your script is registring to the chat and when you send something with say you trigger it again. This is causing the endless loop.
You need to update the local function with global variable to check if the say is an original one and not a new one.
local send_say=false
local function OnPlayerChat(event, player, message, msgType, language)
if not send_say then
player:Say(message.." : OTHER", language)
send_say = true
else
send_say = false
end
return false
end.
RegisterPlayerEvent(18, OnPlayerChat)
Rochet2 commented
The hook can return false to intercept the original message, but it can also return a new message that replaces the original message in addition to that.
While above solution works, it might be cleaner to use the return value to modify the original message.
Here is an example:
local function OnPlayerChat(event, player, message, msgType, language)
return nil, message.." : OTHER"
end
RegisterPlayerEvent(18, OnPlayerChat)
Closing this as there are few solutions posted to the problem.