kessykins
Intermediate OT User
- Joined
- Mar 15, 2010
- Messages
- 297
- Reaction score
- 105
Ok so I attempted to create my first quest npc and failed miserably. The npc doesn't respond to anything but quest/apprentice. Each time it replies with the same thing x.x
What did noob Kes to wrong this time?
++REP for help
What did noob Kes to wrong this time?
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
local storage = 1650
local exp1 = 2000
local exp2 = 4000
if(msgcontains(msg, 'quest') or msgcontains(msg, 'apprentice')) then
if(getPlayerStorageValue(cid, storage) - 1) then
npcHandler:say("You are interested in becoming an apprentice fisherman eh? The first step is to get a pole. Deep Sea Fishing Poles are quite expensive to make.. Bring me 1 Orshabaal brain, 10 Iron Ore, 10 Giant Spider Silk and 10 Yellow Pieces of Cloth. ", cid)
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("Did you bring me 1 Orshabaal brain, 10 Iron Ore, 10 Giant Spider Silk and 10 Yellow Pieces of Cloth?", cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
npcHandler:say("I knew I recognized you! You have already got. Go away!", cid)
elseif(getPlayerStorageValue(cid, storage) == -3) then
npcHandler:say("So! You now have your pole. The next step is to prove to me that you can fish. Bring me 10 Common Silmy Objects, 5 Uncommon Slimy Objects and 1 Rare Slimy Object.", cid)
setPlayerStorageValue(cid, storage, 3)
elseif(getPlayerStorageValue(cid, storage) == 3) then
npcHandler:say("Did you bring me Bring me 10 Common Silmy Objects, 5 Uncommon Slimy Objects and 1 Rare Slimy Object?", cid)
talkState[talkUser] = 3
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if((doPlayerRemoveItem(cid, 5808, 1)) and (doPlayerremoveItem(cid, 5914, 10)) and (doPlayerremoveItem(cid, 5879, 10)) and (doPlayerremoveItem(cid, 5880, 10)) == TRUE) then
npcHandler:say("Thanks! Go into my house and grab your new rod.", cid)
doPlayerAddExp(cid, config.exp1)
setPlayerStorageValue(cid, storage, 2)
talkState[talkUser] = 1
else
npcHandler:say("Sorry, you don\'t have everything I asked for.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
if(doPlayerRemoveItem(cid, 10556, 10) and (doPlayerremoveItem(cid, 10553, 5)) and doPlayerremoveItem(cid, 10557, 1)) == TRUE then
npcHandler:say("Well done! You are now officially an Apprentice Fisherman! Go talk to Polgara for your next step.", cid)
doPlayerAddExp(cid, config.exp2)
setPlayerStorageValue(cid, storage, 3)
talkState[talkUser] = 0
else
npcHandler:say("Sorry, you don\'t have everything I asked for.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Okay then.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
++REP for help