Klank
Althea ¤ A New World Developer
Hey.
I just made this one, and got this problem:
When i say hi the npc responds with "how did you find me?! (brother)
But when i say brother he wont respond..
I just made this one, and got this problem:
When i say hi the npc responds with "how did you find me?! (brother)
But when i say brother he wont respond..
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
local storage = 5204
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
if(msg == 'hi' or msg == 'hello') then
if(getPlayerStorageValue(cid, storage) == -1) then
selfSay('How did you find me here?! ({brother})', cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
selfSay('Hey '..getPlayerName(cid)..', Did you get what i asked for?({yes})',cid)
talkState[talkUser] = 5
else
selfSay('Hello '..getPlayerName(cid)..',Good to see you again.', cid)
end
npcHandler:addFocus(cid)
else
return false
end
end
if(msgcontains(msg,'brother') and talkState[talkUser] == 1) then
selfSay('My brother? I havn\'t seen him in so long! So what brings you down here?({potion})', cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, 'potion') and talkState[talkUser] == 2) then
selfSay('Oh! Did he tell you about it? You must have helped him.. This was our secret... So tell me, do you want to grow a beard yourself? ({yes})',cid)
talkState[talkUser] = 3
elseif(msgcontains(msg,'yes') and talkState[talkUser] == 3) then
selfSay('For me to make this potion i need various types of ingredients, but im missing some.. If you want me to make it you have to bring me: {5x troll hair, 1x bottle of beer, 6x shadow herbs} and {10 honeycombs}. Will you manage to do that? ({yes}/{no})',cid)
talkState[talkUser] = 4
elseif(msgcontains(msg,'yes') and talkState[talkUser] == 4) then
SelfSay('Very well then, ill get ready to make the potion.',cid)
setPlayerStorageValue(cid, storage, 2)
elseif(msgcontains(msg,'no') and talkState[talkUser] == 4) then
SelfSay('Well, no beard for you then',cid)
talkState[talkUser] = 9
elseif(msgcontains(msg,'yes') and talkState[talkUser] == 5) then
if getPlayerItemCount(cid,5902) >= 10 and getPlayerItemCount(cid,2804) >= 6 and getPlayerItemCount(cid,2015) >= 1 and getPlayerItemCount(cid,10606) >= 5 then
if doPlayerRemoveItem(cid,5902,10) and doPlayerRemoveItem(cid,2804,6) and doPlayerRemoveItem(cid,2015,1) and doPlayerRemoveItem (cid,10606,5)then
SelfSay('Thank you, drink this potion and your beard will grow out faster then you\'ve ever seen!',cid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have obtained Beggar beard addon.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
doPlayerAddOutfit(cid, 153, 1)
doPlayerAddOutfit(cid, 157, 1)
else
SelfSay('You don\'t have the required ingredients with you', cid)
end
end
end
talkState[talkUser] = 0
if(msgcontains(msg, 'no') and isInArray({1,5}, talkState[talkUser])) then
selfSay('Well, then i canv\'t help you...', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'bye')) then
selfSay('Good bye.', cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)