Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit 0f9db3f

Browse files
committed
[Fixe] There seems to be a 50 bot limit (5 pages) for the guild roster
1 parent 11674a8 commit 0f9db3f

2 files changed

Lines changed: 123 additions & 34 deletions

File tree

Core/MultiBotHandler.lua

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -472,22 +472,31 @@ MultiBot:SetScript("OnEvent", function()
472472
and MultiBot.frames["MultiBar"].frames["Units"]) then
473473
-- UI pas encore prête : on re-propulse le même event vers NOTRE OnEvent
474474
local saved_msg = arg1
475-
local df = CreateFrame("Frame")
476-
df.t = 0
477-
df:SetScript("OnUpdate", function(self, elapsed)
478-
self.t = self.t + elapsed
479-
if self.t > 0.2 then
480-
self:SetScript("OnUpdate", nil)
481-
local onEvent = MultiBot:GetScript("OnEvent")
482-
if onEvent then
483-
-- Sauvegarde/restaure les globals d’événement
484-
local _event, _arg1 = event, arg1
485-
event, arg1 = "CHAT_MSG_SYSTEM", saved_msg
486-
onEvent()
487-
event, arg1 = _event, _arg1
488-
end
475+
476+
local function ReDispatchRoster()
477+
local onEvent = MultiBot:GetScript("OnEvent")
478+
if onEvent then
479+
-- Sauvegarde/restaure les globals d’événement
480+
local _event, _arg1 = event, arg1
481+
event, arg1 = "CHAT_MSG_SYSTEM", saved_msg
482+
onEvent()
483+
event, arg1 = _event, _arg1
489484
end
490-
end)
485+
end
486+
487+
if type(TimerAfter) == "function" then
488+
TimerAfter(0.2, ReDispatchRoster)
489+
else
490+
local df = CreateFrame("Frame")
491+
df.t = 0
492+
df:SetScript("OnUpdate", function(self, elapsed)
493+
self.t = self.t + elapsed
494+
if self.t > 0.2 then
495+
self:SetScript("OnUpdate", nil)
496+
ReDispatchRoster()
497+
end
498+
end)
499+
end
491500
return
492501
end
493502

@@ -560,7 +569,7 @@ MultiBot:SetScript("OnEvent", function()
560569
-- Filtre de sécurité :
561570
-- - pas de nom vide
562571
-- - pas de classe inconnue => on évite les boutons Unknown
563-
if botName ~= "" and botClass ~= "Unknown" then
572+
if botName ~= "" and botClass and botClass ~= "Unknown" then
564573
local botButton = MultiBot.addPlayer(botClass, botName).setDisable()
565574

566575
botButton.doRight = function(pButton)
@@ -628,12 +637,14 @@ MultiBot:SetScript("OnEvent", function()
628637
end
629638

630639
-- MEMBERBOTS --
631-
for i = 1, 50 do
632-
--local tName, tRank, tIndex, tLevel, tClass = GetGuildRosterInfo(i)
640+
--for i = 1, 50 do
641+
local tGuildCount = 0
642+
if type(GetNumGuildMembers) == "function" then
643+
tGuildCount = select(1, GetNumGuildMembers()) or 0
644+
end
645+
local memberLoopMax = (tGuildCount > 0) and tGuildCount or 50
633646

634-
-- Ensure that the Counter is not bigger than the Amount of Members in Guildlist
635-
--if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
636-
--local tMember = MultiBot.addMember(tClass, tLevel, tName).setDisable()
647+
for i = 1, memberLoopMax do
637648
local memberName, _, _, memberLevel, memberClass = GetGuildRosterInfo(i)
638649

639650
-- Ensure that the Counter is not bigger than the Amount of Members in Guildlist
@@ -661,13 +672,14 @@ MultiBot:SetScript("OnEvent", function()
661672
end
662673

663674
-- FRIENDBOTS --
664-
for i = 1, 50 do
665-
--local tName, tLevel, tClass = GetFriendInfo(i)
666-
667-
-- Ensure that the Counter is not bigger than the Amount of Members in Friendlist
668-
--if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
669-
--local tFriend = MultiBot.addFriend(tClass, tLevel, tName).setDisable()
675+
--for i = 1, 50 do
676+
local tFriendCount = 0
677+
if type(GetNumFriends) == "function" then
678+
tFriendCount = GetNumFriends() or 0
679+
end
680+
local friendLoopMax = (tFriendCount > 0) and tFriendCount or 50
670681

682+
for i = 1, friendLoopMax do
671683
local friendName, friendLevel, friendClass = GetFriendInfo(i)
672684

673685
-- Ensure that the Counter is not bigger than the Amount of Members in Friendlist
@@ -1186,7 +1198,14 @@ MultiBot:SetScript("OnEvent", function()
11861198
local tLevel = ""
11871199
local tClass = ""
11881200

1189-
for i = 1, 50 do
1201+
--for i = 1, 50 do
1202+
local tFriendScanCount = 0
1203+
if type(GetNumFriends) == "function" then
1204+
tFriendScanCount = GetNumFriends() or 0
1205+
end
1206+
local friendScanMax = (tFriendScanCount > 0) and tFriendScanCount or 50
1207+
1208+
for i = 1, friendScanMax do
11901209
tName, tLevel, tClass = GetFriendInfo(i)
11911210
if(tName == arg2) then break end
11921211
if(tName == nil) then break end

Core/MultiBotInit.lua

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,14 @@ tButton.roster = "players"
693693
tButton.filter = "none"
694694

695695
tButton.doRight = function(pButton)
696+
local isGuildRetry = pButton._guildRosterRetrying == true
697+
pButton._guildRosterRetrying = false
698+
local retryCount = tonumber(pButton._guildRosterRetryCount) or 0
699+
if not isGuildRetry then
700+
retryCount = 0
701+
end
702+
local needGuildRetry = false
703+
696704
--[[ -- MEMBERBOTS --
697705
698706
for i = 1, 50 do
@@ -761,6 +769,14 @@ tButton.doRight = function(pButton)
761769
pButton.doLeft(pButton, pButton.roster, pButton.filter)]]--
762770

763771
-- Always refresh guild/friend rosters so their indexes stay in sync
772+
local prevShowOffline = nil
773+
if type(GetGuildRosterShowOffline) == "function" and type(SetGuildRosterShowOffline) == "function" then
774+
prevShowOffline = GetGuildRosterShowOffline()
775+
if prevShowOffline == false then
776+
SetGuildRosterShowOffline(true)
777+
end
778+
end
779+
764780
if(type(GuildRoster) == "function") then GuildRoster() end
765781
if(type(ShowFriends) == "function") then ShowFriends() end
766782

@@ -771,10 +787,30 @@ tButton.doRight = function(pButton)
771787
MultiBot.index.classes.friends = {}
772788

773789
-- MEMBERBOTS --
774-
local tMaxMembers = type(GetNumGuildMembers) == "function" and GetNumGuildMembers() or 50
790+
local inGuild = false
791+
if type(IsInGuild) == "function" then
792+
inGuild = IsInGuild()
793+
elseif type(GetGuildInfo) == "function" then
794+
inGuild = (GetGuildInfo("player") ~= nil)
795+
end
796+
797+
local tMaxMembers = 0
798+
if type(GetNumGuildMembers) == "function" then
799+
tMaxMembers = select(1, GetNumGuildMembers()) or 0
800+
end
801+
tMaxMembers = tonumber(tMaxMembers) or 0
802+
if tMaxMembers <= 0 then
803+
tMaxMembers = 50
804+
if inGuild then
805+
needGuildRetry = true
806+
end
807+
end
808+
809+
local guildCount = 0
775810
for i = 1, tMaxMembers do
776811
local tName, _, _, tLevel, tClass = GetGuildRosterInfo(i)
777812
if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
813+
guildCount = guildCount + 1
778814
local tMember = MultiBot.addMember(tClass, tLevel, tName)
779815
if(tMember.state == false) then
780816
tMember.setDisable()
@@ -797,13 +833,43 @@ tButton.doRight = function(pButton)
797833
pButton.setEnable()
798834
end
799835
end
800-
elseif(tName == nil) then
836+
elseif(tName == nil or tLevel == nil or tClass == nil) then
837+
if inGuild and i < tMaxMembers then
838+
needGuildRetry = true
839+
end
801840
break
802841
end
803842
end
804843

844+
if prevShowOffline == false and type(SetGuildRosterShowOffline) == "function" then
845+
SetGuildRosterShowOffline(false)
846+
end
847+
848+
if not isGuildRetry and inGuild and tMaxMembers == 50 and guildCount == 50 then
849+
needGuildRetry = true
850+
end
851+
852+
if (not isGuildRetry) and needGuildRetry and type(TimerAfter) == "function" and retryCount < 6 then
853+
pButton._guildRosterRetryCount = retryCount + 1
854+
pButton._guildRosterRetrying = true
855+
TimerAfter(0.25, function()
856+
if pButton and pButton.doRight then
857+
pButton.doRight(pButton)
858+
end
859+
end)
860+
else
861+
pButton._guildRosterRetryCount = 0
862+
end
863+
805864
-- FRIENDBOTS --
806-
local tMaxFriends = type(GetNumFriends) == "function" and GetNumFriends() or 50
865+
local tMaxFriends = 0
866+
if type(GetNumFriends) == "function" then
867+
tMaxFriends = GetNumFriends() or 0
868+
end
869+
tMaxFriends = tonumber(tMaxFriends) or 0
870+
if tMaxFriends <= 0 then
871+
tMaxFriends = 50
872+
end
807873
for i = 1, tMaxFriends do
808874
local tName, tLevel, tClass = GetFriendInfo(i)
809875
if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then
@@ -829,20 +895,22 @@ tButton.doRight = function(pButton)
829895
pButton.setEnable()
830896
end
831897
end
832-
elseif(tName == nil) then
833-
break
898+
--elseif(tName == nil) then
899+
--break
900+
elseif(tName == nil or tLevel == nil or tClass == nil) then
901+
needGuildRetry = true
834902
end
835903
end
836904

837905
-- Roster requiring server feedback (players/actives/favorites)
906+
if not isGuildRetry then
838907
local tRoster = pButton.roster or "players"
839908
if(tRoster == "players" or tRoster == "actives" or tRoster == "favorites") then
840909
SendChatMessage(".playerbot bot list", "SAY")
841910
if(tRoster == "favorites" and MultiBot.UpdateFavoritesIndex ~= nil) then
842911
MultiBot.UpdateFavoritesIndex()
843912
end
844913
end
845-
846914
-- Pour les bots déjà groupés : relance un cycle "co ?" afin qu'ils renvoient leurs stratégies
847915
local function RefreshStrategiesFor(name)
848916
if not name or name == UnitName("player") then return end
@@ -890,6 +958,8 @@ tButton.doRight = function(pButton)
890958
end
891959
end
892960

961+
end
962+
893963
pButton.doLeft(pButton, pButton.roster, pButton.filter)
894964

895965
if type(TimerAfter) == "function" then

0 commit comments

Comments
 (0)