eluna-scripts-ornfelt/lua/WowEmulationScriptPack/C++/Weekend2xp.cpp

50 lines
1.4 KiB
C++
Raw Permalink Normal View History

2023-08-16 00:50:59 +02:00
#include "Player.h"
#include "Chat.h"
#include "World.h"
#include "boost/date_time.hpp"
#include "Config.h"
#include "AccountMgr.h"
#include "ScriptMgr.h"
#include "Common.h"
#include "SharedDefines.h"
#include "WorldSession.h"
class XpWeekend : public PlayerScript
{
public:
XpWeekend() : PlayerScript("XpWeekend") { }
void OnGiveXP(Player* player, uint32& amount, Unit* victim)override
{
if (sConfigMgr->GetBoolDefault("DoubleXP.Enable", true))
{
boost::gregorian::date date(boost::gregorian::day_clock::local_day());
auto day = date.day_of_week();
if (day == boost::date_time::Friday ||
day == boost::date_time::Saturday ||
day == boost::date_time::Sunday) {
amount = amount * 2;
}
}
}
void OnLogin(Player* player, bool firstLogin)
{
if (sConfigMgr->GetBoolDefault("DoubleXP.Enable", true))
{
boost::gregorian::date date(boost::gregorian::day_clock::local_day());
auto day = date.day_of_week();
if (day == boost::date_time::Friday ||
day == boost::date_time::Saturday ||
day == boost::date_time::Sunday) {
ChatHandler(player->GetSession()).PSendSysMessage("Double XP Weekend is going on now!");
}
}
}
};
void AddSC_XpWeekend()
{
new XpWeekend();
}