Advertisement
Guest User

Untitled

a guest
Dec 13th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.59 KB | None | 0 0
  1. class login_event : public PlayerScript
  2. {
  3. public:
  4.     login_event () : PlayerScript("login_event ") { }
  5.    
  6.     void OnLogin(Player* player)
  7.     {
  8.         if(player->GetTotalPlayedTime() < 10)
  9.         {
  10.             //main auras player start with (chat starts in 2 seconds so it doesn't interfere with the player logging
  11.             player->m_Events.AddEvent(new customEvent(player), player->m_Events.CalculateTime(2000));
  12.             player->AddAura(auraID, player); //makes player start with an aura on (change ID with auraID)
  13.             player->AddAura(auraID, player); //read above
  14.             player->SetMovement(MOVE_ROOT); //freezes player in place
  15.         }
  16.         else
  17.         {
  18.             player->RemoveAurasDueToSpell(auraID); //since player isn't new, don't add the auras as mentioned above
  19.             player->RemoveAurasDueToSpell(auraID); //read above
  20.             player->SetMovement(MOVE_UNROOT); //makes player able to walk
  21.         }
  22.     }
  23.    
  24.     struct loginEventMain : public BasicEvent
  25.     {
  26.         loginEventMain(Player* _player) : player(_player), _event(0) {}
  27.        
  28.         bool Execute(uint64 /*time*/, uint32 /*diff*/)
  29.         {
  30.             Creature* creature = player->FindNearestCreature(creatureID, 40.0f, true); //replace creatureID with the id of the creature you want to talk
  31.            
  32.             switch(_event++)
  33.             {
  34.                 if(!creature)
  35.                     return true;
  36.                    
  37.             case 0:
  38.                 creature->MonsterSay(("Hello, "+player->GetName+". My name is test.").c_str(), LANG_UNIVERSAL, player->GetGUID());
  39.                 creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); //talk emote
  40.                 player->m_Events.AddEvent(this, player->m_Events.CalculateTime(4000)); //wait 4 seconds for the next speech
  41.                 break;
  42.             case 1:
  43.                 creature->MonsterSay("INSERT TEXT HERE", LANG_UNIVERSAL, player->GetGUID());
  44.                 creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); //emote
  45.                 player->m_Events.AddEvent(this, player->m_Events.CalculateTime(4000)); //4 second wait
  46.                 break;
  47.             case 2:
  48.                 creature->MonsterSay("INSERT TEXT HERE", LANG_UNIVERSAL, player->GetGUID());
  49.                 creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); //emote
  50.                 player->m_Events.AddEvent(this, player->m_Events.CalculateTime(4000)); //4 second wait
  51.                 break;
  52.             case 3:
  53.             //add your own event here
  54.            
  55.  
  56.             break;
  57.            
  58.             case 4:
  59.             //add your own here
  60.            
  61.            
  62.             break;
  63.            
  64.             case 5:
  65.             player->SetMovement(MOVE_UNROOT); //makes the player able to move (if you add an aura in the above, makesure you remove it from the player)
  66.             break;  //you can make more events if needed :)
  67.            
  68.             default:
  69.                 return true; //no events anymore
  70.             }
  71.             return false; // don't destroy event
  72.         }
  73.        
  74.         Player* player;
  75.         uint32 _event;
  76.     };
  77. };
  78.  
  79. void AddSC_login_event()
  80. {
  81.     new login_event();
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement