Advertisement
Rochet2

Developer tag command Trinitycore C++

Sep 17th, 2011
1,755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. /*
  2. This script is made by Rochet2
  3. Please give credits if you are going to use this script somewhere.
  4.  
  5. For TrinityCore
  6. Trinirycore command example as the base and a little help from SD2 forums.
  7.  
  8. Adds a .developer command to your core.
  9. The notifications work like the GM tag's,
  10. but the command ONLY shows the <Dev> tag before your name, does nothing more
  11. */
  12.  
  13. #include "ScriptPCH.h"
  14. #include "Chat.h"
  15.  
  16. class devtag_commandscript : public CommandScript
  17. {
  18.     public:
  19.         devtag_commandscript() : CommandScript("devtag_commandscript") { }
  20.  
  21.         static bool DevTagWorldCommand(ChatHandler* handler, const char* args)
  22.         {
  23.             if (!*args)
  24.             {
  25.                 if (handler->GetSession()->GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
  26.                     handler->GetSession()->SendAreaTriggerMessage("|cffff0000Dev mode is ON|r");
  27.                 else
  28.                     handler->GetSession()->SendAreaTriggerMessage("|cffff0000Dev mode is OFF|r");
  29.                 return true;
  30.             }
  31.  
  32.             std::string argstr = (char*)args;
  33.  
  34.             if (argstr == "on")
  35.             {
  36.                 handler->GetSession()->SendAreaTriggerMessage("|cffff0000Dev mode is ON|r");
  37.                 handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
  38.                 return true;
  39.             }
  40.  
  41.             if (argstr == "off")
  42.             {
  43.                 handler->GetSession()->SendAreaTriggerMessage("|cffff0000Dev mode is OFF|r");
  44.                 handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
  45.                 return true;
  46.             }
  47.  
  48.             handler->SendSysMessage(LANG_USE_BOL);
  49.             handler->SetSentErrorMessage(true);
  50.             return false;
  51.         }
  52.  
  53.         ChatCommand* GetCommands() const
  54.         {
  55.             static ChatCommand DevTagCommandTable[] =
  56.             {
  57.                 { "developer",      SEC_PLAYER,         false,   &DevTagWorldCommand,        "", NULL },
  58.                 { NULL,             0,                  false,  NULL,                       "", NULL }
  59.             };
  60.             return DevTagCommandTable;
  61.         }
  62. };
  63.  
  64. void AddSC_devtag_commandscript()
  65. {
  66.     new devtag_commandscript();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement