Advertisement
Rochet2

GhostCrawler's givelevel

Aug 19th, 2012
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Original script by Ghostcrawler336
  2.  
  3. #include "ScriptPCH.h"
  4. #define TOKEN_ID   60007   // Replace 60007 to YOUR_TOKEN_ID
  5.  
  6. class Level_NPC : public CreatureScript
  7. {
  8. public:
  9.     Level_NPC() : CreatureScript("Level_NPC") {}
  10.  
  11.     bool OnGossipHello(Player* pPlayer, Creature* _creature)
  12.     {
  13.         pPlayer->ADD_GOSSIP_ITEM(7, "Welcome to the level NPC!", GOSSIP_SENDER_MAIN, 0);
  14.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 10(10 Token)", GOSSIP_SENDER_MAIN, 1);
  15.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 20(20 Tokens)", GOSSIP_SENDER_MAIN, 2);
  16.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 30(30 Tokens)", GOSSIP_SENDER_MAIN, 3);
  17.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 40(40 Tokens)", GOSSIP_SENDER_MAIN, 4);
  18.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 50(50 Tokens)", GOSSIP_SENDER_MAIN, 5);
  19.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 60(60 Tokens)", GOSSIP_SENDER_MAIN, 6);
  20.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 70(70 Tokens)", GOSSIP_SENDER_MAIN, 7);
  21.         pPlayer->ADD_GOSSIP_ITEM(10, "Level 80(80 Tokens)", GOSSIP_SENDER_MAIN, 8);
  22.  
  23.         pPlayer->PlayerTalkClass->SendGossipMenu(907, _creature->GetGUID());
  24.         return true;
  25.     }
  26.  
  27.     bool OnGossipSelect(Player* pPlayer, Creature* _creature, uint32 uiSender, uint32 uiAction)
  28.     {
  29.         pPlayer->PlayerTalkClass->ClearMenus();
  30.         if(uiAction != 0)
  31.             if (pPlayer->HasItemCount(TOKEN_ID, uiAction*10, false))
  32.             {
  33.                 if(pPlayer->getLevel() >= 80)
  34.                 {
  35.                     pPlayer->GetSession()->SendNotification("You are already level 80!");
  36.                 }
  37.                 else
  38.                 {
  39.                     uint8 newlevel = pPlayer->getLevel()+uiAction*10;
  40.                     if(newlevel > 80)
  41.                         newlevel = 80;
  42.                     pPlayer->GiveLevel(newlevel);
  43.                     pPlayer->InitTalentForLevel();
  44.                     pPlayer->SetUInt32Value(PLAYER_XP, 0);
  45.                     pPlayer->DestroyItemCount(TOKEN_ID, uiAction*10, true);
  46.                     pPlayer->GetSession()->SendAreaTriggerMessage("You are now Level %u!", uint32(pPlayer->getLevel()));
  47.                     pPlayer->PlayerTalkClass->SendCloseGossip();
  48.                     return true;
  49.                 }
  50.             }
  51.             else
  52.                 pPlayer->GetSession()->SendNotification("You don't have the required token");
  53.         OnGossipHello(pPlayer, _creature);
  54.         return true;
  55.     }
  56. };
  57. void AddSC_Level_NPC()
  58. {
  59.     new Level_NPC();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement