Hello!
I remade npc script to this, and it wont work...
-me- Hi!
-npc- hello, im poor man...can you help me?
-me- help
-npc- can you find wyvern fang?
-me- yes
-npc- <dont answer>
Will be very thankful if u will help me to find mistake eace:
I remade npc script to this, and it wont work...
-me- Hi!
-npc- hello, im poor man...can you help me?
-me- help
-npc- can you find wyvern fang?
-me- yes
-npc- <dont answer>
Will be very thankful if u will help me to find mistake eace:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 thinkCallback(cid)
local random = math.random(250)
if random == 1 then
npcHandler:say("Sir, Ma'am, have a gold coin to spare?")
elseif random == 2 then
npcHandler:say("I need help! Please help me!")
elseif random == 3 then
npcHandler:say("Alms! Alms for the poor!")
end
return true
end
function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
npcHandler:say("Hello " .. getCreatureName(cid) .. ". I am a poor man. Please HELP me!", cid, TRUE)
Topic[cid] = 0
npcHandler:addFocus(cid)
elseif(not npcHandler:isFocused(cid)) then
return false
elseif Topic[cid] == 1 then
if msgcontains(msg, "yes") then
if doPlayerRemoveItem(cid,7408,1) == TRUE then
npcHandler:say("Thank you very much! Take your reward!", cid)
local key = doCreateItemEx(2087, 1)
doItemSetAttribute(key, "aid", 3940)
doPlayerAddItemEx(cid, key, 1)
else
npcHandler:say("You don't have it.", cid)
end
else
npcHandler:say("Ok... No problem!", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("Have a nice day.", cid, TRUE)
Topic[cid] = 0
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "help") then
npcHandler:say("I need wyvern fang. Can you find it for me?", cid)
Topic[talkUser] = 1
end
return true
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Have a nice day.")
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Last edited: