Advertisement
naicer

VIP System FiX

Mar 23rd, 2014
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.93 KB | None | 0 0
  1. /*
  2. * Made By ???
  3. * Error Fixed By Rochet2
  4. * Released By Ghostcrawler
  5. * Edit by Yvoms
  6. * Re-Fixed by Naicer
  7. */
  8.  
  9.  
  10. #include "ScriptMgr.h"
  11. #include "ObjectMgr.h"
  12. #include "MapManager.h"
  13. #include "Chat.h"
  14. #include "Common.h"
  15. #include "Language.h"
  16. #include "CellImpl.h"
  17. #include "GridNotifiers.h"
  18.  
  19. class vipcommands : public CommandScript
  20. {
  21. public:
  22.     vipcommands() : CommandScript("vipcommands") { }
  23.  
  24.     ChatCommand* GetCommands() const
  25.     {
  26.         static ChatCommand vipCommandTable[] =
  27.  
  28.         {
  29.             { "island",     SEC_PLAYER,     true, &HandleVipMallCommand,         "", NULL },
  30.             { "changerace",    SEC_PLAYER,  false, &HandleChangeRaceCommand,             "", NULL },
  31.         { "changefaction",  SEC_PLAYER,  false, &HandleChangeFactionCommand,        "", NULL },
  32.         { "maxskills",  SEC_PLAYER,  false, &HandleMaxSkillsCommand,        "", NULL },
  33.         { "customize",  SEC_PLAYER,  false, &HandleCustomizeCommand,        "", NULL },
  34.         { "tele",           SEC_PLAYER,  false, &HandleTeleCommand,     "", NULL },
  35.         { "morph",           SEC_PLAYER,  false, &HandleMorphCommand,       "", NULL },
  36.         { "buffs",           SEC_PLAYER,  false, &HandleBuffCommand,        "", NULL },
  37.         { "activate",           SEC_PLAYER,  false, &HandleActivateCommand,     "", NULL },
  38.         { "getdrunk",       SEC_PLAYER,     false, &HandleGetDrunkCommand,         "", NULL },
  39.         { "soberup",       SEC_PLAYER,     false, &HandleSoberUpCommand,         "", NULL },
  40.         { "respawn",            SEC_PLAYER,      false, &HandleRespawnCommand,               "", NULL },
  41.  
  42.             { NULL,             0,                     false, NULL,                                          "", NULL }
  43.         };
  44.         static ChatCommand commandTable[] =
  45.         {
  46.             { "vip",        SEC_PLAYER,   true, NULL,      "",  vipCommandTable},
  47.            { NULL,             0,                  false, NULL,                               "", NULL }
  48.         };
  49.         return commandTable;
  50.     }
  51.  
  52. static bool HandleActivateCommand(ChatHandler * handler, const char * args)
  53. {
  54.     Player* player = handler->GetSession()->GetPlayer();
  55.  
  56.     if(player->GetSession()->GetSecurity() >= 1)
  57.     {
  58.         handler->PSendSysMessage("You already got VIP rank.");
  59.         handler->SetSentErrorMessage(true);
  60.         return false;
  61.     }
  62.  
  63.     if(player->HasItemCount(313370, 1, false)) // Token ID, Count.
  64.     {
  65.                   PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
  66.                   stmt->setUInt32(0, player->GetSession()->GetAccountId());
  67.                   stmt->setUInt8(1, 1);
  68.                   stmt->setInt32(2, 1);
  69.              LoginDatabase.Execute(stmt);
  70.         player->DestroyItemCount(313370, 1, true, false); // Token ID, Count.
  71.         handler->PSendSysMessage("Your VIP rank has been updated.Login to get it active");
  72.         return true;
  73.     }
  74.     return true;
  75. }
  76.  
  77. static bool HandleTeleCommand(ChatHandler* handler, const char* args)
  78.     {
  79.         if (!*args)
  80.             return false;
  81.  
  82.         Player* me = handler->GetSession()->GetPlayer();
  83.  
  84.         // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
  85.         GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
  86.  
  87.         if (!tele)
  88.         {
  89.             handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
  90.             handler->SetSentErrorMessage(true);
  91.             return false;
  92.         }
  93.  
  94.         if (me->IsInCombat())
  95.         {
  96.             handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  97.             handler->SetSentErrorMessage(true);
  98.             return false;
  99.         }
  100.  
  101.         MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
  102.         if (!map || map->IsBattlegroundOrArena())
  103.         {
  104.             handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
  105.             handler->SetSentErrorMessage(true);
  106.             return false;
  107.         }
  108.  
  109.         // stop flight if need
  110.         if (me->isInFlight())
  111.         {
  112.             me->GetMotionMaster()->MovementExpired();
  113.             me->CleanupAfterTaxiFlight();
  114.         }
  115.         // save only in non-flight case
  116.         else
  117.             me->SaveRecallPosition();
  118.  
  119.         me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
  120.         return true;
  121.         }
  122.  
  123.  
  124. static bool HandleBuffCommand(ChatHandler * handler, const char * args)
  125.     {
  126.         Player * pl = handler->GetSession()->GetPlayer();
  127.         if(pl->IsInCombat())
  128.         {
  129.             pl->GetSession()->SendNotification("You can't use this in combat!");
  130.             return false;
  131.         }
  132.         if(pl->InArena())
  133.         {
  134.             pl->GetSession()->SendNotification("You can't use that item in an arena match!");
  135.             return false;
  136.         }
  137.         else
  138.         pl->AddAura(48162, pl);
  139.         pl->AddAura(48074, pl);
  140.         pl->AddAura(48170, pl);
  141.         pl->AddAura(43223, pl);
  142.         pl->AddAura(36880, pl);
  143.         pl->AddAura(467, pl);
  144.         pl->AddAura(69994, pl);
  145.         pl->AddAura(48469, pl);
  146.         handler->PSendSysMessage("You have been buffed, enjoy!");
  147.         return true;
  148.  
  149.     }
  150.  
  151.  
  152. static bool HandlevipCommand(ChatHandler* handler, const char* args)
  153.     {
  154.  
  155.         Player* me = handler->GetSession()->GetPlayer();
  156.  
  157.             me->Say("vip command?", LANG_UNIVERSAL);
  158.             return true;
  159.     }
  160.  
  161. static bool HandleMorphCommand(ChatHandler* handler, const char* args)
  162.     {
  163.         handler->GetSession()->GetPlayer()->SetDisplayId((uint32)atol((char*)args));
  164.         return true;
  165.     }
  166.  
  167. static bool HandleChangeRaceCommand(ChatHandler* handler, const char* args)
  168.     {
  169.  
  170.         Player* me = handler->GetSession()->GetPlayer();
  171.         me->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
  172.         handler->PSendSysMessage("Relog to change race of your character.");
  173.         return true;
  174.     }
  175.  
  176. static bool HandleChangeFactionCommand(ChatHandler* handler, const char* args)
  177.     {
  178.  
  179.         Player* me = handler->GetSession()->GetPlayer();
  180.         me->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
  181.         handler->PSendSysMessage("Relog to change faction of your character.");
  182.         return true;
  183.     }
  184.  
  185. static bool HandleMaxSkillsCommand(ChatHandler* handler, const char* args)
  186.     {
  187.  
  188.         Player* me = handler->GetSession()->GetPlayer();
  189.         me->UpdateSkillsForLevel();
  190.         handler->PSendSysMessage("Your weapon skills are now maximized.");
  191.         return true;
  192.     }
  193.  
  194. static bool HandleCustomizeCommand(ChatHandler* handler, const char* args)
  195.     {
  196.  
  197.         Player* me = handler->GetSession()->GetPlayer();
  198.         me->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
  199.         handler->PSendSysMessage("Relog to customize your character.");
  200.         return true;
  201.     }
  202.  
  203. static bool HandleVipMallCommand(ChatHandler* handler, const char* args)
  204.     {
  205.  
  206.         Player* me = handler->GetSession()->GetPlayer();
  207.  
  208.         if (me->IsInCombat())
  209.         {
  210.             handler->SendSysMessage(LANG_YOU_IN_COMBAT);
  211.             handler->SetSentErrorMessage(true);
  212.             return false;
  213.         }
  214.  
  215.         // stop flight if need
  216.         if (me->IsInFlight())
  217.         {
  218.             me->GetMotionMaster()->MovementExpired();
  219.             me->CleanupAfterTaxiFlight();
  220.         }
  221.         // save only in non-flight case
  222.         else
  223.             me->SaveRecallPosition();
  224.  
  225.         me->TeleportTo(1,   -11851.820313f, -4769.585449f22.753876f, 6.053061f); // MapId, X, Y, Z, O
  226.                 return true;
  227.     }
  228.  
  229. static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/)
  230.     {
  231.         Player* player = handler->GetSession()->GetPlayer();
  232.  
  233.         Unit* target = handler->getSelectedUnit();
  234.         if (player->GetSelectedUnit() && target)
  235.         {
  236.             if (target->GetTypeId() != TYPEID_UNIT || target->isPet())
  237.             {
  238.                 handler->SendSysMessage(LANG_SELECT_CREATURE);
  239.                 handler->SetSentErrorMessage(true);
  240.                 return false;
  241.             }
  242.             if(player->GetAreaId() == 4722)
  243.                 return false;
  244.  
  245.             if (target->isDead())
  246.                 target->ToCreature()->Respawn();
  247.             return true;
  248.         }
  249.  
  250.         CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
  251.         Cell cell(p);
  252.         cell.SetNoCreate();
  253.  
  254.         Trinity::RespawnDo u_do;
  255.         Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);
  256.  
  257.         TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
  258.         cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());
  259.  
  260.         return true;
  261.     }
  262.  
  263. static bool HandleGetDrunkCommand(ChatHandler* handler, const char* args)
  264.         {
  265.            
  266.             Player* me = handler->GetSession()->GetPlayer();
  267.                 me->SetDrunkValue(100);
  268.                 handler->PSendSysMessage("You're now drunk!");
  269.             return true;
  270.         }
  271.  
  272. static bool HandleSoberUpCommand(ChatHandler* handler, const char* args)
  273.         {
  274.            
  275.             Player* me = handler->GetSession()->GetPlayer();
  276.                 me->SetDrunkValue(1);
  277.                 handler->PSendSysMessage("It's about time you sober up.");
  278.             return true;
  279. }
  280.    
  281. };
  282.  
  283. void AddSC_vipcommands()
  284. {
  285.     new vipcommands();
  286. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement