Simple guild house teleport NPC and Item script.
Talk to the NPC / Item, and you get the option to teleport to your guild house (if you have one).
Guild house is any location in the world.
To add a guild house, edit the database.
Here's the SQL to add the guild house table:
Code:
CREATE TABLE guild_houses ( `guildid` bigint(20) NOT NULL,
`mapId` int(8) unsigned NOT NULL default '0',
`posx` float NOT NULL,
`posy` float NOT NULL,
`posz` float NOT NULL,
`poso` float NOT NULL,
PRIMARY KEY (`guildId`),
UNIQUE KEY `guildId` (`guildId`)
And here's the script.
Code:
//Simple Guild House Teleporter
//Made By Jotox/Classic
//REPLACE THIS WITH YOUR GUILD TELEPORT NPC ID. (0 for no npc)
#define NPC_ID 9999999
//REPLACE THIS WITH YOUR ITEM TELEPORTER ID. (0 for no item)
#define ITEM_ID 9999999
#include "StdAfx.h"
#include "Setup.h"
static string MSG_RED = "|CFFFF0000";
void GuildTeleport( Player* plr)
{
if( !plr->isAlive() || plr->CombatStatus.IsInCombat() )
{
plr->BroadcastMessage("%sYou cannot perform this action while %s.", MSG_RED, (plr->isAlive()) ? "in combat." : "dead." );
return;
}
if( !plr->IsInGuild() )
{
plr->BroadcastMessage("%sYou must be in a guild to use this.", MSG_RED);
return;
}
QueryResult *result = CharacterDatabase.Query("SELECT * FROM `guild_houses` WHERE guildid = '%u'", plr->GetGuildId() );
if( !result )
{
plr->BroadcastMessage("%sYour guild does not have a guild house.", MSG_RED);
return;
}
Field *fields = result->Fetch();
uint32 map = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
float o = fields[5].GetFloat();
plr->SafeTeleport( map , 0, x, y, z, o)
delete result;
}
class SCRIPT_DECL GuildTeleport : public GossipScript
{
public:
void GossipHello(Object * pObject, Player * plr, bool AutoSend)
{
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 0, plr);
Menu->AddItem( 0, "Teleport Me To My Guild House!", 1);
if(AutoSend)
Menu->SendTo(plr);
}
else
{
plr->BroadcastMessage("You must be in a guild to use this.");
}
}
void GossipSelectOption(Object * pObject, Player * plr, uint32 Id, uint32 IntId, const char * Code)
{
plr->Gossip_Complete();
GuildTeleport( plr );
}
void GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
}
void Destroy()
{
delete this;
}
};
void SetupGuildTeleporter(ScriptMgr * mgr)
{
GossipScript* gs = (GossipScript*) new GuildTeleport();
if( NPC_ID > 0 )
mgr->register_gossip_script(NPC_ID, gs );
if( ITEM_ID > 0 )
mgr->register_item_gossip_script(ITEM_ID, gs );
}
/*
CREATE TABLE guild_houses ( `guildid` bigint(20) NOT NULL,
`mapId` int(8) unsigned NOT NULL default '0',
`posx` float NOT NULL,
`posy` float NOT NULL,
`posz` float NOT NULL,
`poso` float NOT NULL,
PRIMARY KEY (`guildId`),
UNIQUE KEY `guildId` (`guildId`)
)*/