kusanagy

Level Up By Item

Sep 22nd, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. /*
  2.   _______        _         ______                
  3.  |__   __|      | |       |  ____|                
  4.     | | __ _ ___| |_ _   _| |__   _ __ ___  _   _
  5.     | |/ _` / __| __| | | |  __| | '_ ` _ \| | | |
  6.     | | (_| \__ \ |_| |_| | |____| | | | | | |_| |
  7.     |_|\__,_|___/\__|\__, |______|_| |_| |_|\__,_|
  8.                       __/ |                      
  9.                      |___/        
  10.                                          
  11. Script Made By Sinistah
  12. Special Thanks To LilleCarl For The Code Snippet
  13.  
  14. Legend
  15. ------
  16. item_id = the item id of the item ur using.
  17. max_lvl = the max lvl the script will allow players to use the item.
  18. lvl = how many levels the item will grant upon used
  19. */
  20. #include "ScriptPCH.h"
  21.  
  22. enum
  23. {
  24. item_id = 90001,
  25. max_lvl = 80,
  26. lvl = 1
  27. };
  28.  
  29. class item_level : public ItemScript
  30. {
  31. public:
  32.     item_level() : ItemScript("item_level") { }
  33.  
  34.     bool OnUse(Player* player, Item* item, const SpellCastTargets &)
  35.     {
  36.                 if(player->IsBattlegroundOrArena() || player->isInCombat() || player->isInFlight())
  37.                 {
  38.                         player->GetSession()->SendNotification("You Cant Use This Right Now!");
  39.                         return false;
  40.                 }
  41.                 if(player->getLevel() == max_lvl)
  42.                 {
  43.                         player->GetSession()->SendNotification("You are already max level.");
  44.                         return false;
  45.                 }
  46.                 player->SetLevel(player->getLevel() == max_lvl ? max_lvl : player->getLevel() + lvl);
  47.                 player->DestroyItemCount(item_id, 1, true);
  48.                 player->GetSession()->SendNotification("You have used one level coin.");
  49.                 return true;
  50.                 }
  51. };
  52.  
  53. void AddSC_item_level()
  54. {
  55.     new item_level();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment