Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Quest = {
- creature_entry = 123,
- quest_entry = 123,
- gate_entry = 123
- }
- function Quest.OnQuestAccept(event, player, creature, quest)
- -- Check if the quest we pick up matches the expected quest id.
- if(quest:GetId() == Quest.quest_entry) then
- -- Trigger the gate open and reset function.
- Quest.TriggerGate(player)
- end
- end
- function Quest.TriggerGate(player)
- -- Retrieve the gate object with a specific entry within 20 yard range of the player.
- -- Can be substituted with other methods of retrieving the gate object.
- local gate = player:GetGameObjectsInRange(20, Quest.gate_entry)
- if(gate) then
- if(gate:GetGoState() == 1) then
- -- If the object state is closed, open gate and register the gate reset event below.
- gate:SetGoState(0)
- elseif(gate:GetGoState() == 0)
- -- If the gate is already open, remove the previous registered timed
- -- event to close the gate, so it can be safely re-registered below.
- gate:RemoveEvents()
- end
- -- Register timed event to close the gate after a set amount of time.
- gate:RegisterEvent(function(_, _, _, gate) gate:SetGoState(1); return; end, 10000, 1)
- end
- end
- -- Unfortunately we can only hook quest accept event when picked up from a creature.
- RegisterCreatureEvent(Quest.creature_entry, 31, Quest.OnQuestAccept)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement