Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegisterBGEvent - bg:GetMap(), (nil) missing metatable #426

Closed
PerfectlyFineCode opened this issue Jul 26, 2022 · 5 comments
Closed

RegisterBGEvent - bg:GetMap(), (nil) missing metatable #426

PerfectlyFineCode opened this issue Jul 26, 2022 · 5 comments

Comments

@PerfectlyFineCode
Copy link

As title mentions, upon the callback of RegisterBGEvent, if you try to get the bg's map you will get (nil) missing metatable.

Am I doing something wrong?

function start(event, bg, bgId, instanceId)
    -- get players in the battleground
    local map = bg:GetMap()

    PrintInfo(map)
end

RegisterBGEvent(1, start)
@Rochet2
Copy link
Member

Rochet2 commented Jul 27, 2022

What core are you using? (TC, AC, mangos, cmangos, ...)

@PerfectlyFineCode
Copy link
Author

PerfectlyFineCode commented Jul 27, 2022

What core are you using? (TC, AC, mangos, cmangos, ...)

Tried with both Azerothcore and Trinitycore from various versions, same result.

But let's say Azerothcore.

@Rochet2
Copy link
Member

Rochet2 commented Jul 27, 2022

The issue seems to be that GetMap in C++ returns a BattlegroundMap which is not supported/implemented.
However, it is just a derivative of Map.
This should fix it and makes the function return a Map as it is expected to according to Eluna documentation. 2eb5275

@Rochet2 Rochet2 closed this as completed Jul 27, 2022
@PerfectlyFineCode
Copy link
Author

PerfectlyFineCode commented Jul 29, 2022

The issue seems to be that GetMap in C++ returns a BattlegroundMap which is not supported/implemented. However, it is just a derivative of Map. This should fix it and makes the function return a Map as it is expected to according to Eluna documentation. 2eb5275

Unfortunately doesn't work.
it returns (null) missing metatable now, and not (nil) missing metatable.
at least it doesn't crash now which is a bonus, but it still doesn't work.

Code:

function start(event, bg, bgId, instanceId)
    -- get players in the battleground
    local map = bg:GetMap()

    -- if map is nil
    if map == nil then
        PrintInfo("GetMap returned nil")
        return
    end

    local players = map:GetPlayers()

    if players == nil then
        PrintInfo("players returned nil")
        return
    end

    -- loop through all players in the battleground
    for _, player in pairs(players) do
        -- get the player's team
        local team = player:GetTeam()
        PrintInfo("Got Player")
    end
    PrintInfo("end of start()")
end

RegisterBGEvent(1, start)

image

@Rochet2
Copy link
Member

Rochet2 commented Sep 10, 2022

Unfortunately doesn't work.
at least it doesn't crash now which is a bonus, but it still doesn't work.

Are you still having the issue?
If you are using azerothcore, they need to pull the latest changes to their eluna module (https://github.com/azerothcore/mod-eluna)
On TC it should not occur if latest eluna is used.

it returns (null) missing metatable now, and not (nil) missing metatable.

I think that originally the error message was saying null, so the error probably did not change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants