• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Quest door - how to access only if you are on a quest?

TibiaFanatic

New Member
Joined
Sep 14, 2020
Messages
22
Reaction score
3
Location
Sweden
I'm trying to make my first quest, and it's pretty much a copy of "NPC mision 2.0" by Acubens with some minor changes.

The idea is to accept the quest, go and fetch the items, and deliver it to the quest giver, and the item is locked behind a quest door, and I can't figure out how to have the door open if you are on that quest, any thoughts?



The quest:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid



--------------------------------
------- NPC MISION  2.0 --------
------ by Acubens - Otland.net -
--------------------------------


local first = {
-- Place true if you want to use the system of a gift for experience, false if you want to use items
useExpReward = false,
-- The experience that will get the player at the end of the mission
experience = 5000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 2192,
-- Count of the item required
item_count = 1,
-- id of the gift that going to obtain the player at finish the mission
reward = 2147,
-- count of the gift item
reward_count = 5,
-- storage
storage = 60307,
-- name of the quest
questname = "The Seer didn't see this coming Quest"
}

local npc_message ={

-- Procced - message
"I need help retrieving my crystal ball, can you help?",
-- if you dont have items - message
"You don't have my crystal ball.",
-- thanks - message
"Thank You for Help me, {take it}.",
-- already done - message
"You have already done this mission.",
-- ready to go - message
"An Orc Shaman stole my crystal ball, he is located in a cave to the north of Springshire, just follow the river.",
-- congratulations - message
"Congratulations, you have finished the "..first.questname..""

}


if(msgcontains(msg, 'mission')) then
selfSay(npc_message[5], cid)
end

if(msgcontains(msg, first.questname)) then
    selfSay(npc_message[1], cid)
    talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
    if (getPlayerStorageValue(cid,first.storage) > 0) then
        selfSay(npc_message[4], cid)
    else
        if(doPlayerRemoveItem(cid,first.item,first.item_count)) then
            setPlayerStorageValue(cid,first.storage,1)
            if(useExpReward) then
                doPlayerAddExperience(cid,first.experience)
            else
                doPlayerAddItem(cid,first.reward,first.reward_count)
            end
            selfSay(npc_message[3], cid)
            doSendMagicEffect(getCreaturePosition(cid), 10)
            doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
        else
            selfSay(npc_message[2], cid)
        end
    end
return true
end

end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
E
I remember you were using tfs 1.2 right? you don't need any door script, just set the door actionid to the storage number that the npc gives to you, remember it needs to be a quest door and not any other type of door
The NPC give players a storage value here
Lua:
setPlayerStorageValue(cid,first.storage,1)
So you have to create a door where only players with this storage value can enter like this one
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cidPosition = getCreaturePosition(cid)
if (item.actionid == 42366 and getPlayerStorageValue(cid,first.storage) >= 1) then
            if cidPosition.x < toPosition.x then
                doTeleportThing(cid, {x=toPosition.x+1,y=toPosition.y,z=toPosition.z}, TRUE)
            else
                doTeleportThing(cid, {x=toPosition.x-1,y=toPosition.y,z=toPosition.z}, TRUE)
            end
            return TRUE
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can not enter room.")
            return TRUE
        end
end
 
I remember you were using tfs 1.2 right? you don't need any door script, just set the door actionid to the storage number that the npc gives to you, remember it needs to be a quest door and not any other type of door
 
Solution

Similar threads

Back
Top