Advertisement
Guest User

EmuDevs Abuse Player

a guest
Apr 27th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. /*
  2.  *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3.  *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4.  *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5.  *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6.  *            www.emudevs.com
  7. */
  8. struct PlayerAbuse
  9. {
  10.     uint64 victimGUID;
  11.     uint32 whenKilled;
  12. };
  13.  
  14. std::map<uint64, PlayerAbuse> abuseList;
  15.  
  16. class kill_player_abuse : PlayerScript
  17. {
  18. public:
  19.     kill_player_abuse() : PlayerScript("kill_player_abuse") { }
  20.  
  21.     void OnPVPKill(Player* killer, Player* victim)
  22.     {
  23.         if (killer->GetGUID() == victim->GetGUID())
  24.             return;
  25.  
  26.         if (!abuseList.empty())
  27.         {
  28.             for (std::map<uint64, PlayerAbuse>::const_iterator itr = abuseList.begin(); itr != abuseList.end(); ++itr)
  29.             {
  30.                 if (itr->first == killer->GetGUID() && itr->second.victimGUID == victim->GetGUID()) // Initial check
  31.                 {
  32.                     if (GetMSTimeDiffToNow(itr->second.whenKilled) < 180000) // < 3 minutes 180000
  33.                     {   // The player won't be able to kill the same player for another 3 minutes
  34.                         ChatHandler(killer->GetSession()).PSendSysMessage("You cannot kill this player for another %u minute(s).", CalculateTimeInMinutes(GetMSTimeDiffToNow(itr->second.whenKilled)));
  35.                         return;
  36.                     }
  37.                     else
  38.                         abuseList.erase(killer->GetGUID());
  39.                 }
  40.             }
  41.         }
  42.         // Adding the killer/victimGUID to the abuse list
  43.         abuseList[killer->GetGUID()].victimGUID = victim->GetGUID();
  44.         abuseList[killer->GetGUID()].whenKilled = getMSTime();
  45.  
  46.         /* You can add other code beyond this point */
  47.     }
  48.  
  49.     uint32 CalculateTimeInMinutes(uint32 m_time)
  50.     {
  51.         uint32 howManyMinutes;
  52.         if (m_time >= 180000) // 180000 = 3 minutes
  53.             howManyMinutes = 3;
  54.         else if (m_time < 180000-60000)
  55.             howManyMinutes = 2;
  56.         else if (m_time > 180000-60000)
  57.             howManyMinutes = 1;
  58.         return howManyMinutes;
  59.     }
  60. };
  61.  
  62. void AddSC_player_abuse()
  63. {
  64.     new kill_player_abuse();
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement