Even with a 5-second zo_callLater() delay between calls, attempting any automation of guild ranks leads to the dreaded kick from server for message spam, followed by "Error 307 Booted from server" for ten minutes.
Is this API even callable at all? If a 5-second delay still triggers the ban, I'm not about to attempt it again even with 10 seconds between calls. How does the UI itself avoid a ban (because I could certainly manually promote/demote more than 1 player every 5 seconds).
I've got a couple dozen promotions/demotions pending in my 500-member guild, and not about to spend hours doing them manually.
--Z
Lua Code:
function ZZGuildRank.DoSome()
self = ZZGuildRank
local i = #self.queue
assert(0 < i)
local record_str = table.remove(self.queue,i)
local w = split(record_str, "\t")
local want_rank = tonumber(w[1])
local player_name = w[2]
self:SetRank(player_name, want_rank, i)
self:DoSomeLater()
end
function ZZGuildRank:DoSomeLater()
if #self.queue <= 0 then
d("ZZGuildRank: Done.")
return
end
-- 500, 1000, even 5000 too fast!
-- cause server kick, dreaded
-- "Error 307 Booted from Server" 15-minute softban
zo_callLater(function() ZZGuildRank.DoSome() end, 10 * 1000)
end
function ZZGuildRank:SetRank(player_name, want_rank, queue_index)
local member_info = self.guild[player_name]
if not member_info then
d("ZZGuildRank: not a member:"..player_name)
return
end
if member_info.curr_rank_index == want_rank then
d("ZZGuildRank: already rank "..tostring(want_rank).." "..player_name)
return
end
local step = 1
local func = GuildDemote
if want_rank < member_info.curr_rank_index then
step = -1
func = GuildPromote
end
for rank = member_info.curr_rank_index+step, want_rank, step do
d(string.format("|ceeeeee%d: rank:%d %s|r",queue_index, rank, player_name))
func(GUILD_INDEX, player_name)
end
end