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