Code:
#include "StdAfx.h"
#include "Setup.h"
class SCRIPT_DECL GuildPortItem : public GossipScript{
public:
void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void GuildPortItem::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
{
GossipMenu * Menu;
uint32 TextID = 820;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), TextID, Plr);
if(Plr->GetGuildId() > 0)
{
Menu->AddItem(5, "Go to your Guild Location", 1);
}
else
{
Menu->AddItem(5, "You know what, never mind", 2);
}
if(AutoSend)
Menu->SendTo(Plr);
}
void GuildPortItem::GossipSelectOption(Object * pObject, Player * Plr, uint32 Id, uint32 IntId, const char * Code)
{
Item * pItem = (pObject->GetTypeId()==TYPEID_ITEM)?((Item*)pObject):NULL;
if(pItem==NULL)
return;
switch(IntId)
{
case 0:
{
GossipHello(pItem, Plr, true);
}
break;
case 1:
{
QueryResult * result = WorldDatabase.Query( "SELECT * FROM guildlocations WHERE `GuildID`=%u",Plr->GetGuildId() );
if(result)
{
do
{
Field * fields = result->Fetch();
uint32 locmap = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
Plr->SafeTeleport(locmap, 0, LocationVector(x, y, z));
}
while (result->NextRow());
delete result;
}
else
{
sChatHandler.SystemMessage(Plr->GetSession(),"No location found in the database");
}
Plr->Gossip_Complete();
}
break;
case 2:
{
Plr->Gossip_Complete();
}
break;
}
}
void GuildPortItem::GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
}
void SetupGuildPortItem(ScriptMgr * mgr)
{
GossipScript * gpItem = (GossipScript*) new GuildPortItem();
mgr->register_item_gossip_script(34583, gpItem); //GP Item
}
Code:
INSERT INTO `items` VALUES ('34583', '8', '-1', '-1', 'Guild Item', 'Guild Item', 'Guild Item', 'Guild Item', '42629', '1', '0', '0', '0', '0', '1503', '1791', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '33208', '0', '579', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'Let The Guild Battles Begin!', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', null, '0', null, '0', '0', '0', '0', '0', '0', '0', null, null, '0', '-1', '0');