Advertisement
Rochet2

Example 5 players

Aug 1st, 2012
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptPCH.h"
  2.  
  3. std::vector<Player*> Players;
  4. bool BgRunning = false;
  5.  
  6. class TEST : public CreatureScript
  7. {
  8. public:
  9.     TEST() : CreatureScript("TEST") {}
  10.  
  11.     bool OnGossipHello(Player* player, Creature* creature)
  12.     {
  13.         // blah blah
  14.     }
  15.  
  16.     bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 uiAction)
  17.     {
  18.         switch(uiAction)
  19.         {
  20.         case GOSSIP_ACTION_INFO_DEF+1:
  21.             {
  22.                 if(BgRunning)
  23.                 {
  24.                     player->GetSession()->SendNotification("BG is already running");
  25.                     return true;
  26.                 }
  27.                 Players.push_back(player); // add player to the list
  28.                 if (Players.size() >= 5)
  29.                 {
  30.                     for (auto it = Players.begin() ; it < Players.end(); it++ )
  31.                     {
  32.                         if(!(*it)->IsInWorld())
  33.                             Players.erase(it);
  34.                     }
  35.                     if (Players.size() >= 5)
  36.                         for (auto it = Players.begin() ; it < Players.end(); it++ )
  37.                         {
  38.                             (*it)->TeleportTo(0, 0.0, 0.0, 0.0, 0.0);
  39.                             BgRunning = true;
  40.                         }
  41.                 }
  42.             }
  43.         }
  44.         return true;
  45.     }
  46. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement