Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- #include "GuildMgr.h"
- //===============
- // Guild Wars
- // by Mager1794
- // Transcendent Scripting
- // Translated raw to TC on 19th of Dec 2012 by Rochet2
- //===============
- /*
- -- SQL (execute to character database
- CREATE TABLE guild_wars (
- aguild INT(10) UNSIGNED NOT NULL,
- bguild INT(10) UNSIGNED NOT NULL,
- PRIMARY KEY (aguild, bguild)
- )
- COLLATE='latin1_swedish_ci'
- ENGINE=InnoDB;
- */
- class Custom_GuildWars : public CreatureScript
- {
- public:
- Custom_GuildWars() : CreatureScript("Custom_GuildWars") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- player->ADD_GOSSIP_ITEM_EXTENDED(1, "Propose A Guild War", 1, 0, "Enter guild name", 0, true);
- player->ADD_GOSSIP_ITEM_EXTENDED(1, "Propose A Guild Peace", 1, 1, "Enter guild name", 0, true);
- player->SEND_GOSSIP_MENU(2593, creature->GetGUID());
- return true;
- }
- bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code)
- {
- player->PlayerTalkClass->ClearMenus();
- uint32 friendly = player->GetGuildId();
- Guild* guilda;
- if(!friendly || !(guilda = sGuildMgr->GetGuildById(friendly)))
- player->GetSession()->SendNotification("You are not in a guild");
- else if(Guild* guildb = sGuildMgr->GetGuildByName(code))
- {
- uint32 enemy = guildb->GetId();
- if(friendly == enemy)
- player->GetSession()->SendNotification("You cannot declare war on your own guild");
- else if(guilda->GetLeaderGUID() != player->GetGUID())
- player->GetSession()->SendNotification("You must be the guild leader");
- else
- {
- std::ostringstream ss;
- if(!action)
- {
- CharacterDatabase.PExecute("REPLACE INTO guild_wars VALUES(%u,%u)", friendly, enemy);
- CharacterDatabase.PExecute("REPLACE INTO guild_wars VALUES(%u,%u)", enemy, friendly);
- ss << "[Guild Wars] " << guilda->GetName().c_str() << " has declared war on " << guildb->GetName().c_str();
- }
- else
- {
- CharacterDatabase.PExecute("DELETE FROM guild_wars WHERE aguild = %u AND bguild= %u", friendly, enemy);
- CharacterDatabase.PExecute("DELETE FROM guild_wars WHERE aguild = %u AND bguild= %u", enemy, friendly);
- ss << "[Guild Wars] " << guilda->GetName().c_str() << " has declared peace with " << guildb->GetName().c_str();
- }
- sWorld->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
- }
- }
- else
- player->GetSession()->SendNotification("Invalid guild name inserted");
- OnGossipHello(player, creature);
- return true;
- }
- };
- class Custom_GuildWars_PvP : public PlayerScript
- {
- public:
- Custom_GuildWars_PvP() : PlayerScript("Custom_GuildWars_PvP") { }
- void OnPVPKill(Player* killer, Player* killed)
- {
- uint32 aguild = killer->GetGuildId();
- uint32 vguild = killed->GetGuildId();
- if(!aguild || !vguild || aguild == vguild)
- return;
- QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM guild_wars WHERE aguild = %u AND bguild = %u", aguild, vguild);
- if(result)
- {
- if(result->Fetch())
- {
- killer->ModifyMoney(10000);
- killed->ModifyMoney(-5000);
- }
- }
- }
- };
- void AddSC_Custom_GuildWars()
- {
- new Custom_GuildWars();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement