Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* required sql tables for Guild System*/
- // remove /* */ around the query if you dont want sql errors.
- /*
- DROP TABLE IF EXISTS "ab_guild_lands";
- CREATE TABLE "ab_guild_lands" (
- "guild_id" int(6) unsigned NOT NULL DEFAULT '0',
- "posX" float NOT NULL DEFAULT '0',
- "posY" float NOT NULL DEFAULT '0',
- "posZ" float NOT NULL DEFAULT '0',
- "mapId" int(10) unsigned NOT NULL DEFAULT '0',
- "zoneid" int(10) unsigned NOT NULL COMMENT 'zone id',
- "areaid" int(10) unsigned NOT NULL COMMENT 'area id',
- PRIMARY KEY ("zoneid")
- );
- DROP TABLE IF EXISTS "ab_land_data";
- CREATE TABLE "ab_land_data" (
- "guild_id" int(6) unsigned NOT NULL,
- "hostility" enum('HOSTILE','PASSIVE') NOT NULL DEFAULT 'PASSIVE' COMMENT 'Hostility checks',
- "deed" enum('NOTFORSALE','FORSALE') NOT NULL DEFAULT 'NOTFORSALE',
- "landtax" enum('0','1','2','3','4','5','6','7','8','9','10') NOT NULL DEFAULT '0',
- "SalePrice" enum('10K','15K','20K','25K','50K','75K','100k','125K','150K','175K','200K') NOT NULL DEFAULT '10K' COMMENT 'sales checks',
- "mapid" int(10) unsigned NOT NULL,
- "areaid" int(10) unsigned NOT NULL,
- "zoneid" int(10) unsigned NOT NULL,
- PRIMARY KEY ("zoneid")
- );
- */
- #include "StdAfx.h"
- #include "Setup.h"
- // The Defines below are not yet implemented, please be patient, its hot and muggy
- // out here in Tac Town
- #define REQ_LEVEL 80 // change this for level requirements
- // REMOVING GOLD REMOVAL UNTIL CODED PROPERLY
- // #define REQ_COINAGE 1500000000 // 1500000000 = 150k Gold
- #define PORT_REQ_COINAGE 15000 // ??
- #define FOOD_ID 45932
- //#define SETPRICE_10 10K
- //#define SETPRICE_15 15K
- //#define SETPRICE_20 20K
- //#define SETPRICE_25 25K
- //#define SETPRICE_50 50K
- //#define SETPRICE_75 75K
- //#define SETPRICE_100 100K
- //#define SETPRICE_125 125K
- //#define SETPRICE_150 150K
- //#define SETPRICE_175 175K
- //#define SETPRICE_200 200K
- //#define GUILD_SHOP_NPC 993311 // Jotoxs Sick Automated Vendor.(look on mmowned for the updated script)
- //#define SPELL_BUFF 22888 // I chose Rallying Cry of the Dragon
- static bool bypassCombat = false;//If set to true, will enable players to #event while in combat
- // Chat Commands
- static string COMS = "#help"; // Lists commands
- static string COM_ZONE = "#zone";
- static string SET_4_SALE = "#zone sell"; // sets land for sale
- static string BUYLAND = "#zone buy"; // Buys land if its available for purchase in world.
- static string SET_NOT_4_SALE = "#zone reset"; // sets not for sale
- static string G_HEARTH = "#zone port"; // Ports player to closest Guild house if in a Zone owned by Guild
- static string SET_G_HEARTH = "#zone hearth"; // Sets the location for #zone port
- static string COM_ADD = "#add";
- static string ADD_FOOD = "#add food"; // Gives player food/drink
- static string ADD_ITEM = "#add item"; // Gives player items
- static string plr_evn_cmd = "#event";
- static string event_com = "#event on";
- static string event_off = "#event off";
- static string mall_cmd = "#mall";
- static string mall_nort = "#mall northrend";
- static string mall_outl = "#mall outlands";
- static string mall_kalim = "#mall kalimdor";
- static string mall_azero = "#mall azeroth";
- //Default Values
- static bool event_on = false;
- static uint32 emapid = 0;
- static float ex = 0.0f;
- static float ey = 0.0f;
- static float ez = 0.0f;
- // commented out statics will be usable functions in the near future.
- //static string WORLD_CHAT = "#world";
- //static string SHOP = "#guild shop"; //will spawn Jotox's NPC ID - I will not provide his script, I just really love his Vendor Script :)
- //static string BUFFME = "#buffme"; // Gives player buffs - dont have correct functions for adding buffs properly yet
- void AddItem(PlayerPointer Plr, const uint32 &ItemID, const uint32 &Amt, const bool &Stack)
- {
- ItemPointer ITEM_PTR;
- SlotResult SlotID;
- if(Plr == NULL)
- return;
- if(Stack)
- {
- ITEM_PTR = Plr->GetItemInterface()->FindItemLessMax(ItemID, Amt, false);
- if(ITEM_PTR != NULLITEM)
- {
- ITEM_PTR->ModUnsigned32Value(ITEM_FIELD_STACK_COUNT, Amt);
- ITEM_PTR->m_isDirty = true;
- Plr->BroadcastMessage("You have recieved %s%s x%u.", MSG_COLOR_GREEN, ITEM_PTR->GetProto()->Name1, Amt);
- return;
- }
- }
- for(uint32 i = 1;i <= Amt;i++)
- {
- ITEM_PTR = objmgr.CreateItem(ItemID, Plr);
- if(ITEM_PTR == NULLITEM)
- return;
- SlotID = Plr->GetItemInterface()->FindFreeInventorySlot(ITEM_PTR->GetProto());
- if(SlotID.Result)
- {
- Plr->GetItemInterface()->SafeAddItem(ItemID, SlotID.ContainerSlot, SlotID.Slot);
- Plr->BroadcastMessage("You have recieved %s%s x%u.", MSG_COLOR_GREEN, ITEM_PTR->GetProto()->Name1, Amt);
- }
- else
- Plr->SendAreaTriggerMessage("You Do not have enough Free Space.");
- }
- }
- bool Guild_Chat(PlayerPointer Plr, uint32 Type, uint32 Lang, string Message, string Misc)
- {
- if(Message == COMS)
- {
- Plr->BroadcastMessage("[Commands List]");
- Plr->BroadcastMessage("[YOU MUST USE LOWERCASE!]");
- Plr->BroadcastMessage("#help - Shows available Commands.");
- Plr->BroadcastMessage("#zone - Used for zone commands.");
- Plr->BroadcastMessage("#add - Adds an Item to your Bags.");
- Plr->BroadcastMessage("#mall - available mall ports.");
- Plr->BroadcastMessage("#event - join available events.");
- return true;
- }
- else if(Message == COM_ZONE)
- {
- Plr->BroadcastMessage("[Commands List]");
- Plr->BroadcastMessage("#zone sell - Sets your land For Sale");
- Plr->BroadcastMessage("#zone buy - Use this command to purchase Land for your Guild.");
- Plr->BroadcastMessage("#zone reset - Resets your land Sale - Must be done before another player purchases land.");
- Plr->BroadcastMessage("#zone port - Teleports you to nearest Guild House on Land you own.");
- Plr->BroadcastMessage("#zone hearth - Resets Your Guilds Hearth Location per Zone.");
- return true;
- }
- else if(Message == COM_ADD)
- {
- Plr->BroadcastMessage("[Commands List]");
- Plr->BroadcastMessage("#add food - Adds Food to your Bags.");
- return true;
- }
- //else if(Message == COM_ADD_ITEM)
- // {
- // Plr->BroadcastMessage("[Commands List]");
- // Plr->BroadcastMessage("#add item swords - Adds Food to your Bags.");
- //return true;
- //}
- else if(Message == BUYLAND)
- {
- QueryResult * Q_RES_BUY_COM = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
- QueryResult * Q_RES_BUY_FORSALE = CharacterDatabase.Query("SELECT * FROM ab_land_data WHERE zoneid = %u AND deed = FORSALE", Plr->GetZoneId());
- if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
- {
- Plr->BroadcastMessage("You can't purchase Instances!");
- return true;
- }
- if(
- Plr->CombatStatus.IsInCombat())
- {
- Plr->BroadcastMessage("You are in Combat!");
- return true;
- }
- if(
- Plr->getLevel() < REQ_LEVEL) // I run a High rate server, so I set this level cap to 80 for default
- {
- Plr->BroadcastMessage("You must be level 80.");
- return true;
- }
- if(
- Plr->GetGuildId() == NULL)
- {
- Plr->BroadcastMessage("You are not in a Guild.");
- return true;
- }
- if(
- Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
- {
- Plr->BroadcastMessage("You are not the Guild Master.");
- return true;
- }
- if(Q_RES_BUY_FORSALE != NULL)
- {
- Plr->BroadcastMessage("This area is not for sale.");
- }
- if(Q_RES_BUY_FORSALE == NULL)
- {
- CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
- CharacterDatabase.Execute("REPLACE INTO ab_guild_lands VALUES('%u', '%f', '%f', '%f', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetPositionX(), Plr->GetPositionY(), Plr->GetPositionZ(), Plr->GetMapId(), Plr->GetZoneId(), Plr->GetAreaID());
- Plr->BroadcastMessage("Congrats! You just purchased this Zone From another Guild.");
- }
- if(Q_RES_BUY_COM != NULL)
- {
- Plr->BroadcastMessage("This area has already been purchased.");
- }
- if(Q_RES_BUY_COM == NULL)
- {
- CharacterDatabase.Execute("INSERT INTO ab_guild_lands VALUES('%u', '%f', '%f', '%f', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetPositionX(), Plr->GetPositionY(), Plr->GetPositionZ(), Plr->GetMapId(), Plr->GetZoneId(), Plr->GetAreaID());
- CharacterDatabase.Execute("INSERT INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
- Plr->BroadcastMessage("Gratz! Your Guild now Owns this area.");
- }
- return true;
- }
- else if(Message == SET_G_HEARTH)
- {
- QueryResult * Q_RES_G_HEARTH_SET = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
- if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
- {
- Plr->BroadcastMessage("You can't use this command in Instances!");
- return true;
- }
- if(
- Plr->CombatStatus.IsInCombat())
- {
- Plr->BroadcastMessage("You are in Combat!");
- return true;
- }
- if(
- Plr->getLevel() < REQ_LEVEL)
- {
- Plr->BroadcastMessage("You must be level 80.");
- return true;
- }
- if(
- Plr->GetGuildId() == NULL)
- {
- Plr->BroadcastMessage("You are not in a Guild.");
- return true;
- }
- if(
- Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
- {
- Plr->BroadcastMessage("You are not the Guild Master.");
- return true;
- }
- if(Q_RES_G_HEARTH_SET == NULL)
- {
- Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
- }
- if(Q_RES_G_HEARTH_SET != NULL)
- {
- CharacterDatabase.Execute("REPLACE INTO ab_guild_lands VALUES('%u', '%f', '%f', '%f', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetPositionX(), Plr->GetPositionY(), Plr->GetPositionZ(), Plr->GetMapId(), Plr->GetZoneId(), Plr->GetAreaID());
- Plr->BroadcastMessage("Your Guild Hearth Is Now Set.");
- }
- return true;
- }
- else if(Message == SET_4_SALE)
- {
- QueryResult * Q_RES_SET_4_SALE = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
- uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
- QueryResult * Q_RES_SET_DATA = CharacterDatabase.Query("SELECT * FROM ab_land_data WHERE guild_id = %u AND zoneid = %u AND deed = NOTFORSALE", Plr->GetGuildId(), Plr->GetZoneId());
- if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
- {
- Plr->BroadcastMessage("You can't use this command in Instances!");
- return true;
- }
- if(
- Plr->CombatStatus.IsInCombat())
- {
- Plr->BroadcastMessage("You are in Combat!");
- return true;
- }
- if(
- Plr->getLevel() < REQ_LEVEL)
- {
- Plr->BroadcastMessage("You must be level 80.");
- return true;
- }
- if(
- Plr->GetGuildId() == NULL)
- {
- Plr->BroadcastMessage("You are not in a Guild.");
- return true;
- }
- if(
- Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
- {
- Plr->BroadcastMessage("You are not the Guild Master.");
- return true;
- }
- if(Q_RES_SET_4_SALE == NULL)
- {
- Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
- }
- if(Q_RES_SET_DATA == NULL)
- {
- Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
- }
- if(Q_RES_SET_4_SALE != NULL)
- {
- CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'FORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
- Plr->BroadcastMessage("Your Land is now for Sale, you still have the option to reset your sale, but this must be done before someone purchases the land.");
- }
- if(Q_RES_SET_DATA != NULL)
- {
- CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'FORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
- Plr->BroadcastMessage("Your Land is now for Sale, you still have the option to reset your sale, but this must be done before someone purchases the land.");
- }
- return true;
- }
- else if(Message == SET_NOT_4_SALE)
- {
- QueryResult * Q_RES_SET_NOT_4_SALE = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
- uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
- QueryResult * Q_RES_SET_DATA2 = CharacterDatabase.Query("SELECT * FROM ab_land_data WHERE guild_id = %u AND zoneid = %u AND deed = FORSALE", Plr->GetGuildId(), Plr->GetZoneId());
- if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
- {
- Plr->BroadcastMessage("You can't use this command in Instances!");
- return true;
- }
- if(
- Plr->CombatStatus.IsInCombat())
- {
- Plr->BroadcastMessage("You are in Combat!");
- return true;
- }
- if(
- Plr->getLevel() < REQ_LEVEL)
- {
- Plr->BroadcastMessage("You must be level 80.");
- return true;
- }
- if(
- Plr->GetGuildId() == NULL)
- {
- Plr->BroadcastMessage("You are not in a Guild.");
- return true;
- }
- if(
- Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
- {
- Plr->BroadcastMessage("You are not the Guild Master.");
- return true;
- }
- if(Q_RES_SET_NOT_4_SALE == NULL)
- {
- Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
- }
- if(Q_RES_SET_DATA2 == NULL)
- {
- Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
- }
- if(Q_RES_SET_NOT_4_SALE != NULL)
- {
- CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
- Plr->BroadcastMessage("Your Land is no longer for sale.");
- }
- if(Q_RES_SET_DATA2 != NULL)
- {
- CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
- Plr->BroadcastMessage("Your Land is no longer for sale.");
- }
- return true;
- }
- else if(Message == ADD_FOOD)
- {
- AddItem(Plr, FOOD_ID, 1, true);// "1" is the amount of the item to give - True means we stack item
- return true;
- }
- else if(Message == event_com && Plr->GetSession()->HasGMPermissions())
- {
- event_on = true;
- ex = Plr->GetPositionX();
- ey = Plr->GetPositionY();
- ez = Plr->GetPositionZ();
- emapid = Plr->GetMapId();
- return true;
- }
- else if(Message == event_off && Plr->GetSession()->HasGMPermissions())
- {
- event_on = false;
- return true;
- }
- else if(Message == plr_evn_cmd)
- {
- if(event_on)
- if(bypassCombat || !Plr->CombatStatus.IsInCombat())
- Plr->EventTeleport(emapid, ex, ey, ez);
- else
- Plr->BroadcastMessage("You can't port while in combat.");
- else
- Plr->BroadcastMessage("There's no active event at the moment.");
- return true;
- }
- else if(Message == mall_cmd)
- {
- if(bypassCombat || !Plr->CombatStatus.IsInCombat())
- if( Plr->GetTeam() == 1 )
- Plr->EventTeleport(571, 2827.1, 6176.8, 122); //<---Done Horde Mall--->//
- else
- Plr->EventTeleport(571, 2314.69, 5258.58, 12); //<-----Done Ally Mall--->//
- else
- Plr->BroadcastMessage("You can't port while in combat.");
- return true;
- }
- else if(Message == G_HEARTH)
- {
- QueryResult * Q_RES_LOWBIE = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
- if(Q_RES_LOWBIE == NULL)
- {
- Plr->BroadcastMessage("Your Guild does not own any Land Nearby.");
- Plr->Gossip_Complete();
- return true;
- }
- if(Q_RES_LOWBIE->GetRowCount() > 1)
- {
- Plr->BroadcastMessage("Error 421 - Please Report this on the Forums - MYSQL Error - Too much Data to Input");
- Plr->Gossip_Complete();
- return true;
- }
- float x, y, z;
- uint32 MapID;
- Field * F_RES = Q_RES_LOWBIE->Fetch();
- x = F_RES[1].GetFloat();
- y = F_RES[2].GetFloat();
- z = F_RES[3].GetFloat();
- MapID = F_RES[4].GetUInt32();
- Plr->EventTeleport(MapID, x, y, z);
- }
- return true;
- }
- bool ZoneCheckHostile(PlayerPointer Plr, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
- { QueryResult * RES_IS_LAND_HOSTILE = CharacterDatabase.Query("SELECT * FROM ab_land_data WHERE zoneid = %u AND hostility = HOSTILE", Plr->GetZoneId());
- if(RES_IS_LAND_HOSTILE == NULL)
- {
- Plr->SetFFAPvPFlag();
- sChatHandler.SystemMessage(Plr->GetSession(), "Be wary young Traveler, This land is hostile to you... ");
- return true;
- }
- }
- bool ZoneCheckPassive(PlayerPointer Plr, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
- {
- QueryResult * RES_IS_LAND_PASSIVE = CharacterDatabase.Query("SELECT * FROM ab_land_data WHERE zoneid = %u AND hostility = PASSIVE", Plr->GetZoneId());
- if(RES_IS_LAND_PASSIVE == NULL)
- {
- Plr->RemoveFFAPvPFlag();
- sChatHandler.SystemMessage(Plr->GetSession(), "You are in a Passive zone, you are now safe... for now.");
- return true;
- }
- }
- void OnNewGuild(PlayerPointer Plr, Guild * G_PTR)
- {
- char NewGuild[1024];
- snprintf((char*)NewGuild, 1024, "[Guild System] |cff33ff55 [%s]|r - has been formed by|cffff00bb %s", G_PTR->GetGuildName(), Plr->GetName());
- sWorld.SendWorldWideScreenText(NewGuild);
- }
- void OnJoinGuild(PlayerPointer Plr, Guild * G_PTR)
- {
- char JoinGuild[1024];
- snprintf((char*)JoinGuild, 1024, "[Guild System] |cff33ff55 [%s]|r - has Joined the Guild |cffff00bb %s", Plr->GetName(), G_PTR->GetGuildName());
- sWorld.SendWorldWideScreenText(JoinGuild);
- }
- void SetupGuild_Chat(ScriptMgr * mgr)
- {
- mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &Guild_Chat);
- mgr->register_hook(SERVER_HOOK_EVENT_ON_ZONE, &ZoneCheckHostile);
- mgr->register_hook(SERVER_HOOK_EVENT_ON_ZONE, &ZoneCheckPassive);
- mgr->register_hook(SERVER_HOOK_EVENT_ON_GUILD_CREATE, OnNewGuild);
- mgr->register_hook(SERVER_HOOK_EVENT_ON_GUILD_JOIN, OnJoinGuild);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement