kessykins
Intermediate OT User
- Joined
- Mar 15, 2010
- Messages
- 297
- Reaction score
- 105
Hey,
As the title says, I'm having NPC troubles with a new npc.
I'm trying to make it so she'll accept a specific item for special fish bait but she isn't responding to the usual 'hi'
What am I doing wrong >.<
As the title says, I'm having NPC troubles with a new npc.
I'm trying to make it so she'll accept a specific item for special fish bait but she isn't responding to the usual 'hi'
What am I doing wrong >.<
HTML:
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)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local evamsg = 'Here you are!!'
local noimsg = 'What are you trying to do? You dont have the appropriate items!'
local deny = 'Not sure eh? Okay.'
--------------------MESSAGES------------------------------------------------------------------------------
if msgcontains(msg, 'trade') then
selfSay('I sell fish bait for (Deep-Sea Fishing), (Ice Fishing) and (Lava Fishing). What type of fishing do you plan on doing?', cid)
if msgcontains(msg, 'help') then
selfSay('To learn more about the different types of fishing speak with Fishing Guru, Marvin.', cid)
elseif msgcontains(msg, 'Deep-Sea Fishing') then
selfSay('The secret to Deep-Sea Fishing is to use the right kind of bait. I can sell you 100 special worms in exchange for 10 White Pearls. Interested?', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'Ice Fishing') then
selfSay('The secret to Ice Fishing is to use the right kind of bait. I can sell you 100 Shrimp in exchange for 3 Ice Cubes. Interested?', cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'Lava Fishing') then
selfSay('The secret to Lava Fishing is to use the right kind of bait. I can sell you 100 Nails in exchange for 50 Talons. Interested?', cid)
talkState[talkUser] = 3
-------------GETTING BAIT FROM HER-------------------
-- Deep-Sea Fishing
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, ITEM_WHITE_PEARL, 10) == true then
doPlayerAddItem(cid, ITEM_WORM, 100)
selfSay(evamsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
talkState[talkUser] = 0
end
else
selfSay(deny, cid)
talkState[talkUser] = 0
end
-- Ice Fishing
elseif talkState[talkUser] == 2 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, ITEM_ICE_CUBE, 3) == true then
doPlayerAddItem(cid, ITEM_SHRIMP, 100)
selfSay(evamsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
talkState[talkUser] = 0
end
else
selfSay(deny, cid)
talkState[talkUser] = 0
end
-- Lava Fishing
elseif talkState[talkUser] == 3 then
if msgcontains (msg, 'yes') then
if doPlayerTakeItem(cid, ITEM_TALON, 50) == true then
doPlayerAddItem(cid, ITEM_NAIL, 100)
selfSay(evamsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
talkState[talkUser] = 0
end
else
selfSay(deny, cid)
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
end
end
Last edited: