Advertisement
Rochet2

Rasmus

Oct 2nd, 2012
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 65.26 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. #include "ObjectMgr.h"
  4. #include "Group.h"
  5.  
  6. enum eEnums
  7. {
  8.     GAMEOBJECT_SPAWN_LIMIT  =   20,
  9.     NPC_SPAWN_LIMIT    =    10,
  10.  
  11.     SAY_NOT_INTERESTED      = -1999922,
  12.     SAY_WRONG               = -1999923,
  13.     SAY_CORRECT             = -1999924,
  14.  
  15.     ITEM_1 =    183779,
  16.     ITEM_2 =    26990,
  17.     ITEM_3 =    184140,
  18.     ITEM_4 =    181087,
  19.     ITEM_5 =    1594,
  20.     ITEM_6 =    153584,
  21.     ITEM_7 =    176210,
  22.     ITEM_8 =    85004,
  23.     ITEM_9 =    184284,
  24.     ITEM_10 =   182070,
  25.     ITEM_11 =   170592,
  26.     ITEM_12 =   180376,
  27.     ITEM_13 =   180379,
  28.     ITEM_14 =   180377,
  29.  
  30.     NPC_1 =     481851,
  31.     NPC_2 =     18885,
  32.     NPC_3 =     18886,
  33.     NPC_4 =     50071,
  34.     NPC_5 =     50070,
  35.     NPC_6 =     50170,
  36.     NPC_7 =     50027,
  37.     NPC_8 =     26303,
  38.     NPC_9 =     50040,
  39.     NPC_10 =    985000,
  40.     NPC_11 =    32666,
  41.     NPC_12 =    50000,
  42.  
  43.     //PACKAGE 1 GOBJS and NPCs
  44.     P1_ITEM_1 = 179481,
  45.     P1_ITEM_2 = 179483,
  46.     P1_ITEM_3 = 183036,
  47.     P1_ITEM_4 = 183516,
  48.     P1_ITEM_5 = 184998,
  49.     P1_NPC_1 =     50073,
  50.     P1_NPC_2 =     1459,
  51.     P1_NPC_3 =     24181,
  52.     P1_NPC_4 =     985001,
  53.     P1_NPC_5 =     70015,
  54.     //PACKAGE 2 GOBJS and NPCs
  55.     P2_ITEM_1 = 182774,
  56.     P2_ITEM_2 = 186729,
  57.     P2_ITEM_3 = 187294,
  58.     P2_ITEM_4 = 164882,
  59.     P2_ITEM_5 = 180876,
  60.     P2_NPC_1 =     13,
  61.     P2_NPC_2 =     50014,
  62.     P2_NPC_3 =     66667,
  63.     P2_NPC_4 =     500256,
  64.     P2_NPC_5 =     50072,
  65.     P2_NPC_6 =     33357,
  66.     //PACKAGE 3 GOBJS and NPCs
  67.     P3_ITEM_1 = 185547,
  68.     P3_ITEM_2 = 181653,
  69.     P3_ITEM_3 = 1607,
  70.     P3_ITEM_4 = 186682,
  71.     P3_ITEM_5 = 181448,
  72.     P3_NPC_1 =     12198,
  73.     P3_NPC_2 =     20002,
  74.     P3_NPC_3 =     51181,
  75.     P3_NPC_4 =     20381,
  76.     P3_NPC_5 =     19859,
  77.     P3_NPC_6 =     49001,
  78.     //PACKAGE 4 GOBJS and NPCs
  79.     P4_ITEM_1 = 8007658,
  80.     P4_ITEM_2 = 8021000,
  81.     P4_ITEM_3 = 383771,
  82.     P4_ITEM_4 = 21680,
  83.     P4_ITEM_5 = 180334,
  84.     P4_NPC_1 =     190001,
  85.     P4_NPC_2 =     25141,
  86.     P4_NPC_3 =     69305,
  87.     P4_NPC_4 =     63305,
  88.     P4_NPC_5 =     66305,
  89.     P4_NPC_6 =     985402,
  90.     P4_NPC_7 =     985401
  91. };
  92.  
  93. #define ITEM_1_TEXT         "Chair"
  94. #define     ITEM_2_TEXT         "Table"
  95. #define ITEM_3_TEXT         "Mailbox"
  96. #define ITEM_4_TEXT         "Plant"
  97. #define ITEM_5_TEXT         "Bookshelf"
  98. #define ITEM_6_TEXT         "Campfire"
  99. #define ITEM_7_TEXT         "Tent"
  100. #define ITEM_8_TEXT         "Emeth the Ancient Portal"
  101. #define ITEM_9_TEXT         "Purple Torch"
  102. #define ITEM_10_TEXT        "Red Crystal"
  103. #define ITEM_11_TEXT        "Throne"
  104. #define ITEM_12_TEXT        "Berserk Buff"
  105. #define ITEM_13_TEXT        "Speed Buff"
  106. #define ITEM_14_TEXT        "Heal Buff"
  107.  
  108. #define NPC_1_TEXT          "Teleporter"
  109. #define     NPC_2_TEXT          "Arena Vendor"
  110. #define NPC_3_TEXT      "Invincible Gear Vendor"
  111. #define NPC_4_TEXT      "Donor Vendor"
  112. #define NPC_5_TEXT      "Vote Vendor"
  113. #define NPC_6_TEXT      "Refund Vendor"
  114. #define NPC_7_TEXT      "Honor Vendor"
  115. #define NPC_8_TEXT      "Custom Gems"
  116. #define NPC_9_TEXT      "Event Vendor"
  117. #define NPC_10_TEXT         "God of PvP"
  118. #define NPC_11_TEXT         "Training Dummy"
  119. #define NPC_12_TEXT         "Battle Maiden"
  120.  
  121.  
  122. //PACKAGE 1 GOBJs and NPCs
  123. #define P1_ITEM_1_TEXT          "Alliance Banner"
  124. #define     P1_ITEM_2_TEXT          "Horde Banner"
  125. #define P1_ITEM_3_TEXT      "Rune Aura"
  126. #define P1_ITEM_4_TEXT      "Purple Aura"
  127. #define P1_ITEM_5_TEXT      "Flying Platform"
  128. #define P1_NPC_1_TEXT       "Lord Tirion"
  129. #define     P1_NPC_2_TEXT       "Deluxe Voter"
  130. #define P1_NPC_3_TEXT       "Voters Gear"
  131. #define P1_NPC_4_TEXT       "Master of Illusions"
  132. #define P1_NPC_5_TEXT       "Title Master"
  133. //PACKAGE 2 GOBJs and NPCs
  134. #define P2_ITEM_1_TEXT          "Golden Bench"
  135. #define     P2_ITEM_2_TEXT          "Bush"
  136. #define P2_ITEM_3_TEXT      "Guild Vault"
  137. #define P2_ITEM_4_TEXT      "Cleansed Songflower"
  138. #define P2_ITEM_5_TEXT      "Elune's Blessing"
  139. #define P2_NPC_1_TEXT       "Beastermaster Arogon"
  140. #define     P2_NPC_2_TEXT       "Sylvannas"
  141. #define P2_NPC_3_TEXT       "Sharrow"
  142. #define P2_NPC_4_TEXT       "Totems and More"
  143. #define P2_NPC_5_TEXT       "Token Converter"
  144. #define P2_NPC_6_TEXT           "Spectral Tiger"
  145. //PACKAGE 3 GOBJs and NPCs
  146. #define P3_ITEM_1_TEXT          "Owl Statue"
  147. #define     P3_ITEM_2_TEXT          "Man Statue"
  148. #define P3_ITEM_3_TEXT      "Little Flame"
  149. #define P3_ITEM_4_TEXT      "Beer Tent"
  150. #define P3_ITEM_5_TEXT      "Signalling Gem Aura"
  151. #define P3_NPC_1_TEXT       "Arathi Basin"
  152. #define     P3_NPC_2_TEXT       "Warsong Gulch"
  153. #define P3_NPC_3_TEXT       "Real Steel"
  154. #define P3_NPC_4_TEXT       "Eye of the Storm"
  155. #define P3_NPC_5_TEXT       "Arena Battlemaster"
  156. #define P3_NPC_6_TEXT       "Arena Organizer"
  157. //PACKAGE 4 GOBJs and NPCs
  158. #define P4_ITEM_1_TEXT          "Arena Earth Rune"
  159. #define     P4_ITEM_2_TEXT          "Gambling Records"
  160. #define P4_ITEM_3_TEXT      "Gambling Area"
  161. #define P4_ITEM_4_TEXT      "Duel Flag"
  162. #define P4_ITEM_5_TEXT      "Stormwind Rug"
  163. #define P4_NPC_1_TEXT       "Transmogrification"
  164. #define     P4_NPC_2_TEXT       "Commander Steele"
  165. #define P4_NPC_3_TEXT       "Irelia"
  166. #define P4_NPC_4_TEXT       "Bounty Hunter"
  167. #define P4_NPC_5_TEXT       "Bounty Bear"
  168. #define P4_NPC_6_TEXT       "Gladiators Gear"
  169. #define P4_NPC_7_TEXT           "Gladiators Gear"
  170.  
  171. //gomj cmds
  172. bool spawnGoObject(Player *pPlayer, uint32 itemID);
  173. int getSpawnCount(uint32 plrName);
  174. int getSpawnCountBonus(uint32 plrName);
  175. bool getClosestObjectAndDelete(Player *pPlayer);
  176. bool isPossibleGo(uint32 gobjID);
  177. //char cmds
  178. bool isCharacterInLand(Player *pPlayer);
  179. bool isCharacterLandOwner(Player *pPlayer);
  180. bool hasPackage1(uint32 AccID, uint32 package);
  181. bool summonFriend(Player *pPlayer);
  182. bool teleportToLand(Player *pPlayer);
  183. //npc cmds
  184. bool isPossibleNpc(uint32 npcId);
  185. int getNPCCount(uint32 plrName);
  186. int getNPCCountBonus(uint32 plrName);
  187. bool deleteNPC(Player *pPlayer);
  188. bool spawnNPC(Player *pPlayer, uint32 npcID);
  189. bool isTargetInLand(Player *plrTarget, uint32 ownerName);
  190.  
  191. float top_x = 0;
  192. float bottom_x;
  193. float left_y = 0;
  194. float right_y;
  195. int mapid;
  196. bool ownsLand = false;
  197.  
  198. class npc_player_house : public ItemScript
  199. {
  200. public:
  201.     npc_player_house() : ItemScript("npc_player_house") { }
  202.  
  203.     bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
  204.     {
  205.         uint32 AccID = player->GetGUIDLow();
  206.         player->PlayerTalkClass->ClearMenus();
  207.         if(player->isInCombat()){
  208.             ChatHandler(player->GetSession()).PSendSysMessage("You can not use this item while in combat!");
  209.             return false;
  210.         }
  211.  
  212.         if(isCharacterLandOwner(player)){
  213.             if(isCharacterInLand(player)){
  214.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn GameObjects", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+500);
  215.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn NPCs", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+501);
  216.                 if(hasPackage1(AccID, 1))
  217.                     player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #1", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+502);
  218.                 if(hasPackage1(AccID, 2))
  219.                     player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #2", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+503);
  220.                 if(hasPackage1(AccID, 3))
  221.                     player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #3", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  222.                 if(hasPackage1(AccID, 4))
  223.                     player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #4", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+505);
  224.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Delete closest GameObject", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  225.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Delete NPC", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6);
  226.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Summon Friend!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
  227.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Summon Party/Raid!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7);
  228.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Scale NPC.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8);
  229.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE,"Kick Intruder!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5);
  230.             } else {
  231.                 QueryResult result = CharacterDatabase.PQuery("SELECT zone_name FROM player_house_taken WHERE player_guid=%u", player->GetGUIDLow());  
  232.                 uint32 house_count = 1;
  233.                 if(result)
  234.                 {
  235.                     do{
  236.                         Field *fields = result->Fetch();
  237.                         std::string zone_name = fields[0].GetString();
  238.                         if(zone_name == "")
  239.                             zone_name = "First House";
  240.                         player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport to " + zone_name, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+800+house_count);
  241.                         house_count++;
  242.                     } while (result->NextRow());
  243.                 }
  244.             }
  245.         } else {
  246.             ChatHandler(player->GetSession()).PSendSysMessage("You do not own any land!");
  247.             return false;
  248.         }
  249.         player->PlayerTalkClass->SendGossipMenu(1, item->GetGUID());
  250.         return true;
  251.     }
  252.  
  253.     bool OnGossipSelect(Player* player, Item* item, uint32 sender , uint32 action)
  254.     {
  255.         uint32 AccID = player->GetGUIDLow();
  256.         switch(action){
  257.             //GOBJS
  258.         case GOSSIP_ACTION_INFO_DEF +500:
  259.             player->PlayerTalkClass->ClearMenus();
  260.  
  261.             char buffer [50];
  262.             char buffer2 [50];
  263.             sprintf (buffer, "You can spawn %i more items.", GAMEOBJECT_SPAWN_LIMIT + getSpawnCountBonus(player->GetGUIDLow()) - getSpawnCount(player->GetGUIDLow()));
  264.  
  265.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+100);
  266.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+110);
  267.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+120);
  268.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+130);
  269.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+140);
  270.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_6_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+150);
  271.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_7_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+160);
  272.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_8_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+170);
  273.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_9_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+180);
  274.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_10_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+190);
  275.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_11_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+255);
  276.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_12_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+256);
  277.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_13_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+257);
  278.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, ITEM_14_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+258);
  279.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+500);
  280.             player->PlayerTalkClass->SendGossipMenu(9000, item->GetGUID());
  281.             break;
  282.  
  283.             //NPC's
  284.         case GOSSIP_ACTION_INFO_DEF +501:
  285.             player->PlayerTalkClass->ClearMenus();
  286.  
  287.             sprintf (buffer, "You can spawn %i more nps.", NPC_SPAWN_LIMIT + getNPCCountBonus(player->GetGUIDLow()) - getNPCCount(player->GetGUIDLow()));
  288.  
  289.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+200);
  290.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+210);
  291.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+220);
  292.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+230);
  293.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+240);
  294.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_6_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+250);
  295.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_7_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+260);
  296.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_8_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+270);
  297.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_9_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+280);
  298.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_10_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+290);
  299.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_11_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+291);
  300.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, NPC_12_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+292);
  301.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+501);
  302.             player->PlayerTalkClass->SendGossipMenu(9000, item->GetGUID());
  303.             break;
  304.             //spawn package 1
  305.         case GOSSIP_ACTION_INFO_DEF +502:
  306.             player->PlayerTalkClass->ClearMenus();
  307.  
  308.             sprintf (buffer, "You can spawn %i more nps.", NPC_SPAWN_LIMIT + getNPCCountBonus(player->GetGUIDLow()) - getNPCCount(player->GetGUIDLow()));
  309.             sprintf (buffer2, "You can spawn %i more items.", GAMEOBJECT_SPAWN_LIMIT + getSpawnCountBonus(player->GetGUIDLow()) - getSpawnCount(player->GetGUIDLow()));
  310.  
  311.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- OBJECTS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+502);
  312.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_ITEM_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+300);
  313.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_ITEM_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+310);
  314.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_ITEM_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+320);
  315.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_ITEM_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+330);
  316.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_ITEM_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+340);
  317.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_ITEM_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+340);
  318.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- NPCS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+502);
  319.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_NPC_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+350);
  320.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_NPC_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+360);
  321.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_NPC_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+370);
  322.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_NPC_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+380);
  323.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P1_NPC_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+390);
  324.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+502);
  325.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+502);
  326.             player->PlayerTalkClass->SendGossipMenu(9000, item->GetGUID());
  327.             break;
  328.             //spawn package 2
  329.         case GOSSIP_ACTION_INFO_DEF +503:
  330.             player->PlayerTalkClass->ClearMenus();
  331.  
  332.             sprintf (buffer, "You can spawn %i more nps.", NPC_SPAWN_LIMIT + getNPCCountBonus(player->GetGUIDLow()) - getNPCCount(player->GetGUIDLow()));
  333.             sprintf (buffer2, "You can spawn %i more items.", GAMEOBJECT_SPAWN_LIMIT + getSpawnCountBonus(player->GetGUIDLow()) - getSpawnCount(player->GetGUIDLow()));
  334.  
  335.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- OBJECTS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+503);
  336.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_ITEM_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+400);
  337.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_ITEM_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+410);
  338.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_ITEM_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+420);
  339.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_ITEM_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+430);
  340.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_ITEM_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+440);
  341.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- NPCS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+503);
  342.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_NPC_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+450);
  343.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_NPC_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+460);
  344.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_NPC_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+470);
  345.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_NPC_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+480);
  346.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_NPC_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+490);
  347.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P2_NPC_6_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1500);
  348.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+503);
  349.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+503);
  350.             player->PlayerTalkClass->SendGossipMenu(9000, item->GetGUID());
  351.             break;
  352.             //spawn package 3
  353.         case GOSSIP_ACTION_INFO_DEF +504:
  354.             player->PlayerTalkClass->ClearMenus();
  355.  
  356.             sprintf (buffer, "You can spawn %i more nps.", NPC_SPAWN_LIMIT + getNPCCountBonus(player->GetGUIDLow()) - getNPCCount(player->GetGUIDLow()));
  357.             sprintf (buffer2, "You can spawn %i more items.", GAMEOBJECT_SPAWN_LIMIT + getSpawnCountBonus(player->GetGUIDLow()) - getSpawnCount(player->GetGUIDLow()));
  358.  
  359.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- OBJECTS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  360.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_ITEM_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+600);
  361.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_ITEM_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+610);
  362.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_ITEM_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+620);
  363.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_ITEM_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+630);
  364.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_ITEM_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+640);
  365.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- NPCS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  366.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_NPC_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+650);
  367.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_NPC_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+660);
  368.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_NPC_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+670);
  369.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_NPC_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+680);
  370.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_NPC_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+690);
  371.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P3_NPC_6_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+700);
  372.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  373.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  374.             player->PlayerTalkClass->SendGossipMenu(9000, item->GetGUID());
  375.             break;
  376.             //spawn package 4
  377.         case GOSSIP_ACTION_INFO_DEF +505:
  378.             player->PlayerTalkClass->ClearMenus();
  379.  
  380.             sprintf (buffer, "You can spawn %i more nps.", NPC_SPAWN_LIMIT + getNPCCountBonus(player->GetGUIDLow()) - getNPCCount(player->GetGUIDLow()));
  381.             sprintf (buffer2, "You can spawn %i more items.", GAMEOBJECT_SPAWN_LIMIT + getSpawnCountBonus(player->GetGUIDLow()) - getSpawnCount(player->GetGUIDLow()));
  382.  
  383.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- OBJECTS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+505);
  384.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_ITEM_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+910);
  385.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_ITEM_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+920);
  386.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_ITEM_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+930);
  387.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_ITEM_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+940);
  388.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_ITEM_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+950);
  389.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "-- NPCS --", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+505);
  390.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_1_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+960);
  391.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_2_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+970);
  392.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_3_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+980);
  393.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_4_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+990);
  394.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_5_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1000);
  395.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_6_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1010);
  396.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, P4_NPC_7_TEXT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1020);
  397.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+505);
  398.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, buffer2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+505);
  399.             player->PlayerTalkClass->SendGossipMenu(9000, item->GetGUID());
  400.             break;
  401.             //main menu
  402.         case GOSSIP_ACTION_INFO_DEF+999:
  403.             player->PlayerTalkClass->ClearMenus();
  404.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn GameObjects", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+500);
  405.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn NPCs", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+501);
  406.             if(hasPackage1(AccID, 1))
  407.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #1", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+502);
  408.             if(hasPackage1(AccID, 2))
  409.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #2", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+503);
  410.             if(hasPackage1(AccID, 3))
  411.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #3", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  412.             if(hasPackage1(AccID, 4))
  413.                 player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Spawn Package #4", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+504);
  414.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Delete closest GameObject", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  415.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "Delete NPC", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6);
  416.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Summon Friend!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
  417.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Summon Party/Raid!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7);
  418.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE,"Kick Intruder!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5);
  419.             player->PlayerTalkClass->SendGossipMenu(1, item->GetGUID());
  420.             break;
  421.  
  422.             //delete gobj
  423.         case GOSSIP_ACTION_INFO_DEF +2: getClosestObjectAndDelete(player); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+999); break;
  424.             //delete NPC
  425.         case GOSSIP_ACTION_INFO_DEF +6: deleteNPC(player); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+999); break;
  426.  
  427.             //teleport to house
  428.         case GOSSIP_ACTION_INFO_DEF +3:  
  429.             player->CLOSE_GOSSIP_MENU();
  430.             teleportToLand(player);
  431.             break;
  432.             //summon friend
  433.         case GOSSIP_ACTION_INFO_DEF +4: summonFriend(player); player->CLOSE_GOSSIP_MENU(); break;
  434.             //kickplr
  435.         case GOSSIP_ACTION_INFO_DEF +7:
  436.             {
  437.                 player->PlayerTalkClass->SendCloseGossip();
  438.                 Group* grp = player->GetGroup();
  439.                 if(!grp)
  440.                     break;
  441.                 GroupReference* grpRef = grp->GetFirstMember();
  442.                 if(!grpRef)
  443.                     break;
  444.  
  445.                 for (grpRef; grpRef != NULL; grpRef = grpRef->next())
  446.                 {
  447.                     Player* groupMember = grpRef->getSource();
  448.                     ChatHandler(player->GetSession()).PSendSysMessage("Sending summon request to...");
  449.                     if(!groupMember)
  450.                         continue;      
  451.                     else
  452.                         break;
  453.  
  454.                     if(groupMember == player)
  455.                         break;
  456.  
  457.                     player->SetSelection(groupMember->GetGUID());
  458.                     player->CastSpell(groupMember, 7720, true);
  459.                     ChatHandler(player->GetSession()).PSendSysMessage("%s", groupMember->GetName());
  460.                 }
  461.             }
  462.             break;
  463.         case GOSSIP_ACTION_INFO_DEF +8:
  464.             player->PlayerTalkClass->ClearMenus();
  465.             player->ADD_GOSSIP_ITEM( 10, "Set Scale 0.25", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9);
  466.             player->ADD_GOSSIP_ITEM( 10, "Set Scale 0.50", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10);
  467.             player->ADD_GOSSIP_ITEM( 10, "Set Scale 1.00", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+11);
  468.             player->ADD_GOSSIP_ITEM( 10, "Set Scale 1.50", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+12);
  469.             player->ADD_GOSSIP_ITEM( 10, "Set Scale 1.75", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+13);
  470.             player->PlayerTalkClass->SendGossipMenu(1, item->GetGUID());
  471.             break;
  472.         case GOSSIP_ACTION_INFO_DEF +9:
  473.             {
  474.                 if(isCharacterInLand(player)){
  475.                     Creature* target = ChatHandler(player).getSelectedCreature();
  476.                     if (!target)
  477.                     {
  478.                         ChatHandler(player->GetSession()).PSendSysMessage("Please select a valid creature within your land area.");
  479.                         player->PlayerTalkClass->SendCloseGossip(); // Rochet's comment: Why close gossip? Why not return to the menu, so its easier to try again?
  480.                         return false;
  481.                     }
  482.  
  483.                     target->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.25);
  484.                     target->SaveToDB();
  485.                     player->PlayerTalkClass->SendCloseGossip();
  486.  
  487.                     return true;
  488.                 } else {
  489.                     teleportToLand(player);
  490.                 }
  491.             } break;
  492.         case GOSSIP_ACTION_INFO_DEF +10:
  493.             {
  494.                 if(isCharacterInLand(player)){
  495.                     Creature* target = ChatHandler(player).getSelectedCreature();
  496.                     if (!target)
  497.                     {
  498.                         ChatHandler(player->GetSession()).PSendSysMessage("Please select a valid creature within your land area.");
  499.                         player->PlayerTalkClass->SendCloseGossip();
  500.                         return false;
  501.                     }
  502.  
  503.                     target->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.50);
  504.                     target->SaveToDB();
  505.                     player->PlayerTalkClass->SendCloseGossip();
  506.  
  507.                     return true;
  508.                 } else {
  509.                     teleportToLand(player);
  510.                 }
  511.             } break;
  512.         case GOSSIP_ACTION_INFO_DEF +11:
  513.             {
  514.                 if(isCharacterInLand(player)){
  515.                     Creature* target = ChatHandler(player).getSelectedCreature();
  516.                     if (!target)
  517.                     {
  518.                         ChatHandler(player->GetSession()).PSendSysMessage("Please select a valid creature within your land area.");
  519.                         player->PlayerTalkClass->SendCloseGossip();
  520.                         return false;
  521.                     }
  522.  
  523.                     target->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.00);
  524.                     target->SaveToDB();
  525.                     player->PlayerTalkClass->SendCloseGossip();
  526.  
  527.                     return true;
  528.                 } else {
  529.                     teleportToLand(player);
  530.                 }
  531.             } break;
  532.         case GOSSIP_ACTION_INFO_DEF +12:
  533.             {
  534.                 if(isCharacterInLand(player)){
  535.                     Creature* target = ChatHandler(player).getSelectedCreature();
  536.                     if (!target)
  537.                     {
  538.                         ChatHandler(player->GetSession()).PSendSysMessage("Please select a valid creature within your land area.");
  539.                         player->PlayerTalkClass->SendCloseGossip();
  540.                         return false;
  541.                     }
  542.  
  543.                     target->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.50);
  544.                     target->SaveToDB();
  545.                     player->PlayerTalkClass->SendCloseGossip();
  546.  
  547.                     return true;
  548.                 } else {
  549.                     teleportToLand(player);
  550.                 }
  551.             } break;
  552.         case GOSSIP_ACTION_INFO_DEF +13:
  553.             {
  554.                 if(isCharacterInLand(player)){
  555.                     Unit* target = player->getSelectedUnit();
  556.                     if (!target || !target->GetTypeId() == TYPEID_UNIT || !isPossibleNpc(target->GetEntry()))
  557.                     {
  558.                         ChatHandler(player->GetSession()).PSendSysMessage("Please select a valid creature within your land area.");
  559.                         player->PlayerTalkClass->SendCloseGossip();
  560.                         return false;
  561.                     }
  562.  
  563.                     target->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.75);
  564.                     target->SaveToDB();
  565.                     player->PlayerTalkClass->SendCloseGossip();
  566.  
  567.                     return true;
  568.                 } else {
  569.                     teleportToLand(player);
  570.                 }
  571.             } break;
  572.             //kickplr
  573.         case GOSSIP_ACTION_INFO_DEF +5:  
  574.             {
  575.                 player->PlayerTalkClass->SendCloseGossip();
  576.                 Player* selPlr = player->GetSelectedPlayer();
  577.                 if(!selPlr)
  578.                     break;
  579.                 if(selPlr != player){
  580.                     ChatHandler(selPlr->GetSession()).PSendSysMessage("You have been kicked off %s land!", player->GetName());
  581.                     isTargetInLand(selPlr, player->GetGUIDLow());
  582.                 }
  583.             }
  584.             break;
  585.  
  586.             //ADD ITEMS
  587.         case GOSSIP_ACTION_INFO_DEF +100: spawnGoObject(player, ITEM_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  588.         case GOSSIP_ACTION_INFO_DEF +110: spawnGoObject(player, ITEM_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  589.         case GOSSIP_ACTION_INFO_DEF +120: spawnGoObject(player, ITEM_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  590.         case GOSSIP_ACTION_INFO_DEF +130: spawnGoObject(player, ITEM_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  591.         case GOSSIP_ACTION_INFO_DEF +140: spawnGoObject(player, ITEM_5) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  592.         case GOSSIP_ACTION_INFO_DEF +150: spawnGoObject(player, ITEM_6) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  593.         case GOSSIP_ACTION_INFO_DEF +160: spawnGoObject(player, ITEM_7) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  594.         case GOSSIP_ACTION_INFO_DEF +170: spawnGoObject(player, ITEM_8) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  595.         case GOSSIP_ACTION_INFO_DEF +180: spawnGoObject(player, ITEM_9) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  596.         case GOSSIP_ACTION_INFO_DEF +190: spawnGoObject(player, ITEM_10); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  597.         case GOSSIP_ACTION_INFO_DEF +255: spawnGoObject(player, ITEM_11); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  598.         case GOSSIP_ACTION_INFO_DEF +256: spawnGoObject(player, ITEM_12); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  599.         case GOSSIP_ACTION_INFO_DEF +257: spawnGoObject(player, ITEM_13); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  600.         case GOSSIP_ACTION_INFO_DEF +258: spawnGoObject(player, ITEM_14); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+500); break;
  601.             //ADD NPCS
  602.         case GOSSIP_ACTION_INFO_DEF +200: spawnNPC(player, NPC_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  603.         case GOSSIP_ACTION_INFO_DEF +210: spawnNPC(player, NPC_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  604.         case GOSSIP_ACTION_INFO_DEF +220: spawnNPC(player, NPC_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  605.         case GOSSIP_ACTION_INFO_DEF +230: spawnNPC(player, NPC_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  606.         case GOSSIP_ACTION_INFO_DEF +240: spawnNPC(player, NPC_5) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  607.         case GOSSIP_ACTION_INFO_DEF +250: spawnNPC(player, NPC_6) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  608.         case GOSSIP_ACTION_INFO_DEF +260: spawnNPC(player, NPC_7) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  609.         case GOSSIP_ACTION_INFO_DEF +270: spawnNPC(player, NPC_8) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  610.         case GOSSIP_ACTION_INFO_DEF +280: spawnNPC(player, NPC_9) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  611.         case GOSSIP_ACTION_INFO_DEF +290: spawnNPC(player, NPC_10); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  612.         case GOSSIP_ACTION_INFO_DEF +291: spawnNPC(player, NPC_11); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  613.         case GOSSIP_ACTION_INFO_DEF +292: spawnNPC(player, NPC_12); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+501); break;
  614.  
  615.             //package 1
  616.         case GOSSIP_ACTION_INFO_DEF +300: spawnGoObject(player, P1_ITEM_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  617.         case GOSSIP_ACTION_INFO_DEF +310: spawnGoObject(player, P1_ITEM_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  618.         case GOSSIP_ACTION_INFO_DEF +320: spawnGoObject(player, P1_ITEM_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  619.         case GOSSIP_ACTION_INFO_DEF +330: spawnGoObject(player, P1_ITEM_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  620.         case GOSSIP_ACTION_INFO_DEF +340: spawnGoObject(player, P1_ITEM_5) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  621.         case GOSSIP_ACTION_INFO_DEF +350: spawnNPC(player, P1_NPC_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  622.         case GOSSIP_ACTION_INFO_DEF +360: spawnNPC(player, P1_NPC_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  623.         case GOSSIP_ACTION_INFO_DEF +370: spawnNPC(player, P1_NPC_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  624.         case GOSSIP_ACTION_INFO_DEF +380: spawnNPC(player, P1_NPC_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  625.         case GOSSIP_ACTION_INFO_DEF +390: spawnNPC(player, P1_NPC_5); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+502); break;
  626.  
  627.             //package 2
  628.         case GOSSIP_ACTION_INFO_DEF +400: spawnGoObject(player, P2_ITEM_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  629.         case GOSSIP_ACTION_INFO_DEF +410: spawnGoObject(player, P2_ITEM_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  630.         case GOSSIP_ACTION_INFO_DEF +420: spawnGoObject(player, P2_ITEM_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  631.         case GOSSIP_ACTION_INFO_DEF +430: spawnGoObject(player, P2_ITEM_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  632.         case GOSSIP_ACTION_INFO_DEF +440: spawnGoObject(player, P2_ITEM_5) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  633.         case GOSSIP_ACTION_INFO_DEF +450: spawnNPC(player, P2_NPC_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  634.         case GOSSIP_ACTION_INFO_DEF +460: spawnNPC(player, P2_NPC_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  635.         case GOSSIP_ACTION_INFO_DEF +470: spawnNPC(player, P2_NPC_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  636.         case GOSSIP_ACTION_INFO_DEF +480: spawnNPC(player, P2_NPC_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  637.         case GOSSIP_ACTION_INFO_DEF +490: spawnNPC(player, P2_NPC_5); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  638.         case GOSSIP_ACTION_INFO_DEF +1500: spawnNPC(player, P2_NPC_6); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+503); break;
  639.  
  640.             //package 3
  641.         case GOSSIP_ACTION_INFO_DEF +600: spawnGoObject(player, P3_ITEM_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  642.         case GOSSIP_ACTION_INFO_DEF +610: spawnGoObject(player, P3_ITEM_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  643.         case GOSSIP_ACTION_INFO_DEF +620: spawnGoObject(player, P3_ITEM_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  644.         case GOSSIP_ACTION_INFO_DEF +630: spawnGoObject(player, P3_ITEM_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  645.         case GOSSIP_ACTION_INFO_DEF +640: spawnGoObject(player, P3_ITEM_5) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  646.         case GOSSIP_ACTION_INFO_DEF +650: spawnNPC(player, P3_NPC_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  647.         case GOSSIP_ACTION_INFO_DEF +660: spawnNPC(player, P3_NPC_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  648.         case GOSSIP_ACTION_INFO_DEF +670: spawnNPC(player, P3_NPC_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  649.         case GOSSIP_ACTION_INFO_DEF +680: spawnNPC(player, P3_NPC_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  650.         case GOSSIP_ACTION_INFO_DEF +690: spawnNPC(player, P3_NPC_5); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  651.         case GOSSIP_ACTION_INFO_DEF +700: spawnNPC(player, P3_NPC_6); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+504); break;
  652.  
  653.             //package 4
  654.         case GOSSIP_ACTION_INFO_DEF +910: spawnGoObject(player, P4_ITEM_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  655.         case GOSSIP_ACTION_INFO_DEF +920: spawnGoObject(player, P4_ITEM_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  656.         case GOSSIP_ACTION_INFO_DEF +930: spawnGoObject(player, P4_ITEM_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  657.         case GOSSIP_ACTION_INFO_DEF +940: spawnGoObject(player, P4_ITEM_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  658.         case GOSSIP_ACTION_INFO_DEF +950: spawnGoObject(player, P4_ITEM_5) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  659.         case GOSSIP_ACTION_INFO_DEF +960: spawnNPC(player, P4_NPC_1) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  660.         case GOSSIP_ACTION_INFO_DEF +970: spawnNPC(player, P4_NPC_2) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  661.         case GOSSIP_ACTION_INFO_DEF +980: spawnNPC(player, P4_NPC_3) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  662.         case GOSSIP_ACTION_INFO_DEF +990: spawnNPC(player, P4_NPC_4) ; OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  663.         case GOSSIP_ACTION_INFO_DEF +1000: spawnNPC(player, P4_NPC_5); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  664.         case GOSSIP_ACTION_INFO_DEF +1010: spawnNPC(player, P4_NPC_6); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  665.         case GOSSIP_ACTION_INFO_DEF +1020: spawnNPC(player, P4_NPC_7); OnGossipSelect(player, item, item->GetGUID(), GOSSIP_ACTION_INFO_DEF+505); break;
  666.  
  667.         case GOSSIP_ACTION_INFO_DEF +801: teleportToHouse(player, 1); break;
  668.         case GOSSIP_ACTION_INFO_DEF +802: teleportToHouse(player, 2); break;
  669.         case GOSSIP_ACTION_INFO_DEF +803: teleportToHouse(player, 3); break;
  670.         case GOSSIP_ACTION_INFO_DEF +804: teleportToHouse(player, 4); break;
  671.         case GOSSIP_ACTION_INFO_DEF +805: teleportToHouse(player, 5); break;
  672.         case GOSSIP_ACTION_INFO_DEF +806: teleportToHouse(player, 6); break;
  673.         case GOSSIP_ACTION_INFO_DEF +807: teleportToHouse(player, 7); break;
  674.         case GOSSIP_ACTION_INFO_DEF +808: teleportToHouse(player, 8); break;
  675.         case GOSSIP_ACTION_INFO_DEF +809: teleportToHouse(player, 9); break;
  676.         case GOSSIP_ACTION_INFO_DEF +810: teleportToHouse(player, 10); break;
  677.         }
  678.         return true;
  679.     }
  680.  
  681.     bool teleportToHouse(Player* player, uint32 selection)
  682.     {
  683.         if(player->isInCombat() || player->GetMap()->IsBattlegroundOrArena() || player->GetMap()->IsDungeon()){ return false; }
  684.  
  685.         QueryResult result = CharacterDatabase.PQuery("SELECT map_id, spawn_x, spawn_y, spawn_z, spawn_o FROM player_house_taken WHERE player_guid=%u", player->GetGUIDLow()); 
  686.         uint32 house_count = 1;
  687.         do{
  688.             if(house_count == selection)
  689.             {
  690.                 Field *fields = result->Fetch();
  691.                 player->TeleportTo(fields[0].GetUInt32(),fields[1].GetFloat(),fields[2].GetFloat(),fields[3].GetFloat(),fields[4].GetFloat());
  692.                 ChatHandler(player->GetSession()).SendSysMessage("Welcome Home!");
  693.                 return true;
  694.             }
  695.             house_count++;
  696.         } while (result->NextRow());
  697.  
  698.         return false;
  699.     }
  700.  
  701. };
  702. bool summonFriend(Player *pPlayer)
  703. {
  704.     Player *plrFriend = pPlayer->GetSelectedPlayer();
  705.     if(plrFriend){
  706.         if(plrFriend->isInCombat()){ ChatHandler(pPlayer->GetSession()).PSendSysMessage("Your friend is in combat!"); return false;}
  707.         if(plrFriend->GetMap()->IsBattlegroundOrArena()){ ChatHandler(pPlayer->GetSession()).PSendSysMessage("Your friend is in a battleground!"); return false;}
  708.         if(plrFriend->GetMap()->IsDungeon()){ ChatHandler(pPlayer->GetSession()).PSendSysMessage("Your friend is in a dungeon!"); return false;}
  709.         if(plrFriend->IsBeingTeleported()) { return false; };
  710.         if(plrFriend->isDead()) { return false; };
  711.  
  712.         if(pPlayer->IsInPartyWith(plrFriend) || pPlayer->IsInRaidWith(plrFriend)){
  713.             pPlayer->CastSpell(plrFriend, 7720, true);
  714.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("Summon request sent!");
  715.             return true;
  716.         } else {
  717.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("You must invite this person to your party first!");
  718.         }
  719.     } else {
  720.         try{
  721.             pPlayer->CastSpell(plrFriend, 7720, true);
  722.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("Summon request sent!");
  723.         } catch(...) {
  724.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("You must target the person you want to summon! (Invite to party/raid)");
  725.         }
  726.  
  727.     }
  728.     return false;
  729. }
  730.  
  731. bool isCharacterInLand(Player *pPlayer)
  732. {
  733.     float playerx = pPlayer->GetPositionX();
  734.     float playery = pPlayer->GetPositionY();
  735.     uint32 mapid_multi = pPlayer->GetMap()->GetId();
  736.  
  737.     QueryResult result = CharacterDatabase.PQuery("SELECT map_id, bottom_x, top_x, left_y, right_y FROM player_house_taken WHERE player_guid=%u AND map_id=%u", pPlayer->GetGUID(), mapid_multi);  
  738.     if(!result)
  739.         return false;
  740.  
  741.     do{
  742.         Field *fields = result->Fetch();
  743.         mapid = fields[0].GetInt32();
  744.         bottom_x = fields[1].GetFloat();
  745.         top_x = fields[2].GetFloat();
  746.         left_y = fields[3].GetFloat();
  747.         right_y = fields[4].GetFloat();
  748.  
  749.         if(playerx < bottom_x && playerx > top_x && playery < left_y && playery > right_y) { ownsLand = true; return true; }
  750.     } while (result->NextRow());
  751.  
  752.     return false;
  753. }
  754.  
  755. bool isTargetInLand(Player *plrTarget, uint32 ownerName)
  756. {
  757.     if(plrTarget)
  758.     {
  759.         float playerx = plrTarget->GetPositionX();
  760.         float playery = plrTarget->GetPositionY();
  761.         uint32 mapid_multi = plrTarget->GetMap()->GetId();
  762.  
  763.         QueryResult result = CharacterDatabase.PQuery("SELECT map_id, bottom_x, top_x, left_y, right_y FROM player_house_taken WHERE player_guid=%u AND map_id=%u", ownerName, mapid_multi);   
  764.         do{
  765.             Field *fields = result->Fetch();
  766.             mapid = fields[0].GetInt32();
  767.             bottom_x = fields[1].GetFloat();
  768.             top_x = fields[2].GetFloat();
  769.             left_y = fields[3].GetFloat();
  770.             right_y = fields[4].GetFloat();
  771.  
  772.             if(playerx < bottom_x && playerx > top_x && playery < left_y && playery > right_y)
  773.             {
  774.                 if(plrTarget)
  775.                 {
  776.                     plrTarget->TeleportTo(534, 5541.770020f, -3783.469971f, 1594.910034f, 2.883010f);
  777.                 }
  778.                 return true;
  779.             } else {
  780.                 ChatHandler(plrTarget->GetSession()).PSendSysMessage("%s is not located on your land!", plrTarget->GetName());
  781.             }
  782.  
  783.         } while (result->NextRow());
  784.     }
  785.     return false;
  786. }
  787.  
  788. bool isCharacterLandOwner(Player *pPlayer)
  789. {
  790.     QueryResult result;
  791.     if(!ownsLand){
  792.         result = CharacterDatabase.PQuery("SELECT * FROM player_house_taken WHERE player_guid=%u", pPlayer->GetGUIDLow()); 
  793.         if(result)
  794.         {
  795.             ownsLand = true;
  796.         }
  797.     } else {
  798.         result = CharacterDatabase.PQuery("SELECT * FROM player_house_taken WHERE player_guid=%u", pPlayer->GetGUIDLow());
  799.         if(result) { ownsLand = true; } else { ownsLand = false; }
  800.     }
  801.     return ownsLand;
  802. }
  803.  
  804. bool teleportToLand(Player *pPlayer)
  805. {
  806.     if(pPlayer->isInCombat() || pPlayer->GetMap()->IsBattlegroundOrArena() || pPlayer->GetMap()->IsDungeon()){ return false; }
  807.     QueryResult spawnresult;
  808.     spawnresult = CharacterDatabase.PQuery("SELECT map_id, spawn_x, spawn_y, spawn_z, spawn_o FROM player_house_taken WHERE player_guid=%u", pPlayer->GetGUIDLow());   
  809.     if(spawnresult){
  810.         Field *fields = spawnresult->Fetch();
  811.         pPlayer->TeleportTo(fields[0].GetUInt32(),fields[1].GetFloat(),fields[2].GetFloat(),fields[3].GetFloat(),fields[4].GetFloat());
  812.         ChatHandler(pPlayer->GetSession()).SendSysMessage("Welcome Home!");
  813.         return true;
  814.     } else {
  815.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("Could not locate your spawn! Please contact a GM!");
  816.     }
  817.     return false;
  818. }
  819.  
  820. /*
  821. *****
  822. GAMEOBJECT METHODS
  823. *****
  824. */
  825.  
  826. bool isPossibleGo(uint32 gobjID)
  827. {
  828.     QueryResult result;
  829.     result = CharacterDatabase.PQuery("SELECT * FROM player_house_objects where gobjID = %u", gobjID);
  830.     if(result)
  831.         return true;
  832.  
  833.     return false;
  834. }
  835.  
  836. bool getClosestObjectAndDelete(Player *pPlayer)
  837. {
  838.     if(getSpawnCount(pPlayer->GetGUIDLow() < 0))
  839.     {
  840.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("You land item has been locked, please contact a GM");
  841.         return false;
  842.     }
  843.  
  844.     float distance = 10;
  845.     uint32 count = 0;
  846.     uint32 gameguid, gameentry;
  847.     QueryResult result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
  848.         "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
  849.         "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_ LIMIT 1",
  850.         pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(),
  851.         pPlayer->GetMapId(),pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(),distance*distance);
  852.  
  853.     if (result)
  854.     {
  855.         Field *fields = result->Fetch();
  856.         gameguid = fields[0].GetUInt32();
  857.         gameentry = fields[1].GetUInt32();
  858.         float x = fields[2].GetFloat();
  859.         float y = fields[3].GetFloat();
  860.         float z = fields[4].GetFloat();
  861.         int mapid = fields[5].GetUInt16();
  862.         ++count;
  863.     }
  864.     if(count == 0){
  865.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("No items found within 10 yards. Try moving closer to your target");
  866.         return true;
  867.     }
  868.     if(!isPossibleGo(gameentry))
  869.     {
  870.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("That object is not able to be deleted. Contact an administrator to get it removed.");
  871.         return false;
  872.     }
  873.  
  874.     if(gameguid) {
  875.         GameObject* gObj = NULL;
  876.         gObj = pPlayer->GetMap()->GetGameObject(MAKE_NEW_GUID(gameguid, gameentry, HIGHGUID_GAMEOBJECT));
  877.         if(!gObj)
  878.         {
  879.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("Could not find gameobject. Please wait 5-10 seconds to delete a object after you have spawned it.");
  880.             return false;
  881.         }
  882.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("%s was deleted!", gObj->GetName());
  883.         gObj->SetRespawnTime(0);                                
  884.         gObj->Delete();
  885.         gObj->DeleteFromDB();
  886.         CharacterDatabase.PExecute("UPDATE player_house SET items_spawned = items_spawned - 1 WHERE player_guid=%u", pPlayer->GetGUID());
  887.     }
  888.  
  889.     return true;
  890. }
  891.  
  892. bool hasPackage1(uint32 AccID, uint32 package)
  893. {
  894.     QueryResult result = CharacterDatabase.PQuery("SELECT * FROM player_house WHERE package%u = 1 AND player_guid = %u", package, AccID);
  895.     if(result)
  896.         return true;
  897.     return false;
  898. }
  899.  
  900. bool spawnGoObject(Player *pPlayer, uint32 itemID)
  901. {
  902.     if(isCharacterInLand(pPlayer)){
  903.         if(getSpawnCount(pPlayer->GetGUIDLow() < 0) || getSpawnCount(pPlayer->GetGUIDLow() > 1000))
  904.         {
  905.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("You land item has been locked, please contact a GM");
  906.             return false;
  907.         }
  908.  
  909.         int bonus = getSpawnCountBonus(pPlayer->GetGUIDLow());
  910.         if(getSpawnCount(pPlayer->GetGUIDLow()) < GAMEOBJECT_SPAWN_LIMIT + bonus)
  911.         {
  912.             Map *map = pPlayer->GetMap();
  913.             GameObject* pGameObj = new GameObject; 
  914.             uint32 db_lowGUID = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
  915.  
  916.             if (!pGameObj->Create(db_lowGUID, itemID, map, 1, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
  917.             {
  918.                 delete pGameObj;
  919.                 return false;
  920.             }
  921.  
  922.             pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),pPlayer->GetPhaseMaskForSpawn());
  923.             map->AddToMap(pGameObj);
  924.             sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
  925.             CharacterDatabase.PExecute("UPDATE player_house SET items_spawned = items_spawned + 1 WHERE player_guid=%u", pPlayer->GetGUIDLow());
  926.         } else {
  927.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("GameObject spawn limit reached!");
  928.         }
  929.     } else {
  930.         teleportToLand(pPlayer);
  931.     }
  932.     return true;
  933. }
  934.  
  935. int getSpawnCount(uint32 plrName)
  936. {
  937.     uint32 spawn = 0;
  938.     QueryResult result = CharacterDatabase.PQuery("SELECT items_spawned FROM player_house WHERE player_guid = %u", plrName);
  939.     if(result)
  940.     {
  941.         spawn = (*result)[0].GetUInt32();
  942.         if (spawn <= 0)
  943.             return 0;
  944.     } else {
  945.         return 0;
  946.     }
  947.     return spawn;
  948. }
  949.  
  950. int getSpawnCountBonus(uint32 plrName)
  951. {
  952.     uint32 spawn = 0;
  953.     QueryResult result = CharacterDatabase.PQuery("SELECT items_bonus FROM player_house WHERE player_guid = %u", plrName);
  954.     if(result)
  955.     {
  956.         spawn = (*result)[0].GetUInt32();
  957.         if (spawn <= 0)
  958.             return 0;
  959.     } else {
  960.         return 0;
  961.     }
  962.     return spawn;
  963. }
  964. /*
  965. -------
  966. END GAMEOBJECT METHODS
  967. -----
  968. */
  969.  
  970.  
  971. /*
  972. -----
  973. ADD NPC METHODS
  974. ------
  975. */
  976.  
  977. bool isPossibleNpc(uint32 npcId)
  978. {
  979.     QueryResult result;
  980.     result = CharacterDatabase.PQuery("SELECT * FROM player_house_npcs where npcId = %u", npcId);
  981.     if(result)
  982.         return true;
  983.  
  984.     return false;
  985. }
  986.  
  987. int getNPCCount(uint32 plrName)
  988. {
  989.     uint32 npc = 0;
  990.     QueryResult result = CharacterDatabase.PQuery("SELECT npcs_spawned FROM player_house WHERE player_guid = %u", plrName);
  991.     if(result)
  992.     {
  993.         npc = (*result)[0].GetUInt32();
  994.         if (npc <= 0)
  995.             return 0;
  996.     } else {
  997.         return 0;
  998.     }
  999.     return npc;
  1000. }
  1001.  
  1002. int getNPCCountBonus(uint32 plrName)
  1003. {
  1004.     uint32 npc = 0;
  1005.     QueryResult result = CharacterDatabase.PQuery("SELECT npcs_bonus FROM player_house WHERE player_guid = %u", plrName);
  1006.     if(result)
  1007.     {
  1008.         npc = (*result)[0].GetUInt32();
  1009.         if (npc <= 0)
  1010.             return 0;
  1011.     } else {
  1012.         return 0;
  1013.     }
  1014.     return npc;
  1015. }
  1016.  
  1017. bool spawnNPC(Player *pPlayer, uint32 npcID)
  1018. {
  1019.     if(isCharacterInLand(pPlayer)){
  1020.         if(getNPCCount(pPlayer->GetGUIDLow() < 0) || getNPCCount(pPlayer->GetGUIDLow() > 1000))
  1021.         {
  1022.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("You land item has been locked, please contact a GM");
  1023.             return false;
  1024.         }
  1025.  
  1026.         int bonus = getNPCCountBonus(pPlayer->GetGUID());
  1027.         if(getNPCCount(pPlayer->GetGUIDLow()) < NPC_SPAWN_LIMIT + bonus)
  1028.         {
  1029.             float player_x = pPlayer->GetPositionX();
  1030.             float player_y = pPlayer->GetPositionY();
  1031.             float player_z = pPlayer->GetPositionZ();
  1032.             float player_o = pPlayer->GetOrientation();
  1033.             uint32 mapid = pPlayer->GetMapId();
  1034.             Map *map = pPlayer->GetMap();
  1035.             Creature* creature = new Creature;
  1036.             if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, 1, npcID, 0, 1, player_x, player_y, player_z, player_o)){
  1037.                 delete creature;
  1038.                 return false;
  1039.             }
  1040.             creature->SaveToDB(mapid, (1 << map->GetSpawnMode()), pPlayer->GetPhaseMaskForSpawn());
  1041.             uint32 db_guid = creature->GetDBTableGUIDLow();
  1042.             if (!creature->LoadCreatureFromDB(db_guid, map)){
  1043.                 delete creature;
  1044.                 return false;
  1045.             }
  1046.             sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
  1047.  
  1048.             CharacterDatabase.PExecute("UPDATE player_house SET npcs_spawned = npcs_spawned + 1 WHERE player_guid=%u", pPlayer->GetGUIDLow());
  1049.         } else {
  1050.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("NPC spawn limit reached!");
  1051.         }
  1052.     } else {
  1053.         teleportToLand(pPlayer);
  1054.     }
  1055.     return true;
  1056. }
  1057.  
  1058. bool deleteNPC(Player *pPlayer)
  1059. {
  1060.     Creature *creep = pPlayer->GetMap()->GetCreature(pPlayer->GetSelection());
  1061.     if(!creep)
  1062.         return false;
  1063.     if(creep->isPet() || creep->isHunterPet() || creep->IsControlledByPlayer() || creep->isSpiritHealer() || creep->isSummon())
  1064.         return false;
  1065.  
  1066.     if(getNPCCount(pPlayer->GetGUIDLow()) < 0)
  1067.     {
  1068.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("You land item has been locked, please contact a GM");
  1069.         return false;
  1070.     }
  1071.  
  1072.  
  1073.     if(!isPossibleNpc(creep->GetEntry()))
  1074.     {
  1075.         ChatHandler(pPlayer->GetSession()).PSendSysMessage("Your not allowed to delete that creature.");
  1076.         return false;
  1077.     }
  1078.  
  1079.     float playerx = creep->GetPositionX();
  1080.     float playery = creep->GetPositionY();
  1081.     uint32 mapid_multi = pPlayer->GetMap()->GetId();
  1082.  
  1083.     QueryResult result = CharacterDatabase.PQuery("SELECT map_id, bottom_x, top_x, left_y, right_y FROM player_house_taken WHERE player_guid=%u AND map_id=%u", pPlayer->GetGUIDLow(), mapid_multi);   
  1084.     do{
  1085.         Field *fields = result->Fetch();
  1086.         mapid = fields[0].GetInt32();
  1087.         bottom_x = fields[1].GetFloat();
  1088.         top_x = fields[2].GetFloat();
  1089.         left_y = fields[3].GetFloat();
  1090.         right_y = fields[4].GetFloat();
  1091.  
  1092.         if(playerx < bottom_x && playerx > top_x && playery < left_y && playery > right_y)
  1093.         {
  1094.             creep->CombatStop();
  1095.             creep->DeleteFromDB();
  1096.             creep->AddObjectToRemoveList();
  1097.             CharacterDatabase.PExecute("UPDATE player_house SET npcs_spawned = npcs_spawned - 1 WHERE player_guid=%u", pPlayer->GetGUIDLow());
  1098.             ChatHandler(pPlayer->GetSession()).PSendSysMessage("%s has been deleted!", creep->GetName());
  1099.             return true;
  1100.         }
  1101.  
  1102.     } while (result->NextRow());
  1103.  
  1104.     ChatHandler(pPlayer->GetSession()).PSendSysMessage("%s is not located on your land!", creep->GetName());   
  1105.     return false;
  1106. }
  1107.  
  1108. class playerhouse_commandscript : public CommandScript
  1109. {
  1110. public:
  1111.     playerhouse_commandscript() : CommandScript("playerhouse_commandscript") { }
  1112.  
  1113.     ChatCommand* GetCommands() const
  1114.     {
  1115.  
  1116.         static ChatCommand playerhouseCommandTable[] =
  1117.         {
  1118.             { "add",         SEC_GAMEMASTER,     false, &HandleAddPlayerHouse,                 "", NULL },
  1119.             { "fix",         SEC_ADMINISTRATOR,  false, &HandleFixPlayerHouse,                 "", NULL },
  1120.             { NULL,             0,                  false, NULL,                               "", NULL }
  1121.         };
  1122.  
  1123.         static ChatCommand commandTable[] =
  1124.         {
  1125.             { "house",          SEC_GAMEMASTER,     false, NULL,            "", playerhouseCommandTable },
  1126.             { NULL,             0,                  false, NULL,                               "", NULL }
  1127.         };
  1128.         return commandTable;
  1129.     }
  1130.  
  1131.     static bool HandleFixPlayerHouse(ChatHandler* handler, const char* /*args*/)
  1132.     {
  1133.         Player* player = handler->GetSession()->GetPlayer();
  1134.  
  1135.         if(player->GetSession()->GetSecurity() == 10)
  1136.         {
  1137.             CharacterDatabase.PExecute("ALTER TABLE player_house_available DROP id");
  1138.             CharacterDatabase.PExecute("ALTER TABLE player_house_available AUTO_INCREMENT = 1");
  1139.             CharacterDatabase.PExecute("ALTER TABLE player_house_available ADD id int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
  1140.             handler->PSendSysMessage("Houses are now set in order!");
  1141.         } else {
  1142.             handler->PSendSysMessage("Only rank 10 people can use this command.");
  1143.             return false; }
  1144.  
  1145.         return true;
  1146.     }
  1147.  
  1148.     static bool HandleAddPlayerHouse(ChatHandler* handler, char const* args)
  1149.     {
  1150.         if (!*args)
  1151.             return false;
  1152.  
  1153.         char* nameStr = strtok((char*)args, " ");
  1154.         if (!nameStr)
  1155.             return false;
  1156.  
  1157.         char* _price = strtok(NULL, " ");
  1158.         uint32 price;
  1159.  
  1160.         if (!_price)
  1161.             price = 10;
  1162.         else
  1163.             price = atoi(_price);
  1164.  
  1165.         if (!price || price == NULL || price <= 0)
  1166.             price = 10;
  1167.  
  1168.         //Check to see how many locations are in the DB (10max)
  1169.         QueryResult result = CharacterDatabase.PQuery("SELECT * FROM player_house_available");
  1170.         if(result){
  1171.             if(result->GetRowCount() >= 20)
  1172.             {
  1173.                 handler->PSendSysMessage("You can only have 20 active locations at a time!");
  1174.                 return true;
  1175.             }
  1176.         }
  1177.  
  1178.         //Cordinates for available house
  1179.         float top_x = 0;
  1180.         float bottom_x = 0;
  1181.         float left_y = 0;
  1182.         float right_y = 0;
  1183.  
  1184.         //Varibles used throughout code
  1185.         Player *player = handler->GetSession()->GetPlayer();
  1186.         float player_x = player->GetPositionX();
  1187.         float player_y = player->GetPositionY();
  1188.         uint32 mapid = player->GetMapId();
  1189.         Map *map = player->GetMap();
  1190.  
  1191.         //Check to see if you are to close to avliable players land
  1192.         result = CharacterDatabase.PQuery("SELECT bottom_x, top_x, left_y, right_y FROM player_house_available WHERE map_id= '%u'", mapid);
  1193.         if(result)
  1194.         {
  1195.             do{
  1196.                 Field *fields = result->Fetch();
  1197.                 bottom_x = fields[0].GetFloat() - 40.0;
  1198.                 top_x = fields[1].GetFloat() + 40.0;
  1199.                 left_y = fields[2].GetFloat() - 40.0;
  1200.                 right_y = fields[3].GetFloat() + 40.0;
  1201.  
  1202.                 if(player_x > bottom_x && player_x < top_x && player_y > left_y && player_y < right_y){
  1203.                     handler->PSendSysMessage("You are to close to another players land! Please move further away and try again.");
  1204.                     return false;
  1205.                 }
  1206.             } while (result->NextRow());
  1207.         }
  1208.  
  1209.         //Check to see if occupied land is close to where youre located.
  1210.         result = CharacterDatabase.PQuery("SELECT bottom_x, top_x, left_y, right_y FROM player_house_taken WHERE map_id= '%u'", mapid);
  1211.         if(result)
  1212.         {
  1213.             do{
  1214.                 Field *fields = result->Fetch();
  1215.                 bottom_x = fields[0].GetFloat() - 40.0;
  1216.                 top_x = fields[1].GetFloat() + 40.0;
  1217.                 left_y = fields[2].GetFloat() - 40.0;
  1218.                 right_y = fields[3].GetFloat() + 40.0;         
  1219.                 if(player_x > bottom_x && player_x < top_x && player_y > left_y && player_y < right_y){
  1220.                     handler->PSendSysMessage("You are to close to another players land! Please move further away and try again.");
  1221.                     return false;
  1222.                 }
  1223.             } while (result->NextRow());
  1224.         }
  1225.  
  1226.         //Set bottom_x, left_y as highest value
  1227.         if((player_x - 23) > (player_x + 23)){
  1228.             bottom_x = player_x - 23; top_x = player_x + 23; }
  1229.         else{
  1230.             bottom_x = player_x + 23; top_x = player_x - 23; }
  1231.         if((player_y + 23) > (player_y - 23)) {
  1232.             left_y = player_y + 23; right_y = player_y - 23; }
  1233.         else{
  1234.             left_y = player_y - 23; right_y = player_y + 23; }
  1235.  
  1236.         //Spawn creature to assist with purchase of land.
  1237.         Creature* creature = new Creature;
  1238.         if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, player->GetPhaseMaskForSpawn(), 594, 0, 1, player_x+1, player_y+1, player->GetPositionZ(), player->GetOrientation()))
  1239.             delete creature;
  1240.         creature->SaveToDB(mapid, (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn());
  1241.         uint32 db_guid = creature->GetDBTableGUIDLow();
  1242.         if (!creature->LoadCreatureFromDB(db_guid, map))
  1243.             delete creature;
  1244.         sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
  1245.  
  1246.         //Insert data into available houses
  1247.         CharacterDatabase.PExecute("INSERT INTO player_house_available (zone_name, price, map_id, bottom_x, top_x, left_y, right_y, spawn_x, spawn_y, spawn_z, spawn_o, c_guid) VALUES (\"%s\", %u, %u, %f, %f, %f, %f, %f, %f, %f, %f, %u)",
  1248.             nameStr, price, mapid, bottom_x, top_x,
  1249.             left_y, right_y, player_x, player_y,
  1250.             player->GetPositionZ(), player->GetOrientation(), db_guid);
  1251.  
  1252.         handler->PSendSysMessage("Success! %s has been added for %u DP to the database as possible land!", nameStr, price);
  1253.         return true;
  1254.     }
  1255. };
  1256.  
  1257. /*
  1258. -----
  1259. END NPC METHODS
  1260. ---
  1261. */
  1262.  
  1263. void AddSC_npc_player_house()
  1264. {
  1265.     new npc_player_house();
  1266.     new playerhouse_commandscript();
  1267. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement