Advertisement
Rochet2

Kill all players

Aug 2nd, 2012
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. #include "AccountMgr.h"
  4.  
  5. class buff_commandscript : public CommandScript
  6. {
  7. public:
  8.     buff_commandscript() : CommandScript("buff_commandscript") { }
  9.  
  10.     ChatCommand* GetCommands() const
  11.     {
  12.         static ChatCommand IngameCommandTable[] =
  13.         {
  14.             { "killallplayers", SEC_ADMINISTRATOR,         false, &HandleKillAllCommand,       "", NULL },
  15.             { NULL,             0,                  false, NULL,                        "", NULL }
  16.         };
  17.         return IngameCommandTable;
  18.     }
  19.  
  20.     static bool HandleKillAllCommand(ChatHandler * handler, const char * args)
  21.     {
  22.         SessionMap m_sessions = sWorld->GetAllSessions();
  23.         for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
  24.         {
  25.             if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
  26.                 continue;
  27.  
  28.             if(AccountMgr::IsPlayerAccount(itr->second->GetSecurity())) // Only killing players, not GMs
  29.                 itr->second->GetPlayer()->KillPlayer();
  30.         }
  31.         handler->PSendSysMessage("All players have been killed");
  32.         return true;
  33.     }
  34. };
  35.  
  36. void AddSC_Ingame_commandscript()
  37. {
  38.     new buff_commandscript();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement