From 0f9db3f0ae3aae2e52d0010fd3162ba697f1e111 Mon Sep 17 00:00:00 2001 From: Wishmaster117 <140754794+Wishmaster117@users.noreply.github.com> Date: Thu, 25 Dec 2025 03:36:27 +0000 Subject: [PATCH] [Fixe] There seems to be a 50 bot limit (5 pages) for the guild roster --- Core/MultiBotHandler.lua | 75 ++++++++++++++++++++++-------------- Core/MultiBotInit.lua | 82 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 123 insertions(+), 34 deletions(-) diff --git a/Core/MultiBotHandler.lua b/Core/MultiBotHandler.lua index 812915a..18b80b0 100644 --- a/Core/MultiBotHandler.lua +++ b/Core/MultiBotHandler.lua @@ -472,22 +472,31 @@ MultiBot:SetScript("OnEvent", function() and MultiBot.frames["MultiBar"].frames["Units"]) then -- UI pas encore prête : on re-propulse le même event vers NOTRE OnEvent local saved_msg = arg1 - local df = CreateFrame("Frame") - df.t = 0 - df:SetScript("OnUpdate", function(self, elapsed) - self.t = self.t + elapsed - if self.t > 0.2 then - self:SetScript("OnUpdate", nil) - local onEvent = MultiBot:GetScript("OnEvent") - if onEvent then - -- Sauvegarde/restaure les globals d’événement - local _event, _arg1 = event, arg1 - event, arg1 = "CHAT_MSG_SYSTEM", saved_msg - onEvent() - event, arg1 = _event, _arg1 - end + + local function ReDispatchRoster() + local onEvent = MultiBot:GetScript("OnEvent") + if onEvent then + -- Sauvegarde/restaure les globals d’événement + local _event, _arg1 = event, arg1 + event, arg1 = "CHAT_MSG_SYSTEM", saved_msg + onEvent() + event, arg1 = _event, _arg1 end - end) + end + + if type(TimerAfter) == "function" then + TimerAfter(0.2, ReDispatchRoster) + else + local df = CreateFrame("Frame") + df.t = 0 + df:SetScript("OnUpdate", function(self, elapsed) + self.t = self.t + elapsed + if self.t > 0.2 then + self:SetScript("OnUpdate", nil) + ReDispatchRoster() + end + end) + end return end @@ -560,7 +569,7 @@ MultiBot:SetScript("OnEvent", function() -- Filtre de sécurité : -- - pas de nom vide -- - pas de classe inconnue => on évite les boutons Unknown - if botName ~= "" and botClass ~= "Unknown" then + if botName ~= "" and botClass and botClass ~= "Unknown" then local botButton = MultiBot.addPlayer(botClass, botName).setDisable() botButton.doRight = function(pButton) @@ -628,12 +637,14 @@ MultiBot:SetScript("OnEvent", function() end -- MEMBERBOTS -- - for i = 1, 50 do - --local tName, tRank, tIndex, tLevel, tClass = GetGuildRosterInfo(i) + --for i = 1, 50 do + local tGuildCount = 0 + if type(GetNumGuildMembers) == "function" then + tGuildCount = select(1, GetNumGuildMembers()) or 0 + end + local memberLoopMax = (tGuildCount > 0) and tGuildCount or 50 - -- Ensure that the Counter is not bigger than the Amount of Members in Guildlist - --if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then - --local tMember = MultiBot.addMember(tClass, tLevel, tName).setDisable() + for i = 1, memberLoopMax do local memberName, _, _, memberLevel, memberClass = GetGuildRosterInfo(i) -- Ensure that the Counter is not bigger than the Amount of Members in Guildlist @@ -661,13 +672,14 @@ MultiBot:SetScript("OnEvent", function() end -- FRIENDBOTS -- - for i = 1, 50 do - --local tName, tLevel, tClass = GetFriendInfo(i) - - -- Ensure that the Counter is not bigger than the Amount of Members in Friendlist - --if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then - --local tFriend = MultiBot.addFriend(tClass, tLevel, tName).setDisable() + --for i = 1, 50 do + local tFriendCount = 0 + if type(GetNumFriends) == "function" then + tFriendCount = GetNumFriends() or 0 + end + local friendLoopMax = (tFriendCount > 0) and tFriendCount or 50 + for i = 1, friendLoopMax do local friendName, friendLevel, friendClass = GetFriendInfo(i) -- Ensure that the Counter is not bigger than the Amount of Members in Friendlist @@ -1186,7 +1198,14 @@ MultiBot:SetScript("OnEvent", function() local tLevel = "" local tClass = "" - for i = 1, 50 do + --for i = 1, 50 do + local tFriendScanCount = 0 + if type(GetNumFriends) == "function" then + tFriendScanCount = GetNumFriends() or 0 + end + local friendScanMax = (tFriendScanCount > 0) and tFriendScanCount or 50 + + for i = 1, friendScanMax do tName, tLevel, tClass = GetFriendInfo(i) if(tName == arg2) then break end if(tName == nil) then break end diff --git a/Core/MultiBotInit.lua b/Core/MultiBotInit.lua index b8a3443..5752a23 100644 --- a/Core/MultiBotInit.lua +++ b/Core/MultiBotInit.lua @@ -693,6 +693,14 @@ tButton.roster = "players" tButton.filter = "none" tButton.doRight = function(pButton) + local isGuildRetry = pButton._guildRosterRetrying == true + pButton._guildRosterRetrying = false + local retryCount = tonumber(pButton._guildRosterRetryCount) or 0 + if not isGuildRetry then + retryCount = 0 + end + local needGuildRetry = false + --[[ -- MEMBERBOTS -- for i = 1, 50 do @@ -761,6 +769,14 @@ tButton.doRight = function(pButton) pButton.doLeft(pButton, pButton.roster, pButton.filter)]]-- -- Always refresh guild/friend rosters so their indexes stay in sync + local prevShowOffline = nil + if type(GetGuildRosterShowOffline) == "function" and type(SetGuildRosterShowOffline) == "function" then + prevShowOffline = GetGuildRosterShowOffline() + if prevShowOffline == false then + SetGuildRosterShowOffline(true) + end + end + if(type(GuildRoster) == "function") then GuildRoster() end if(type(ShowFriends) == "function") then ShowFriends() end @@ -771,10 +787,30 @@ tButton.doRight = function(pButton) MultiBot.index.classes.friends = {} -- MEMBERBOTS -- - local tMaxMembers = type(GetNumGuildMembers) == "function" and GetNumGuildMembers() or 50 + local inGuild = false + if type(IsInGuild) == "function" then + inGuild = IsInGuild() + elseif type(GetGuildInfo) == "function" then + inGuild = (GetGuildInfo("player") ~= nil) + end + + local tMaxMembers = 0 + if type(GetNumGuildMembers) == "function" then + tMaxMembers = select(1, GetNumGuildMembers()) or 0 + end + tMaxMembers = tonumber(tMaxMembers) or 0 + if tMaxMembers <= 0 then + tMaxMembers = 50 + if inGuild then + needGuildRetry = true + end + end + + local guildCount = 0 for i = 1, tMaxMembers do local tName, _, _, tLevel, tClass = GetGuildRosterInfo(i) if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then + guildCount = guildCount + 1 local tMember = MultiBot.addMember(tClass, tLevel, tName) if(tMember.state == false) then tMember.setDisable() @@ -797,13 +833,43 @@ tButton.doRight = function(pButton) pButton.setEnable() end end - elseif(tName == nil) then + elseif(tName == nil or tLevel == nil or tClass == nil) then + if inGuild and i < tMaxMembers then + needGuildRetry = true + end break end end + if prevShowOffline == false and type(SetGuildRosterShowOffline) == "function" then + SetGuildRosterShowOffline(false) + end + + if not isGuildRetry and inGuild and tMaxMembers == 50 and guildCount == 50 then + needGuildRetry = true + end + + if (not isGuildRetry) and needGuildRetry and type(TimerAfter) == "function" and retryCount < 6 then + pButton._guildRosterRetryCount = retryCount + 1 + pButton._guildRosterRetrying = true + TimerAfter(0.25, function() + if pButton and pButton.doRight then + pButton.doRight(pButton) + end + end) + else + pButton._guildRosterRetryCount = 0 + end + -- FRIENDBOTS -- - local tMaxFriends = type(GetNumFriends) == "function" and GetNumFriends() or 50 + local tMaxFriends = 0 + if type(GetNumFriends) == "function" then + tMaxFriends = GetNumFriends() or 0 + end + tMaxFriends = tonumber(tMaxFriends) or 0 + if tMaxFriends <= 0 then + tMaxFriends = 50 + end for i = 1, tMaxFriends do local tName, tLevel, tClass = GetFriendInfo(i) if(tName ~= nil and tLevel ~= nil and tClass ~= nil and tName ~= UnitName("player")) then @@ -829,12 +895,15 @@ tButton.doRight = function(pButton) pButton.setEnable() end end - elseif(tName == nil) then - break + --elseif(tName == nil) then + --break + elseif(tName == nil or tLevel == nil or tClass == nil) then + needGuildRetry = true end end -- Roster requiring server feedback (players/actives/favorites) + if not isGuildRetry then local tRoster = pButton.roster or "players" if(tRoster == "players" or tRoster == "actives" or tRoster == "favorites") then SendChatMessage(".playerbot bot list", "SAY") @@ -842,7 +911,6 @@ tButton.doRight = function(pButton) MultiBot.UpdateFavoritesIndex() end end - -- Pour les bots déjà groupés : relance un cycle "co ?" afin qu'ils renvoient leurs stratégies local function RefreshStrategiesFor(name) if not name or name == UnitName("player") then return end @@ -890,6 +958,8 @@ tButton.doRight = function(pButton) end end + end + pButton.doLeft(pButton, pButton.roster, pButton.filter) if type(TimerAfter) == "function" then