My server is Forgotten server 0.3.2 client 8.4.
The trouble im having is I have a quest NPC who is supposed to give you a storage number after doing his quest so you can pull a lever to get to the next area.
The Problem is after talking to the npc he sets your storage value to 50215 with a value of 1.
And this alone lets you pass lever.
If you do his quest that value becomes 2
How can I fix it so you must do his quest to use lever?
Thank you for any help.
NPC script
Action script
The trouble im having is I have a quest NPC who is supposed to give you a storage number after doing his quest so you can pull a lever to get to the next area.
The Problem is after talking to the npc he sets your storage value to 50215 with a value of 1.
And this alone lets you pass lever.
If you do his quest that value becomes 2
How can I fix it so you must do his quest to use lever?
Thank you for any help.
NPC script
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
--[[
REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
]]--
local storage = 50215
if(msgcontains(msg, 'quest') or msgcontains(msg, 'Death Certificate')) then
if(getPlayerStorageValue(cid, storage) < 1) then
npcHandler:say("Hey, I have quest for you. Bring me please {Death Certificate}.", cid)
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("Do you have the Death Certificate?", cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
npcHandler:say("Sorry, you have already done my quest.", cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, 7703, 1) == TRUE) then
npcHandler:say("Thanks! As I said, here\'s 100 god coins and some exp!", cid)
doPlayerAddExp(cid, 20000000)
doPlayerAddItem(cid, 6527, 100)
setPlayerStorageValue(cid, storage, 2)
doSendMagicEffect(getPlayerPosition(cid),11)
talkState[talkUser] = 0
else
npcHandler:say("Sorry, you don\'t have Death Certificate.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Then not.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Action script
Code:
function onUse(cid, item, frompos, item2, topos)
-- from mainland to island
if item.uid == 15100 then
queststatus = getPlayerStorageValue(cid,50215)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"The Mayor of Munchkinland has not given you the power to go here.")
else
gopos = {x=1400, y=1127, z=7}
doTeleportThing(cid, gopos)
end -- from island to mainland
elseif item.uid == 15101 then
backpos = {x=1402, y=1125, z=7}
doTeleportThing(cid, backpos)
else
return 0
end
return 1
end