Advertisement
Rochet2

Timed jamey try this

Jun 30th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. #define PlayerAmount    10
  4.  
  5. static bool Countdownstart;
  6. static uint32 playeroom = PlayerAmount;
  7.  
  8. class PvP_Event_Announcer : public WorldScript
  9. {
  10. public:
  11.     PvP_Event_Announcer() : WorldScript("PvP_Event_Announcer"){}
  12.  
  13.     void OnStartup()
  14.     {
  15.         Events.ScheduleEvent(COUNTDOWN_60, 10000);
  16.     }
  17.  
  18.     void OnUpdate(uint32 diff)
  19.     {
  20.         Events.Update(diff);
  21.         while (uint32 eventId = Events.ExecuteEvent())
  22.         {
  23.             switch (eventId)
  24.             {
  25.             case COUNTDOWN_60:
  26.                 {
  27.                     sWorld->SendServerMessage(SERVER_MSG_STRING, "|cffffcc00[PvP Event Announcer]:|r|c00FFFFFFThe 1 versus 1 PvP event countdown is starting in 1 minute !");
  28.                     Events.ScheduleEvent(COUNTDOWN_30, 30000);
  29.                     break;
  30.                 }
  31.             case COUNTDOWN_30:
  32.                 {
  33.                     sWorld->SendServerMessage(SERVER_MSG_STRING, "|cffffcc00[PvP Event Announcer]:|r|c00FFFFFFThe 1 versus 1 PvP event countdown is starting in 30 seconds, contestors be ready!");
  34.                     Events.ScheduleEvent(EVENT_START_60, 30000);
  35.                     break;
  36.                 }
  37.             case EVENT_START_60:
  38.                 {
  39.                     Countdownstart = true;
  40.                     sWorld->SendServerMessage(SERVER_MSG_STRING, "|cffffcc00[PvP Event Announcer]:|r|c00FFFFFFThe 1 versus 1 PvP event countdown has started, you have 1 minute to enter by typing: .enterpvp , be fast cause only 10 players can enter!");
  41.                     Events.ScheduleEvent(EVENT_START_30, 30000);
  42.                     break;
  43.                 }
  44.             case EVENT_START_30:
  45.                 {
  46.                     sWorld->SendServerMessage(SERVER_MSG_STRING, "|cffffcc00[PvP Event Announcer]:|r|c00FFFFFFThe 1 versus 1 PvP event countdown is only 30 seconds more, enter fast if you still want to by typing : .enterpvp");
  47.                     Events.ScheduleEvent(EVENT_START, 30000);
  48.                     break;
  49.                 }
  50.             case EVENT_START:
  51.                 {
  52.                     sWorld->SendServerMessage(SERVER_MSG_STRING, "|cffffcc00[PvP Event Announcer]:|r|c00FFFFFFThe 1 versus 1 PvP event has started !");
  53.                     // Events.ScheduleEvent(EVENT_END, 60000);
  54.                     break;
  55.                 }
  56.             }
  57.         }
  58.     }
  59.  
  60. private:
  61.     EventMap Events;
  62.  
  63.     enum eEvents
  64.     {
  65.         COUNTDOWN_60,
  66.         COUNTDOWN_30,
  67.         EVENT_START_60,
  68.         EVENT_START_30,
  69.         EVENT_START,
  70.     };
  71.  
  72. };
  73.  
  74.  
  75.  
  76. class PvP_Event_Command : public CommandScript
  77. {
  78. public:
  79.     PvP_Event_Command() : CommandScript("PvP_Event_Command") {}
  80.  
  81.     ChatCommand* GetCommands() const
  82.     {
  83.         static ChatCommand PVPEventSubCommandTable[] =
  84.         {
  85.             { "enter",      SEC_PLAYER,     false&HandleEnterpvpcommand,     "", NULL },
  86.             { NULL,         0,              falseNULL,                       "", NULL }
  87.         };
  88.  
  89.         static ChatCommand CommandTable[] =
  90.         {
  91.             { "pvpevent",   SEC_PLAYER,     falseNULL,       "", PVPEventSubCommandTable },
  92.             { NULL,         0,              falseNULL,       "", NULL }
  93.         };
  94.         return CommandTable;
  95.     }
  96.  
  97.     static bool HandleEnterpvpcommand(ChatHandler* handler, const char* args)
  98.     {
  99.         WorldSession* Session = handler->GetSession();
  100.         Player* pPlayer = Session->GetPlayer();
  101.  
  102.         if(!Countdownstart)
  103.             Session->SendNotification("There is currently no countdown for this event going on");
  104.         else if(playeroom-- > 0)
  105.         {
  106.             Session->SendAreaTriggerMessage("Thank you for entering, there is room for %u more players!", playeroom);
  107.             // add pPlayer to some list or something
  108.         }
  109.         else
  110.             Session->SendNotification("The maximum player amount for this event is already reached, please try another time");
  111.         return true;
  112.     }
  113. };
  114.  
  115. void AddSC_PvP_Event()
  116. {
  117.     new PvP_Event_Announcer;
  118.     new PvP_Event_Command;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement