lua_scripts/Zone_Buff_utgarde.lua:8: attempt to call method 'GetInstance' (a nil value)
trinitycore
Lamento la confusión, me equivoqué con la API de Lua de TrinityCore. Desafortunadamente, no se puede acceder directamente a la información de la instancia de un jugador desde Lua en TrinityCore.
En este caso, tendríamos que utilizar un enfoque diferente. Podríamos usar el mapa de ID de mazmorras. Aquí hay una lista de ID de mapas de mazmorras heroicas de Wrath of the Lich King:
```lua
local heroicMaps = {
[574] = true, -- Utgarde Keep
[575] = true, -- Utgarde Pinnacle
[576] = true, -- The Nexus
[578] = true, -- The Oculus
[599] = true, -- Drak'Tharon Keep
[600] = true, -- The Stonecore
[601] = true, -- Ahn'kahet: The Old Kingdom
[602] = true, -- Azjol-Nerub
[604] = true, -- Gundrak
[608] = true, -- Violet Hold
[615] = true, -- The Obsidian Sanctum
[616] = true, -- The Eye of Eternity
[619] = true, -- Ahn'Kahet: The Old Kingdom
[624] = true, -- Vault of Archavon
[631] = true, -- Icecrown Citadel
[632] = true, -- The Forge of Souls
[649] = true, -- Trial of the Crusader
[650] = true, -- Trial of the Champion
[668] = true, -- Halls of Reflection
[724] = true, -- The Ruby Sanctum
}
```
Podríamos comprobar si el jugador está en uno de estos mapas y si está en modo heroico. Aquí te dejo el código revisado:
```lua
local BUFF_ID = 73822
local MIN_INSTANCE_LEVEL = 80
local PLAYER_EVENT_ON_ENTER_ZONE = 27
local PLAYER_EVENT_ON_LEAVE_ZONE = 28
local heroicMaps = {
--add the IDs of the heroic dungeons maps
[574] = true,
[575] = true,
-- [...]
}
local function applyZoneBuff(event, player)
local map = player:GetMap()
if map and map:IsDungeon() and player:GetLevel() >= MIN_INSTANCE_LEVEL and heroicMaps[map:GetMapId()] then
player:AddAura(BUFF_ID, player)
end
end
local function removeZoneBuff(event, player)
if player:HasAura(BUFF_ID) then
player:RemoveAura(BUFF_ID)
end
end
RegisterPlayerEvent(PLAYER_EVENT_ON_ENTER_ZONE, applyZoneBuff)
RegisterPlayerEvent(PLAYER_EVENT_ON_LEAVE_ZONE, removeZoneBuff)
```
Por favor verifica las ID de los mapas de las mazmorras heroicas y añádelas a la lista `heroicMaps` como se muestra en el ejemplo.