azerothcore/mod-eluna-lua-engine

Bug in Say() method

DamianBajofer opened this issue · 4 comments

Hey, i have the latest reversion of AzerothCore and i am having an problem with the method Say()

I download azeroth core 3 days ago and eluna too!

This is the result
1
2
3

Any solution?

print the hash commit of:

  • azerothcore
  • mod-eluna-lua-engine
  • LuaEngine

to get it you can go to the directory, write git log:
image

same for ac and LuaEngine directory

I haven't .git directory in my source or eluna-engine.. then i cant use git log

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)

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.