WoW:API JoinBattlefield: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (Move page script moved page API JoinBattlefield to API JoinBattlefield without leaving a redirect)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{wowapi}}
{{wowapi}} __NOTOC__
Queues the player for a battleground
Queues the player, or the player's group, for a battlefield instance.
  JoinBattlefield(index[, asGroup[, isRated]])
  JoinBattlefield(index,joinAs)


== Parameters ==
== Arguments ==
=== Arguments ===
;index : Number - Which battlefield instance to queue for (0 for first available), or which arena bracket to queue for.
:index, joinAs
;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.


:;index : Integer - Which battlefield index to queue for ( 0 for the first available )
== Details ==
;:joinAs : Integer - Queue as a group or queue solo ( nil for solo; 1 for group )
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.


----
== Example ==
=== Details ===
The following code creates a utility function, JoinBattlegroundType, which allows you to queue for the first available instance of a specific battleground type.
Queue the player for the current battleground instance list you are viewing, if a window isn't opened it will use the last one you had opened.
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


----
=== Example ===
Queue as a group if the battleground will allow it, which is currently everything except [[Alterac Valley]].


if( CanJoinBattlefieldAsGroup() ) then
The following will queue you for Skirmish 2v2 if not in a group.
  -- Queue as a group for the first available battleground
  JoinBattlefield(0, 1);
  /script JoinBattlefield(1)
  else
  -- Solo queue for the first available battleground
  JoinBattlefield(0);
end


''Note: JoinBattlefield(0, 1) when the most recent BG talked to was AV will indeed queue the full group for AV, but not strictly as a group - it will behave similarly as if everybody had individually queued.  It's not clear if this is the intended effect.''
== 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}}

Latest revision as of 04:46, 15 August 2023

WoW API < JoinBattlefield

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

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

Arguments[edit]

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[edit]

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[edit]

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


The following will queue you for Skirmish 2v2 if not in a group.

/script JoinBattlefield(1)

Notes[edit]

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

See Also[edit]