• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Halt Event Chain

Status
Not open for further replies.

avatarscape

Emulation Addict
Just wondering.. Is it possible to terminate handling of an event in C++ by doing something in the LUA hook?
I'm trying to establish a secure communication between client and server on a specific prefix, however if players can send each other messages using the same prefix, There'll be problems. I decided a way round this is to halt processing of all ADDON_EVENT_ON_MESSAGE events with a certain prefix and handle them by the server instead.

Any ideas?
 

Rochet2

Moderator / Eluna Dev
Halting chat messages (and few other things) was a special functionality coded in Eluna.
You can usually use return false to halt messages etc. Read hook comments for more info for what other hooks have:
https://github.com/ElunaLuaEngine/Eluna/blob/master/HookMgr.h#L117
Can return false or new msg
So you can even return a new message to replace what the player was saying.


And if it wasnt clear ..
returning means that the function triggered on the chat event should use "return false"
 
Last edited:

avatarscape

Emulation Addict
The addon event doesn't say it supports returning false :(

Come to think of it, the addon messages are always sent from the player itself. I might aswell just do a simple sender == UnitName("Player") to verify.
Thanks for that info anyway, will definitely come in useful.
 

Rochet2

Moderator / Eluna Dev
The addon event doesn't say it supports returning false :(

Come to think of it, the addon messages are always sent from the player itself. I might aswell just do a simple sender == UnitName("Player") to verify.
Thanks for that info anyway, will definitely come in useful.

Hmm, that is true for the addon message hook.
However, I was thinking you could use the normal chat messages. Or command hook possibly.
Maybe we should implement the same return functionality to addon messaging.

The SendAddonMessage method on server side sends the player guid so it can be checked yes. (note that this is not default functionality in TC)
 

avatarscape

Emulation Addict
Thanks for the info.
Is it possible by some comment at the beginning of the file or so, to specify files that need to be loaded before the active file?
I only ask because I'm porting certain ace libraries which require other libraries. Or are they loaded alphabetically, or what?
 

Rochet2

Moderator / Eluna Dev
Thanks for the info.
Is it possible by some comment at the beginning of the file or so, to specify files that need to be loaded before the active file?
I only ask because I'm porting certain ace libraries which require other libraries. Or are they loaded alphabetically, or what?

Files are loaded alphabetically, however many things affect that as only the path is compared.
This means that folder starting with A is loaded before a script starting with B in the same folder.

You can use require function.
Require was recently modified to search the whole script folder tree and it is intended that one uses it like this:
require("filename")
filename should only have the file name, not a path, unless the file exists outside of the script directory.
filename should only have the file name. This means that there should be no extentions like .lua or similar.

Example:
local AIO = require("AIO")
 

Rochet2

Moderator / Eluna Dev
Spell:GetTargetDest() only has 1 return value. I've checked out the function and it should return 3 values...
Can you show the full code and tell what the return values are that you are getting?
The method should return the x,y,z or nil.

local x,y,z = spell:GetTargetDest()
print(x,y,z) -- prints coords or nils (doesnt print anything)

The implementation checks if the spell actually has dest:
Code:
#ifndef TRINITY
        if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
            return 3;
        float x, y, z;
        spell->m_targets.getDestination(x, y, z);
#else
        if (!spell->m_targets.HasDst())
            return 3;
        float x, y, z;
        spell->m_targets.GetDstPos()->GetPosition(x, y, z);
#endif
        Eluna::Push(E->L, x);
        Eluna::Push(E->L, y);
        Eluna::Push(E->L, z);
        return 3;
 

avatarscape

Emulation Addict
Can you show the full code and tell what the return values are that you are getting?
The method should return the x,y,z or nil.

local x,y,z = spell:GetTargetDest()
print(x,y,z) -- prints coords or nils (doesnt print anything)

The implementation checks if the spell actually has dest:
Code:
#ifndef TRINITY
        if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
            return 3;
        float x, y, z;
        spell->m_targets.getDestination(x, y, z);
#else
        if (!spell->m_targets.HasDst())
            return 3;
        float x, y, z;
        spell->m_targets.GetDstPos()->GetPosition(x, y, z);
#endif
        Eluna::Push(E->L, x);
        Eluna::Push(E->L, y);
        Eluna::Push(E->L, z);
        return 3;

This was the code:
function DebugSpellCast(event, player, spell, skipCheck)
print(spell:GetTargetDest());
end
RegisterPlayerEvent(5, DebugSpellCast)

It only outputs one value. When set it as variables, only x has a value.
 

Rochet2

Moderator / Eluna Dev
Hmm, need to take a look at this more. The function itself doesnt have an error and similar functions like GetLocation work fine.
The values get pushed normally, but the values in lua are invalid. Also the return amount in implementation is correct and if it wouldnt be, there would be an error message.

https://github.com/ElunaLuaEngine/Eluna/issues/125
 
Last edited:
Status
Not open for further replies.
Top