Thread Tools Display Modes
07-28-08, 02:39 AM   #1
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
How to tell you're in a BG

I need to tell, within an addon, whether you're in a BG or not.

I didn't want to faff-about with zone names - those being localised etc. - so I hunted around the API and found this

GetBattlefieldInstanceRunTime()

It's SUPPOSED to report the instance's runtime in ms - and mostly that's what it does - however it also reports '0' quite often - so it's not a great deal of use!!

I'm assuming this relates to the way that 'Run Time' on the scoresheet is often blank - e.g. it's a server 'issue'.

Are there any other easy/sure-fire ways to detect whether you're in a BG without resorting to crude things like the zone name?

I wondered about querying things like the scores - but as they are often not available within BGs for long periods I guess they're also prone to 'server issues'???
  Reply With Quote
07-28-08, 02:46 AM   #2
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 26
To determinate that your are in an active Battlefield you can query your battlefield queues for an active status:

http://www.wowwiki.com/API_GetBattlefieldStatus

this should allways work
  Reply With Quote
07-28-08, 02:50 AM   #3
Soulsbane
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 7
do something like

Code:
if select(2, IsInInstance()) == "pvp" then
-- Do stuff
end
  Reply With Quote
07-28-08, 03:21 AM   #4
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Originally Posted by Macniel View Post
To determinate that your are in an active Battlefield you can query your battlefield queues for an active status:

http://www.wowwiki.com/API_GetBattlefieldStatus

this should allways work
I tried (something close to) this earlier - as a brute-force test of that - and it failed completely...

for x in 1,3 do -- upto 3 queus possible
If GetBattlefieldStatus(x) then DEFAULT_CHAT_FRAME:AddMessage("YO"); end;
end;

It returned nothing whatsoever DESPITE me being in AV and the queues for AB and EOTS which suggests it's as prone to returning nonsense/nothing as the GetBattlefieldInstanceRunTime() call...
  Reply With Quote
07-28-08, 03:30 AM   #5
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Originally Posted by Soulsbane View Post
do something like

Code:
if select(2, IsInInstance()) == "pvp" then
-- Do stuff
end
I like the sound of that because it's not the GetBattlefield... functions which are - it would appear - heavily unreliable

Thanks!
  Reply With Quote
07-28-08, 06:11 AM   #6
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 26
Originally Posted by kerrang View Post
I tried (something close to) this earlier - as a brute-force test of that - and it failed completely...

for x in 1,3 do -- upto 3 queus possible
If GetBattlefieldStatus(x) then DEFAULT_CHAT_FRAME:AddMessage("YO"); end;
end;

It returned nothing whatsoever DESPITE me being in AV and the queues for AB and EOTS which suggests it's as prone to returning nonsense/nothing as the GetBattlefieldInstanceRunTime() call...
This is very odd, As I joined an EotS Battleifled and dumped GetBattelFieldStatus(1) (it was the only queue I joined in fact) i got the values : "active", "Auge des Sturms", 70, 70, 15, nil back
  Reply With Quote
07-28-08, 11:01 AM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Soulsbane View Post
do something like

Code:
if select(2, IsInInstance()) == "pvp" then
-- Do stuff
end
this is usually what's suggested/used.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-28-08, 12:16 PM   #8
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
IsInInstance is cool because you can detect wether you are in BG "pvp" arenas "arena" or in pve instances "raid" & "party" only with it.
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)
  Reply With Quote
07-28-08, 01:06 PM   #9
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Originally Posted by Macniel View Post
This is very odd, As I joined an EotS Battleifled and dumped GetBattelFieldStatus(1) (it was the only queue I joined in fact) i got the values : "active", "Auge des Sturms", 70, 70, 15, nil back
I've used GetBattlefieldInstanceRunTime() for a while and it's generally worked aok.

Something was breaking my 'BG detector' from time-to-time tho - and extensive monitoring of the values it was checking shows that function can report 0 even in a BG for extended periods of time - even across multiple BGs/queues - which suggests it's something on the server-side which is being disabled/failing perhaps?

I've had a few BGs recently which reported no Elapsed/Total time - I've had several occasions where the scores could not be shown mid-game too - so I guess it's a "load" issue of some sort?

IsInInstance is working very well so far tho - seems a much more reliable test...
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to tell you're in a BG


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off