1. #1

    Getting name of battleground

    How do you get the name of a battleground when a player enters? Right now I am using the PLAYER_ENTERING_BATTLEGROUND event and GetRealZoneText like:

    Code:
    if event == "PLAYER_ENTERING_BATTLEGROUND" then
        local bgName = GetRealZoneText()
        print("Entering "..bgName)
    end
    But this prints out the zone I was in before entering the bg. For example, I was in Undercity, queued for Arathi Basin, accepted queue. When the loading finished, my chat log had a message "Entering Undercity". Using /reload, the screen loaded and I had the message "Entering Arathi Basin"

    Is there a way to get the name of the new zone, instead of the one you came from?

    Slightly related, I found the PLAYER_ENTERING_BATTLEGROUND event, but is there a way to detect when the player leaves the battleground? I know PLAYER_ENTERING_WORLD is fired when leaving a battleground, but that gets fired loads of times, I only care about it when it is fired from leaving a battleground, not /reload, first log in, entering a raid or dungeon, etc.
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  2. #2

  3. #3
    Zone changed worked like a charm. I also solved my second problem. Just set a bool to true when the PLAYER_ENTERING_BATTLEGROUND was called and used that to check the PLAYER_ENTERING_WORLD event
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  4. #4
    Does this let you see what Bg you're going to enter if it's random? If not, is there a way to do that?
    *Serious face... fist in air.*

  5. #5
    This waits until the BG loads before getting the name, so it knows what BG the random is at the same time you do.
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  6. #6
    Deleted
    If you can't be bothered to localize battleground zone names for every language (or use LibBabble), you can also work with GetBattlefieldStatus, which should fire UPDATE_BATTLEFIELD_STATUS when its returns change.

  7. #7
    Quote Originally Posted by Treeston View Post
    If you can't be bothered to localize battleground zone names for every language (or use LibBabble), you can also work with GetBattlefieldStatus, which should fire UPDATE_BATTLEFIELD_STATUS when its returns change.
    That would probably work much better, I only care when they are actually in the BG, so would I be correct in checking GetBattlefieldStatus(1) where param1 is 'active' on a firing of UPDATE_BATTLEFIELD_STATUS? I'm assuming the active BG will always be index 1 since they can only be in one battleground.

    Also, does this localize the name automatically? To be honest I had completely forgotten about localization.

    I realize my explanation may not make the most sense. In pseudocode:

    Code:
    local bgName
    if event == 'UPDATE_BATTLEFIELD_STATUS then
        local status, name = GetBattlefieldStatus(1)
        if status == 'active' then
            bgName = name
        end
    end
    Last edited by Arcilux; 2011-08-02 at 07:53 PM.
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  8. #8
    Deleted
    I wouldn't be sure that queue 1 is always the active BG.
    Code:
    if event == 'UPDATE_BATTLEFIELD_STATUS' then
        local bgName
        for q=1, MAX_BATTLEFIELD_QUEUES do
            local s,n,_,_,_,t =  GetBattlefieldStatus(q)
            if (s == 'active') and (t == 0) then -- you can leave out the second part if you want to check for arena matches, too
                bgName = n
                break
            end
        end
        if bgName then
             -- do something because player is in a BG
        end
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •