Advertisement
Guest User

Untitled

a guest
Jul 31st, 2009
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.85 KB | None | 0 0
  1. /*
  2. Required SQL Tables.  Load these into your Character DataBase.
  3. */
  4. /*
  5. # HeidiSQL Dump
  6. #
  7. # --------------------------------------------------------
  8. # Host:                         127.0.0.1
  9. # Database:                     logon_conquest
  10. # Server version:               5.1.30-community
  11. # Server OS:                    Win32
  12. # Target compatibility:         ANSI SQL
  13. # HeidiSQL version:             4.0
  14. # Date/time:                    2009-07-31 04:32:26
  15. # --------------------------------------------------------
  16.  
  17. /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI,NO_BACKSLASH_ESCAPES';*/
  18. /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;*/
  19.  
  20.  
  21. DROP TABLE IF EXISTS "ab_guild_lands";
  22.  
  23. #
  24. # Table structure for table 'ab_guild_lands'
  25. #
  26.  
  27. CREATE TABLE "ab_guild_lands" (
  28.   "guild_id" int(6) unsigned NOT NULL DEFAULT '0',
  29.   "posX" float NOT NULL DEFAULT '0',
  30.   "posY" float NOT NULL DEFAULT '0',
  31.   "posZ" float NOT NULL DEFAULT '0',
  32.   "mapId" int(10) unsigned NOT NULL DEFAULT '0',
  33.   "zoneid" int(10) unsigned NOT NULL COMMENT 'zone id',
  34.   "areaid" int(10) unsigned NOT NULL COMMENT 'area id',
  35.   PRIMARY KEY ("zoneid")
  36. );
  37.  
  38.  
  39.  
  40. DROP TABLE IF EXISTS "ab_land_data";
  41.  
  42. #
  43. # Table structure for table 'ab_land_data'
  44. #
  45.  
  46. CREATE TABLE "ab_land_data" (
  47.   "guild_id" int(6) unsigned NOT NULL,
  48.   "hostility" enum('HOSTILE','PASSIVE') NOT NULL DEFAULT 'PASSIVE' COMMENT 'Hostility checks',
  49.   "deed" enum('NOTFORSALE','FORSALE') NOT NULL DEFAULT 'NOTFORSALE',
  50.   "landtax" enum('0','1','2','3','4','5','6','7','8','9','10') NOT NULL DEFAULT '0',
  51.   "SalePrice" enum('10K','15K','20K','25K','50K','75K','100k','125K','150K','175K','200K') NOT NULL DEFAULT '10K' COMMENT 'sales checks',
  52.   "mapid" int(10) unsigned NOT NULL,
  53.   "areaid" int(10) unsigned NOT NULL,
  54.   "zoneid" int(10) unsigned NOT NULL,
  55.   PRIMARY KEY ("zoneid")
  56. );
  57.  
  58. /*!40101 SET SQL_MODE=@OLD_SQL_MODE;*/
  59. /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;*/
  60.  
  61. */
  62.  
  63. #include "StdAfx.h"
  64. #include "Setup.h"
  65.  
  66. // The Defines below are not yet implemented, please be patient, its hot and muggy
  67. // out here in Tac Town
  68.  
  69. #define GUILD_MASTER_ITEM           62810       // Guild Control Item
  70. #define REQ_COINAGE                 1500000000  // 1500000000 = 150k Gold
  71. #define PORT_REQ_COINAGE            15000       // ??
  72. #define FOOD_ID                     45932
  73. //#define SETPRICE_10                   10K
  74. //#define SETPRICE_15                   15K
  75. //#define SETPRICE_20                   20K
  76. //#define SETPRICE_25                   25K
  77. //#define SETPRICE_50                   50K
  78. //#define SETPRICE_75                   75K
  79. //#define SETPRICE_100              100K
  80. //#define SETPRICE_125              125K
  81. //#define SETPRICE_150              150K
  82. //#define SETPRICE_175              175K
  83. //#define SETPRICE_200              200K
  84. //#define GUILD_SHOP_NPC            993311     // Jotoxs Sick Automated Vendor.(look on mmowned for the updated script)
  85. //#define SPELL_BUFF                22888       // I chose Rallying Cry of the Dragon
  86.  
  87. // Chat Commands
  88. static string COMS              = "#help";  // Lists commands
  89. static string BUYLAND           = "#buyland";   // Buys land if its available for purchase in world.
  90. static string G_HEARTH          = "#guild hearth"; // Ports player to closest Guild house if in a Zone owned by Guild
  91. static string ADD_FOOD          = "#add food";  // Gives player food/drink
  92. static string ADD_ITEM          = "#add item";
  93. static string SET_G_HEARTH      = "#set guildhearth";
  94.  
  95. // commented out statics will be usable functions in the near future.
  96.  
  97. static string WORLD_CHAT        = "#world";
  98. static string SHOP              = "#guild shop"; //will spawn Jotox's NPC ID - I will not provide his script, I just really love his Vendor Script :)
  99. //static string BUFFME          = "#buffme";    // Gives player buffs - dont have correct functions for adding buffs properly yet
  100. static string SET_4_SALE        = "#set forsale"; // sets land for sale
  101. static string SET_NOT_4_SALE    = "#set notforsale"; // sets not for sale
  102.  
  103. void AddItem(PlayerPointer Plr, const uint32 &ItemID, const uint32 &Amt, const bool &Stack)
  104. {
  105.     ItemPointer ITEM_PTR;
  106.     SlotResult SlotID;
  107.    
  108.     if(Plr == NULL)
  109.         return;
  110.     if(Stack)
  111.     {
  112.     ITEM_PTR = Plr->GetItemInterface()->FindItemLessMax(ItemID, Amt, false);
  113.         if(ITEM_PTR != NULLITEM)
  114.         {
  115.         ITEM_PTR->ModUnsigned32Value(ITEM_FIELD_STACK_COUNT, Amt);
  116.         ITEM_PTR->m_isDirty = true;
  117.         Plr->BroadcastMessage("You have recieved %s%s x%u.", MSG_COLOR_GREEN, ITEM_PTR->GetProto()->Name1, Amt);
  118.         return;
  119.         }      
  120.     }
  121.     for(uint32 i = 1;i <= Amt;i++)
  122.     {
  123.     ITEM_PTR = objmgr.CreateItem(ItemID, Plr);
  124.         if(ITEM_PTR == NULLITEM)
  125.         return;
  126.         SlotID = Plr->GetItemInterface()->FindFreeInventorySlot(ITEM_PTR->GetProto());
  127.         if(SlotID.Result)
  128.         {
  129.         Plr->GetItemInterface()->SafeAddItem(ItemID, SlotID.ContainerSlot, SlotID.Slot);
  130.         Plr->BroadcastMessage("You have recieved %s%s x%u.", MSG_COLOR_GREEN, ITEM_PTR->GetProto()->Name1, Amt);
  131.         }
  132.         else
  133.         Plr->SendAreaTriggerMessage("You Do not have enough Free Space.");
  134.     }
  135. }
  136.  
  137. bool Guild_Chat(PlayerPointer Plr, uint32 Type, uint32 Lang, string Message, string Misc)
  138. {
  139. if(Message == COMS)
  140.     {
  141.         Plr->BroadcastMessage("[Commands List]");
  142.         Plr->BroadcastMessage("#help - Shows available Commands.");
  143.         Plr->BroadcastMessage("#buyland - Use this command to purchase Land for your Guild.");
  144.         Plr->BroadcastMessage("#set forsale - Sets your land For Sale");
  145.         Plr->BroadcastMessage("#set notforsale - Resets your land Sale - Must be done before another player purchases land.");
  146.         Plr->BroadcastMessage("#guild hearth - Teleports you to nearest Guild House on Land you own.");
  147.         Plr->BroadcastMessage("#set guildhearth - Resets Your Guilds Hearth Location per Zone.");
  148.         Plr->BroadcastMessage("#add food - Adds Food to your Bags.");
  149. return true;
  150. }
  151. else if(Message == BUYLAND)
  152.     {
  153.     QueryResult * Q_RES_BUY_COM = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
  154.     uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
  155.     QueryResult * Q_RES_BUY_FORSALE = CharacterDatabase.Query("SELECT * FROM ab_land_data WHERE zoneid = %u AND deed = FORSALE", Plr->GetZoneId());
  156.    
  157.     if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
  158.     {
  159.         Plr->BroadcastMessage("You can't purchase Instances!");
  160.         return true;
  161.     }
  162.     if(
  163.         Plr->CombatStatus.IsInCombat())
  164.     {
  165.         Plr->BroadcastMessage("You are in Combat!");
  166.         return true;
  167.     }
  168.     if(
  169.         Plr->getLevel() < 10)
  170.     {
  171.         Plr->BroadcastMessage("You must be level 10.");
  172.         return true;
  173.     }
  174.     if(
  175.         Plr->GetGuildId() == NULL)
  176.     {  
  177.         Plr->BroadcastMessage("You are not in a Guild.");
  178.         return true;
  179.     }
  180.     if(
  181.         Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
  182.     {
  183.         Plr->BroadcastMessage("You are not the Guild Master.");
  184.         return true;
  185.     }
  186.     if(Q_RES_BUY_FORSALE != NULL)
  187.     {
  188.         Plr->BroadcastMessage("This area is not for sale.");
  189.     }
  190.     if(Q_RES_BUY_FORSALE == NULL)
  191.     {
  192.         CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
  193.         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());
  194.         Plr->BroadcastMessage("Congrats! You just purchased this Zone From another Guild.");
  195.     }
  196.     if(Q_RES_BUY_COM != NULL)
  197.     {
  198.         Plr->BroadcastMessage("This area has already been purchased.");
  199.     }
  200.     if(PLR_COINAGE < (REQ_COINAGE))
  201.     {
  202.         Plr->BroadcastMessage("You don't have enough gold to purchase this Land.");
  203.     }
  204.     if(Q_RES_BUY_COM == NULL)
  205.     {
  206.         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());
  207.         CharacterDatabase.Execute("INSERT INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
  208.         Plr->BroadcastMessage("Gratz! Your Guild now Owns this area.");
  209.             }
  210.         return true;
  211.         }
  212. else if(Message == SET_G_HEARTH)
  213.     {
  214.     QueryResult * Q_RES_G_HEARTH_SET = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
  215.     uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
  216.    
  217.     if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
  218.     {
  219.         Plr->BroadcastMessage("You can't use this command in Instances!");
  220.         return true;
  221.     }
  222.     if(
  223.         Plr->CombatStatus.IsInCombat())
  224.     {
  225.         Plr->BroadcastMessage("You are in Combat!");
  226.         return true;
  227.     }
  228.     if(
  229.         Plr->getLevel() < 10)
  230.     {
  231.         Plr->BroadcastMessage("You must be level 10.");
  232.         return true;
  233.     }
  234.     if(
  235.         Plr->GetGuildId() == NULL)
  236.     {  
  237.         Plr->BroadcastMessage("You are not in a Guild.");
  238.         return true;
  239.     }
  240.     if(
  241.         Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
  242.     {
  243.         Plr->BroadcastMessage("You are not the Guild Master.");
  244.         return true;
  245.     }
  246.     if(Q_RES_G_HEARTH_SET == NULL)
  247.     {
  248.         Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
  249.     }
  250.     if(PLR_COINAGE < (PORT_REQ_COINAGE))
  251.     {
  252.         Plr->BroadcastMessage("You don't have enough gold to set your Guild Hearth.");
  253.     }
  254.     if(Q_RES_G_HEARTH_SET != NULL)
  255.     {
  256.         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());
  257.         Plr->BroadcastMessage("Your Guild Hearth Is Now Set.");
  258.             }
  259.         return true;
  260.         }
  261. else if(Message == SET_4_SALE)
  262.     {
  263.     QueryResult * Q_RES_SET_4_SALE = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
  264.     uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
  265.     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());
  266.     if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
  267.     {
  268.         Plr->BroadcastMessage("You can't use this command in Instances!");
  269.         return true;
  270.     }
  271.     if(
  272.         Plr->CombatStatus.IsInCombat())
  273.     {
  274.         Plr->BroadcastMessage("You are in Combat!");
  275.         return true;
  276.     }
  277.     if(
  278.         Plr->getLevel() < 10)
  279.     {
  280.         Plr->BroadcastMessage("You must be level 10.");
  281.         return true;
  282.     }
  283.     if(
  284.         Plr->GetGuildId() == NULL)
  285.     {  
  286.         Plr->BroadcastMessage("You are not in a Guild.");
  287.         return true;
  288.     }
  289.     if(
  290.         Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
  291.     {
  292.         Plr->BroadcastMessage("You are not the Guild Master.");
  293.         return true;
  294.     }
  295.     if(Q_RES_SET_4_SALE == NULL)
  296.     {
  297.         Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
  298.     }
  299.     if(Q_RES_SET_DATA == NULL)
  300.     {
  301.         Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
  302.     }
  303.     if(Q_RES_SET_4_SALE != NULL)
  304.     {
  305.         CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'FORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
  306.        
  307.         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.");
  308.             }
  309.     if(Q_RES_SET_DATA != NULL)
  310.     {
  311.         CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'FORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
  312.        
  313.         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.");
  314.             }
  315.         return true;
  316.         }
  317. else if(Message == SET_NOT_4_SALE)
  318.     {
  319.     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());
  320.     uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
  321.     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());
  322.     if(Plr->GetMapId() != 0 && Plr->GetMapId() != 1 && Plr->GetMapId() != 530 && Plr->GetMapId() != 571)
  323.     {
  324.         Plr->BroadcastMessage("You can't use this command in Instances!");
  325.         return true;
  326.     }
  327.     if(
  328.         Plr->CombatStatus.IsInCombat())
  329.     {
  330.         Plr->BroadcastMessage("You are in Combat!");
  331.         return true;
  332.     }
  333.     if(
  334.         Plr->getLevel() < 10)
  335.     {
  336.         Plr->BroadcastMessage("You must be level 10.");
  337.         return true;
  338.     }
  339.     if(
  340.         Plr->GetGuildId() == NULL)
  341.     {  
  342.         Plr->BroadcastMessage("You are not in a Guild.");
  343.         return true;
  344.     }
  345.     if(
  346.         Plr->GetGuild()->GetGuildLeader() != Plr->GetGUID())
  347.     {
  348.         Plr->BroadcastMessage("You are not the Guild Master.");
  349.         return true;
  350.     }
  351.     if(Q_RES_SET_NOT_4_SALE == NULL)
  352.     {
  353.         Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
  354.     }
  355.     if(Q_RES_SET_DATA2 == NULL)
  356.     {
  357.         Plr->BroadcastMessage("Your Guild does not Own Land in this Area.");
  358.     }
  359.     if(Q_RES_SET_NOT_4_SALE != NULL)
  360.     {
  361.         CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
  362.        
  363.         Plr->BroadcastMessage("Your Land is no longer for sale.");
  364.             }
  365.     if(Q_RES_SET_DATA2 != NULL)
  366.     {
  367.         CharacterDatabase.Execute("REPLACE INTO ab_land_data VALUES('%u', 'PASSIVE', 'NOTFORSALE', '0', '10K', '%u', '%u', '%u')", Plr->GetGuildId(), Plr->GetMapId(), Plr->GetAreaID(), Plr->GetZoneId());
  368.        
  369.         Plr->BroadcastMessage("Your Land is no longer for sale.");
  370.             }
  371.         return true;
  372.         }
  373.  
  374. else if(Message == ADD_FOOD)
  375.     {
  376.     AddItem(Plr, FOOD_ID, 1, true);// "1" is the amount of the item to give - True means we stack item
  377.     return true;
  378. }
  379. else if(Message == G_HEARTH)
  380.     {
  381.     QueryResult * Q_RES_LOWBIE = CharacterDatabase.Query("SELECT * FROM ab_guild_lands WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());
  382.     uint32 PLR_COINAGE = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
  383.     if(Q_RES_LOWBIE == NULL)
  384.     {
  385.         Plr->BroadcastMessage("Your Guild does not own any Land Nearby.");
  386.         Plr->Gossip_Complete();
  387.     return true;
  388.     }
  389.     if(Q_RES_LOWBIE->GetRowCount() > 1)
  390.     {
  391.         Plr->BroadcastMessage("Error 421 - Please Report this on the Forums - MYSQL Error - Too much Data to Input");
  392.         Plr->Gossip_Complete();
  393.     return true;
  394.     }
  395.    
  396.     if(PLR_COINAGE < (PORT_REQ_COINAGE))
  397.     {
  398.         Plr->BroadcastMessage("You don't have enough gold to teleport to your house.");
  399.         Plr->Gossip_Complete();
  400.     return true;
  401.     }
  402.         float x, y, z;
  403.         uint32 MapID;
  404.         Field * F_RES = Q_RES_LOWBIE->Fetch();
  405.         x = F_RES[1].GetFloat();
  406.         y = F_RES[2].GetFloat();
  407.         z = F_RES[3].GetFloat();
  408.         MapID = F_RES[4].GetUInt32();
  409.         Plr->EventTeleport(MapID, x, y, z);
  410.         }
  411.     return true;
  412. }
  413.  
  414.  
  415. void SetupGuild_Chat(ScriptMgr * mgr)
  416. {
  417.     mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &Guild_Chat);
  418. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement