WoW:API JoinBattlefield: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(→‎Example: + loud errors on serial calls.)
Line 1: Line 1:
{{wowapi}}
{{wowapi}} __NOTOC__
Queues the player, or the players group for a battlefield.
Queues the player, or the player's group, for a battlefield instance.
JoinBattlefield(index[, asGroup[, isRated]])


JoinBattlefield(index, joinAs, isRated)
== Arguments ==
;index : Number - Which battlefield instance to queue for (0 for first available), or which arena bracket to queue for.
;asGroup : Boolean - If true-equivalent, the player's group is queued for the battlefield, otherwise, only the player is queued.
;isRated : Boolean - If true-equivalent, and queueing for an arena bracket, the group is queued for a rated match as opposed to a skirmish.


== Parameters ==
== Details ==
=== Arguments ===
The function requests the player to be added to a queue for a particular instance of the currently selected battleground type, as set by {{api|RequestBattlegroundInstanceInfo}}(index). You CANNOT queue immediately after a {{api|RequestBattlegroundInstanceInfo}} call, and must instead capture the event that indicates that the instance list is available.
:index, joinAs, isRated


:;index : Integer - Which battlefield instance to queue for (0 for first available), or which arena bracket to queue for
== Example ==
:;joinAs : Integer - Queue as a group
The following code creates a utility function, JoinBattlegroundType, which allows you to queue for the first available instance of a specific battleground type.
:;isRated : Integer - Queues for a rated arena
do
 
  local f, aG, iR = CreateFrame("FRAME");
----
  f:SetScript("OnEvent", function(self, event)
=== Details ===
  JoinBattlefield(0, aG, iR);
Queues the player for the current battlefield they have open. When the Arena Battlemaster window is open, index 1 is 2vs2, index 2 is 3vs3 and index 3 is 5vs5, if you pass the "isRated" flag it'll queue for a rated arena, if you don't it'll queue for a Skirmish arena.
  self:UnregisterEvent("PVPQUEUE_ANYWHERE_SHOW");
 
  end);
[[Patch 2.0.3]] You can no longer queue a group for Alterac Valley, and if the battlefield window is closed it won't queue you for the last opened battlefield. Because of this, it's possible to do send a JoinBattlefield request and then not be queued if you jump away too quickly and close the window.
  function JoinBattlegroundType(index, asGroup, isRated)
 
  if f:IsEventRegistered("PVPQUEUE_ANYWHERE_SHOW") then
[[Patch 2.4.0]] Queuing for Alterac Valley as a group is back
    error("A join battleground request is already being processed");
----
   end
 
   f:RegisterEvent("PVPQUEUE_ANYWHERE_SHOW");
=== Example ===
   aG, iR = asGroup, isRated;
Queue the players group for the battlefield window open.
   RequestBattlegroundInstanceInfo(index);
 
  end
if( CanJoinBattlefieldAsGroup() ) then
   -- Queue as a group for the first available battleground
   JoinBattlefield(0, 1);
else
   -- Solo queue for the first available battleground
   JoinBattlefield(0);
  end
  end
Queue the players group for a rated 3vs3 arena.
JoinBattlefield(2, 1, 1);
Queue solo for 2v2 skirmish.
/script JoinBattlefield(1, 0, 0)
Queue solo for open BG window, make sure you see a little flash on your BG queue minimap icon or hear a little ding.


/script JoinBattlefield(0)
== Notes ==
* When the Arena Battlemaster window is open, index 1 is 2vs2, index 2 is 3vs3 and index 3 is 5vs5.


__NOTOC__
== See Also ==
* {{api|CanJoinBattlefieldAsGroup}}

Revision as of 12:58, 21 August 2009

WoW API < JoinBattlefield

Queues the player, or the player's group, for a battlefield instance.

JoinBattlefield(index[, asGroup[, isRated]])

Arguments

index
Number - Which battlefield instance to queue for (0 for first available), or which arena bracket to queue for.
asGroup
Boolean - If true-equivalent, the player's group is queued for the battlefield, otherwise, only the player is queued.
isRated
Boolean - If true-equivalent, and queueing for an arena bracket, the group is queued for a rated match as opposed to a skirmish.

Details

The function requests the player to be added to a queue for a particular instance of the currently selected battleground type, as set by RequestBattlegroundInstanceInfo(index). You CANNOT queue immediately after a RequestBattlegroundInstanceInfo call, and must instead capture the event that indicates that the instance list is available.

Example

The following code creates a utility function, JoinBattlegroundType, which allows you to queue for the first available instance of a specific battleground type.

do
 local f, aG, iR = CreateFrame("FRAME");
 f:SetScript("OnEvent", function(self, event)
  JoinBattlefield(0, aG, iR);
  self:UnregisterEvent("PVPQUEUE_ANYWHERE_SHOW");
 end);
 function JoinBattlegroundType(index, asGroup, isRated)
  if f:IsEventRegistered("PVPQUEUE_ANYWHERE_SHOW") then
   error("A join battleground request is already being processed");
  end
  f:RegisterEvent("PVPQUEUE_ANYWHERE_SHOW");
  aG, iR = asGroup, isRated;
  RequestBattlegroundInstanceInfo(index);
 end
end

Notes

  • When the Arena Battlemaster window is open, index 1 is 2vs2, index 2 is 3vs3 and index 3 is 5vs5.

See Also