Monday, April 16, 2012

Auto joining Battlegrounds

Hello all,

I have picked up someones addon that hasn't been updated in over a year, the addon still works ok but this feature just doesn't seem to want to work.


Code:
function TitanPanelHGrindButton_CheckBGConfirm()
local status, index;
local autoJoin = TitanGetVar(TITAN_HGRIND_ID, "AutoJoinBG");
for i=1,4 do
status,_,_ = GetBattlefieldStatus(i);
if(status == "confirm") then
index = i;
--DEFAULT_CHAT_FRAME:AddMessage(status.." "..index);
break
end
end

if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 19) then DEFAULT_CHAT_FRAME:AddMessage("20...", 1, 1, 0) end
if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 9) then DEFAULT_CHAT_FRAME:AddMessage("10...", 1, 1, 0) end
if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 4) then DEFAULT_CHAT_FRAME:AddMessage("5...", 1, 1, 0) end
if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 3) then DEFAULT_CHAT_FRAME:AddMessage("4...", 1, 1, 0) end
if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 2) then DEFAULT_CHAT_FRAME:AddMessage("3...", 1, 1, 0) end
if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 1) then DEFAULT_CHAT_FRAME:AddMessage("2...", 1, 1, 0) end
if (math.floor(TITAN_HGRIND_BGCONFIRM - GetTime()) == 0) then DEFAULT_CHAT_FRAME:AddMessage("1...", 1, 1, 0) end

if ((status == "confirm") and (autoJoin == 1)) then
if (StaticPopup_Visible("CONFIRM_BATTLEFIELD_ENTRY")) then
if (TITAN_HGRIND_BGCONFIRM == 0) then
DEFAULT_CHAT_FRAME:AddMessage(TITAN_HGRIND_MAJ, 1, 1, 0);
TITAN_HGRIND_BGCONFIRM = GetTime() + 30;
elseif (GetTime() > TITAN_HGRIND_BGCONFIRM) then
TITAN_HGRIND_BGCONFIRM = 0;
if UnitIsAFK("player") then
DEFAULT_CHAT_FRAME:AddMessage(TITAN_HGRIND_CANCELAJ, 1, 1, 0);
else
DEFAULT_CHAT_FRAME:AddMessage(TITAN_HGRIND_MAJNOW, 1, 1, 0);
AcceptBattlefieldPort(index,1)
StaticPopup_Hide("CONFIRM_BATTLEFIELD_ENTRY");
end
end
end
end
end

I am new to the addon creating so I am not sure yet how to fix it, can anyone help. Its meant to, if you have auto join enabled, it auto joins the BG after 30 seonds (I am trying to cut it down in time) but testing it as I got the addon, it just doesn't bother to join.

Thanks in advance,

Doomie|||does it do all the chat messages?

Apparently it should say the contents of the TITAN_HGRIND_MAJ-textstring.

Then at 20/10/5/4/3/2/1 seconds remaining it should give another chatmsg.

Then at 0 seconds remaining it should say something like

"You're AFK, cancelling" if you're AFK at that moment

or

"Joining BG" if not.

If it's not doing any of those messages then that means the TitanPanelHGrindButton_CheckBGConfirm() function is never called and we need to see the calling piece of code.

If it IS doing those messages... well, I reviewed how the AcceptBattlefieldPort()-API function works and I can't see anything wrong.

One tip is checking how other addons do it... AlarBGHelper from http://files.wowace.com might do the same thing ?|||Right, checked the messages it comes up with.

TITAN_HGRIND_MAJ = "Auto-Joining BG in 30 seconds.";

This one fires ok but then nothing else happens I get no countdown or anything. Now I have other mods but not BG ones but I have Deadly Boss Mod which does the timers, could this be doing it in?

Thanks

Doomie

No comments:

Post a Comment