Originally Posted by
Togggy
and to change it back after the quest is complete?
Code:
CREATURE_EVENT_ON_QUEST_REWARD = 34 -- // (event, player, creature, quest, opt) - Can return true
So something like:
Code:
local NPC_QUEST_GIVER = 10581 -- npc ID that gives the quest
local function QuestGiverEvents(event, plr, pUnit, quest, _)
--if quest:GetId() == 1 then -- can change to your quest ID
if event == 31 then
plr:SetPhaseMask(2) -- Change the players phase to 2 on quest accept
elseif event == 34 then
plr:SetPhaseMask(1)
end
--end
end
RegisterCreatureEvent(NPC_QUEST_GIVER, 31, QuestGiverEvents)
RegisterCreatureEvent(NPC_QUEST_GIVER, 34, QuestGiverEvents)
-- CREATURE_EVENT_ON_QUEST_ACCEPT = 31 -- // (event, player, creature, quest) - Can return true
-- CREATURE_EVENT_ON_QUEST_REWARD = 34 -- // (event, player, creature, quest, opt) - Can return true
But then bear in mind the quest can be abandoned too, so you also need to handle that:
Code:
local NPC_QUEST_GIVER = 10581 -- npc ID that gives the quest
local QUEST_ID = 10851 -- your quest ID
local function QuestGiverEvents(event, plr, pUnit, quest, _)
if quest:GetId() == QUEST_ID then
if event == 31 then
plr:SetPhaseMask(2) -- Change the players phase to 2 on quest accept
elseif event == 34 then
plr:SetPhaseMask(1)
end
end
end
RegisterCreatureEvent(NPC_QUEST_GIVER, 31, QuestGiverEvents)
RegisterCreatureEvent(NPC_QUEST_GIVER, 34, QuestGiverEvents)
-- CREATURE_EVENT_ON_QUEST_ACCEPT = 31 -- // (event, player, creature, quest) - Can return true
-- CREATURE_EVENT_ON_QUEST_REWARD = 34 -- // (event, player, creature, quest, opt) - Can return true
local function PLAYER_EVENT_ON_QUEST_ABANDON(event, plr, questId)
if questId == QUEST_ID then
plr:SetPhaseMask(1)
end
end
RegisterPlayerEvent(38, PLAYER_EVENT_ON_QUEST_ABANDON)