/************************************************************************/ /* GuildHousing.cpp Script */ /* © 2006-2007 XzWoW Team */ /* Xel Database */ /************************************************************************/ /* * XzWoW Guild Housing * * Author : Xelynn * * About: * Buy guild houses(30,000 gold), add 100 guild keys then teleport into your house. * Still in development * TODO: * make it so it adds item, currently does not for some reason * make it so theres a sql taken check to send player message if taken(check todolist) */ #include "StdAfx.h" #include "Setup.h" class SCRIPT_DECL ZhizheGossip : public GossipScript { public: ADD_GOSSIP_FACTORY_FUNCTION(ZhizheGossip); void GossipHello(Creature* pCreature, Player* Plr, bool AutoSend); void GossipSelectOption(Creature* pCreature, Player* Plr, uint32 Id, uint32 IntId); void GossipEnd(Creature* pCreature, Player* Plr); }; void ZhizheGossip::GossipHello(Creature* pCreature, Player* Plr, bool AutoSend) { sLog.outDetail("GuildHousing.cpp : Hello by %s", Plr->GetName()); GossipMenu *Menu; uint32 TextID =1001005; // Hello (First) Menu. objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), TextID, Plr); if( pCreature->GetUInt32Value(UNIT_NPC_FLAGS) & UNIT_NPC_FLAG_VENDOR ) Menu-> AddItem (1, "[ Buy a Guild House ]", 1); if(AutoSend) Menu->SendTo(Plr); } #define SendQuickMenu(textid) objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), textid, Plr); \ Menu->SendTo(Plr); void ZhizheGossip::GossipSelectOption(Creature* pCreature, Player* Plr, uint32 Id, uint32 IntId) { sLog.outDebug("Gossip-Zhizhe.cpp : Select option %u by %s", IntId, Plr->GetName()); switch(IntId) { case 0: // Return to start GossipHello(pCreature, Plr, true); break; case 1: //野外 GossipMenu *Menu1; objmgr.CreateGossipMenuForPlayer(&Menu1, pCreature->GetGUID(), 1001005, Plr); Menu1->AddItem( 0, " Guild House 1 " , 2); Menu1->SendTo(Plr); break; case 2: // (info->mapId, 0, LocationVector(info->positionX, info->positionY, info->positionZ)); { uint32 price=10000000;// uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); if (currentgold>=price){ int32 newgold = currentgold - price; Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); Item *item = objmgr.CreateItem( 100601, Plr); // Guild Key 1 Plr->GetItemInterface()->AddItemToFreeSlot(item); Plr->SafeTeleport(451,0,15637.739258,-16175.264648,44.936722,6.273752); }else{ Plr->GetSession()->SendNotification("You don't have enough money. Need %u Gold",price/30,000); } } QueryResult * result = NULL; result = CharacterDatabase.Query("SELECT Taken FROM guildhouses WHERE Id='1'"); uint32 Taken = result->Fetch()->GetUInt32(); if(Taken == 1) { Plr->BroadcastMessage("This house has already been selected"); } break; } } void ZhizheGossip::GossipEnd(Creature* pCreature, Player* Plr) { GossipScript::GossipEnd(pCreature, Plr); } void SetupZhizhe(ScriptMgr * mgr) { /* List */ mgr->register_gossip_script(1001005, &ZhizheGossip::Create); //Goldtooth Sleezer }