Advertisement
Guest User

FFA

a guest
Jul 24th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. #include "Player.h"
  4.  
  5.  
  6. class ffa_commandscript : public CommandScript
  7. {
  8. public:
  9.     ffa_commandscript() : CommandScript("ffa_commandscript") { }
  10.  
  11.     ChatCommand* GetCommands() const
  12.     {
  13.         static ChatCommand ffaCommandTable[] =
  14.         {
  15.             { "on", SEC_PLAYER, false, &HandleFFAOnCommand, "", NULL },
  16.             { "off", SEC_PLAYER, false, &HandleFFAOnCommand, "", NULL },
  17.             { NULL, 0, false, NULL, "", NULL }
  18.         };
  19.         static ChatCommand commandTable[] =
  20.         {
  21.             { "ffa", SEC_PLAYER, true, NULL, "", ffaCommandTable },
  22.             { NULL, 0, false, NULL, "", NULL }
  23.         };
  24.         return commandTable;
  25.     }
  26.  
  27.     static bool HandleFFAOnCommand(ChatHandler * handler, const char * args)
  28.     {
  29.         Player* player = handler->GetSession()->GetPlayer();
  30.  
  31.         if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
  32.         {
  33.             handler -> SendSysMessage("You are already FFA PVP Flagged!");
  34.             handler -> SetSentErrorMessage(true);
  35.             return false;
  36.         }
  37.        
  38.         SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
  39.         return true;
  40.     }
  41.    
  42.     static bool HandleFFAOffCommand(ChatHandler * handler, const char * args)
  43.     {
  44.         Player* player = handler->GetSession()->GetPlayer();
  45.  
  46.         if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
  47.         {
  48.             RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
  49.         }
  50.  
  51.         handler->SendSysMessage("You are not FFA PVP Flagged!");
  52.         handler->SetSentErrorMessage(true);
  53.         return false;
  54.         }
  55. };
  56.  
  57. void AddSC_ffa_commandscript()
  58. {
  59.     new ffa_commandscript();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement