Added a hook for player::Update

This commit is contained in:
talamortis
2017-07-26 16:47:19 +01:00
committed by Yehonal
parent c15f15ebb0
commit f6ff4910c3
3 changed files with 12 additions and 0 deletions

View File

@@ -1574,6 +1574,8 @@ void Player::Update(uint32 p_time)
if (!IsInWorld())
return;
sScriptMgr->OnBeforePlayerUpdate(this, p_time);
// undelivered mail
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
{

View File

@@ -1263,6 +1263,11 @@ void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck)
FOREACH_SCRIPT(PlayerScript)->OnSpellCast(player, spell, skipCheck);
}
void ScriptMgr::OnBeforePlayerUpdate(Player* player, uint32 p_time)
{
FOREACH_SCRIPT(PlayerScript)->OnBeforeUpdate(player, p_time);
}
void ScriptMgr::OnPlayerLogin(Player* player)
{
FOREACH_SCRIPT(PlayerScript)->OnLogin(player);

View File

@@ -777,6 +777,9 @@ class PlayerScript : public ScriptObject
// Called when a player's talent points are reset (right before the reset is done)
virtual void OnTalentsReset(Player* /*player*/, bool /*noCost*/) { }
// Called for player::update
virtual void OnBeforeUpdate(Player* /*player*/, uint32 /*p_time*/){ }
// Called when a player's money is modified (before the modification is done)
virtual void OnMoneyChanged(Player* /*player*/, int32& /*amount*/) { }
@@ -1177,6 +1180,8 @@ class ScriptMgr
public: /* PlayerScript */
void OnBeforePlayerUpdate(Player* player, uint32 p_time);
void OnPlayerReleasedGhost(Player* player);
void OnPVPKill(Player* killer, Player* killed);
void OnCreatureKill(Player* killer, Creature* killed);