Eluna add OnAddonMessage event

Added OnAddonMessage event for Client <-> Server Addon communication
This commit is contained in:
Foereaper
2014-04-05 23:51:06 +02:00
parent b02cb0f545
commit a9542a28cb
2 changed files with 29 additions and 0 deletions

View File

@@ -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

View File

@@ -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);