mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna add OnAddonMessage event
Added OnAddonMessage event for Client <-> Server Addon communication
This commit is contained in:
25
HookMgr.cpp
25
HookMgr.cpp
@@ -214,6 +214,31 @@ bool HookMgr::OnPacketReceive(WorldSession* session, WorldPacket& packet)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// AddOns
|
||||
void HookMgr::OnAddonMessage(Player* pPlayer, std::string& msg, uint32 type, std::string& to)
|
||||
{
|
||||
if (!sEluna->ServerEventBindings.HasEvents(ADDON_EVENT_ON_MESSAGE))
|
||||
return;
|
||||
ELUNA_GUARD();
|
||||
sEluna->ServerEventBindings.BeginCall(ADDON_EVENT_ON_MESSAGE);
|
||||
sEluna->Push(sEluna->L, pPlayer);
|
||||
|
||||
const char* c_msg = msg.c_str();
|
||||
char* arg = strtok((char*)c_msg, "\t");
|
||||
while (arg)
|
||||
{
|
||||
sEluna->Push(sEluna->L, arg);
|
||||
arg = strtok(NULL, "\t");
|
||||
}
|
||||
|
||||
sEluna->Push(sEluna->L, type);
|
||||
if (to.empty())
|
||||
sEluna->Push(sEluna->L);
|
||||
else
|
||||
sEluna->Push(sEluna->L, to);
|
||||
sEluna->ServerEventBindings.ExecuteCall();
|
||||
sEluna->ServerEventBindings.EndCall();
|
||||
}
|
||||
|
||||
#ifndef MANGOS
|
||||
class ElunaWorldAI : public WorldScript
|
||||
|
||||
@@ -124,6 +124,9 @@ enum ServerEvents
|
||||
AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, AHObject) // NOT SUPPORTED YET
|
||||
AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET
|
||||
|
||||
// AddOns
|
||||
ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, msg)
|
||||
|
||||
SERVER_EVENT_COUNT
|
||||
};
|
||||
|
||||
@@ -329,6 +332,7 @@ public:
|
||||
void OnGmTicketDelete(Player* pPlayer); // Not on TC
|
||||
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
|
||||
void OnEngineRestart();
|
||||
void OnAddonMessage(Player* pPlayer, std::string& msg, uint32 type, std::string& to);
|
||||
|
||||
/* Item */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
|
||||
|
||||
Reference in New Issue
Block a user