I'm learning to build mission npc, but I'm having trouble with NPC 2 and 3, they do not respond to 'yes'.
Can someone help me? Thanks in advance.
They are related:
The NPC 1 tell to bring stuffs from NPC 2. And NPC 2 say that to do that, need itens from NPC3.
NPC 1
NPC 2
NPC 3
up
up
Can someone help me? Thanks in advance.
They are related:
The NPC 1 tell to bring stuffs from NPC 2. And NPC 2 say that to do that, need itens from NPC3.
NPC 1
Code:
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
local storage = 135001
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
msg = msg:lower();
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msg == "catacounbs" then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Hello! I think you are here to get acess to the entrance of The Catacounbs, right?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 5 then
selfSay("Did you bring me the itens?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 6 then
selfSay("Thanks for the help.", cid)
else
selfSay("Something is missing.", cid)
end
npcHandler:addFocus(cid)
else
return false
end
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("For I give you the acess you need to make me a favor. Go to Nico and tell him that I want the {stuffs}. He'll know what is.", cid)
setPlayerStorageValue(cid, storage, 1)
elseif getPlayerStorageValue(cid, storage) == 5 then
if doPlayerRemoveItem(cid, 2796, 1) then
selfSay("Well, now you can pass the door.", cid)
doPlayerAddItem(cid, 2160, 3)
doPlayerAddExp(cid, 5000)
setPlayerStorageValue(cid, storage, 6)
else
selfSay("You don't have it.", cid)
end
else
selfSay("I think you've not talk with Nico yet", cid)
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "bye") then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
NPC 2
Code:
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
local storage = 135001
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
msg = msg:lower();
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msg == "stuffs" then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("What you mean?", cid)
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("I think you come here for Tery. Well, to do what him want I need that you go to Lian and bring me some {mix herbs}, can you do it?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 4 then
selfSay("Did you bring the mix herbs?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 5 then
selfSay("Already done.", cid)
else
selfSay("Something is missing.", cid)
end
npcHandler:addFocus(cid)
else
return false
end
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == 1 then
selfSay("So be it. Come back when you have it.", cid)
setPlayerStorageValue(cid, storage, 2)
elseif getPlayerStorageValue(cid, storage) == 4 then
if doPlayerRemoveItem(cid, 2801, 1) then
selfSay("Here are. Tell Tery to come visit me at any time.", cid)
doPlayerAddItem(cid, 2796, 1)
setPlayerStorageValue(cid, storage, 5)
else
selfSay("You don't have it.", cid)
end
else
selfSay("I think you've not talk with Lian yet", cid)
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "bye") then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
NPC 3
Code:
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
local storage = 135001
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
msg = msg:lower();
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msg == "mix herbs" then
if getPlayerStorageValue(cid, storage) <= 1 then
selfSay("What do you mean by that?", cid)
elseif getPlayerStorageValue(cid, storage) == 2 then
selfSay("Hm...Ok then. Back with one of each item below: blood herb, stone herb, star herb, sling herb, powder herb and shadow herb. Ok?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 3 then
selfSay("You bring the herbs?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 6 then
selfSay("I already gave it to you. Have you memory loss?", cid)
else
selfSay("Something is missing.", cid)
end
npcHandler:addFocus(cid)
else
return false
end
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == 2 then
selfSay("Ok, come back when you have it.", cid)
setPlayerStorageValue(cid, storage, 3)
elseif getPlayerStorageValue(cid, storage) == 3 then
if doPlayerRemoveItem(cid, 2798, 1) and doPlayerRemoveItem(cid, 2799, 1) and doPlayerRemoveItem(cid, 2800, 1) and doPlayerRemoveItem(cid, 2802, 1) and doPlayerRemoveItem(cid, 2803, 1) and doPlayerRemoveItem(cid, 2804, 1) then
selfSay("So done. Here are the mix herb", cid)
doPlayerAddItem(cid, 2801, 1)
setPlayerStorageValue(cid, storage, 4)
else
selfSay("You don't have it.", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "bye") then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
up
up
Last edited by a moderator: