Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-02-24, 08:05 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 122
Quest Select/Accept/Complete LUA

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:
  1. local addonName, addon = ...
  2. local QuestIDs = {77244, 70893} -- Quest IDs to auto accept and turn in
  3.  
  4. local function IsQuestInList(questID)
  5.     for _, id in ipairs(QuestIDs) do
  6.         if questID == id then
  7.             return true
  8.         end
  9.     end
  10.     return false
  11. end
  12.  
  13. local function AcceptQuest()
  14.     local availableQuests = C_GossipInfo.GetAvailableQuests()
  15.     if availableQuests then
  16.         for _, questInfo in ipairs(availableQuests) do
  17.             if IsQuestInList(questInfo.questID) then
  18.                 C_GossipInfo.SelectAvailableQuest(questInfo.questID)
  19.                 return true
  20.             end
  21.         end
  22.     end
  23.     return false
  24. end
  25.  
  26. local function CompleteQuest()
  27.     local activeQuests = C_GossipInfo.GetActiveQuests()
  28.     if activeQuests then
  29.         for _, questInfo in ipairs(activeQuests) do
  30.             if IsQuestInList(questInfo.questID) then
  31.                 C_GossipInfo.SelectActiveQuest(questInfo.questID)
  32.                 return true
  33.             end
  34.         end
  35.     end
  36.     return false
  37. end
  38.  
  39. local function OnGossipShow()
  40.     if AcceptQuest() then
  41.         return
  42.     end
  43.  
  44.     if CompleteQuest() then
  45.         -- Auto-complete the quest when gossip window shows up
  46.         CompleteQuest()
  47.         GetQuestReward(1)
  48.         return
  49.     end
  50. end
  51.  
  52. local frame = CreateFrame("Frame")
  53. frame:RegisterEvent("GOSSIP_SHOW")
  54. frame:SetScript("OnEvent", OnGossipShow)
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Quest Select/Accept/Complete LUA


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off