Created
December 19, 2011 13:25
-
-
Save fredimachado/1497219 to your computer and use it in GitHub Desktop.
Implement PlayerScript::OnUpdateZone Hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp | |
index b59c8c0..961079a 100755 | |
--- a/src/server/game/Entities/Player/Player.cpp | |
+++ b/src/server/game/Entities/Player/Player.cpp | |
@@ -7379,6 +7379,8 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) | |
if (!zone) | |
return; | |
+ sScriptMgr->OnPlayerUpdateZone(this, newZone, newArea); | |
+ | |
if (sWorld->getBoolConfig(CONFIG_WEATHER)) | |
{ | |
Weather* wth = WeatherMgr::FindWeather(zone->ID); | |
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp | |
index 925b352..e5f937d 100755 | |
--- a/src/server/game/Scripting/ScriptMgr.cpp | |
+++ b/src/server/game/Scripting/ScriptMgr.cpp | |
@@ -1297,6 +1297,11 @@ void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, ui | |
FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent); | |
} | |
+void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea) | |
+{ | |
+ FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea); | |
+} | |
+ | |
// Guild | |
void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank) | |
{ | |
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h | |
index b3ba7f0..100b50e 100755 | |
--- a/src/server/game/Scripting/ScriptMgr.h | |
+++ b/src/server/game/Scripting/ScriptMgr.h | |
@@ -723,6 +723,9 @@ class PlayerScript : public ScriptObject | |
// Called when a player is bound to an instance | |
virtual void OnBindToInstance(Player* /*player*/, Difficulty /*difficulty*/, uint32 /*mapId*/, bool /*permanent*/) { } | |
+ | |
+ // Called in Player::UpdateZone | |
+ virtual void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea) { } | |
}; | |
class GuildScript : public ScriptObject | |
@@ -992,6 +995,7 @@ class ScriptMgr | |
void OnPlayerCreate(Player* player); | |
void OnPlayerDelete(uint64 guid); | |
void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent); | |
+ void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea); | |
public: /* GuildScript */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment