Advertisement
tok124

levelup token

Nov 11th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chathandler.cpp"
  3.  
  4. uint32 ITEM_ID = 44728;
  5. uint8 MAX_LVL = 255;
  6.  
  7. class item_level : public ItemScript
  8. {
  9. public:
  10.     item_level() : ItemScript("item_level") { }
  11.  
  12.     bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
  13.     {
  14.         if(player->IsInCombat() || player->IsInFlight())
  15.         {
  16.             player->GetSession()->SendNotification("You Cant Use This Right Now!");
  17.             return false;
  18.         }
  19.         if(player->getLevel() >= MAX_LVL)
  20.         {
  21.             player->GetSession()->SendNotification("You are already max level.");
  22.             return false;
  23.         }
  24.  
  25.         int32 oldlevel = player->getLevel();
  26.         int32 newLevel = oldlevel + 1;
  27.  
  28.         player->GiveLevel(newLevel);
  29.         player->InitTalentForLevel();
  30.         player->SetUInt32Value(PLAYER_XP, 0);
  31.         player->DestroyItemCount(ITEM_ID, 1, true);
  32.         player->GetSession()->SendNotification("You have used one level token. Thanks for supporting our server");
  33.         return true;
  34.     }
  35. };
  36.  
  37. void AddSC_item_level()
  38. {
  39.     new item_level();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement