Hi all. I wrote a code in which the automatic acceptance and delivery of quests 77244 and 70893 occurs.
The code opens the quest window, but you have to press the “turn in quest” button yourself. How can I fix this? So that it would be automatic?
Lua Code:
local addonName, addon = ...
local QuestIDs = {77244, 70893} -- Quest IDs to auto accept and turn in
local function IsQuestInList(questID)
for _, id in ipairs(QuestIDs) do
if questID == id then
return true
end
end
return false
end
local function AcceptQuest()
local availableQuests = C_GossipInfo.GetAvailableQuests()
if availableQuests then
for _, questInfo in ipairs(availableQuests) do
if IsQuestInList(questInfo.questID) then
C_GossipInfo.SelectAvailableQuest(questInfo.questID)
return true
end
end
end
return false
end
local function CompleteQuest()
local activeQuests = C_GossipInfo.GetActiveQuests()
if activeQuests then
for _, questInfo in ipairs(activeQuests) do
if IsQuestInList(questInfo.questID) then
C_GossipInfo.SelectActiveQuest(questInfo.questID)
return true
end
end
end
return false
end
local function OnGossipShow()
if AcceptQuest() then
return
end
if CompleteQuest() then
-- Auto-complete the quest when gossip window shows up
CompleteQuest()
GetQuestReward(1)
return
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("GOSSIP_SHOW")
frame:SetScript("OnEvent", OnGossipShow)