Heya! I have a Npc that exchange creature products for Silver Tokens! But he is bugged in a way that when i want to exchange he will say that i dont have the stuff.
Please help!
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() end
local item = 'I\'m sorry, but you do not have the required items for this trade.'
local done = 'Here you are, thank you for your business.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msg == 'creature products' then
npcHandler:say('I am interested in {frazzle skins}, {red dragon scales}, {draken sulphurs}, {demonic essences}, {soul orbs}, {snake skins}, {compound eyes} and {wyrm scales}', cid)
elseif msgcontains(msg, 'frazzle skins') then
if getPlayerItemCount(cid,22533) >= 40 then
npcHandler:say('Did you bring me the 40 frazzle skins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {40 frazzle skins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,22533) >= 40 then
if doPlayerRemoveItem(cid,22533, 40) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'red dragon scales') then
if getPlayerItemCount(cid,5882) >= 20 then
npcHandler:say('Did you bring me the 20 red dragon scales?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {20 red dragon scales}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,5882) >= 20 then
if doPlayerRemoveItem(cid,5882, 20) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'draken sulphurs') then
if getPlayerItemCount(cid,12614) >= 30 then
npcHandler:say('Did you bring me the 30 draken sulphurs?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {30 draken sulphurs}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,12614) >= 30 then
if doPlayerRemoveItem(cid,22533, 30) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'demonic essences') then
if getPlayerItemCount(cid,6500) >= 50 then
npcHandler:say('Did you bring me the 50 demonic essences?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {50 demonic essences}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,6500) >= 50 then
if doPlayerRemoveItem(cid,6500, 50) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'soul orbs') then
if getPlayerItemCount(cid,5944) >= 100 then
npcHandler:say('Did you bring me the 100 soul orbs?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {100 soul orbs}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,5944) >= 100 then
if doPlayerRemoveItem(cid,5944, 100) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'snake skins') then
if getPlayerItemCount(cid,10611) >= 30 then
npcHandler:say('Did you bring me the 30 snake skins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {30 snake skins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,10611) >= 30 then
if doPlayerRemoveItem(cid,10611, 30) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'compound eyes') then
if getPlayerItemCount(cid,15486) >= 100 then
npcHandler:say('Did you bring me the 100 compound eyes?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {100 compound eyes}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,15486) >= 100 then
if doPlayerRemoveItem(cid,15486, 100) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'wyrm scales') then
if getPlayerItemCount(cid,10582) >= 100 then
npcHandler:say('Did you bring me the 100 wyrm scales?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {100 wyrm scales}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,10582) >= 100 then
if doPlayerRemoveItem(cid,10582, 100) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
else
npcHandler:say(item, cid)
end
if msgcontains(msg, 'no') and npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 15 then
npcHandler:say('Well, then leave.')
npcHandler.topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Please help!
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler
function onCreatureDisappear(cid) npcHandler
function onCreatureSay(cid, type, msg) npcHandler
function onThink() npcHandler
local item = 'I\'m sorry, but you do not have the required items for this trade.'
local done = 'Here you are, thank you for your business.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msg == 'creature products' then
npcHandler:say('I am interested in {frazzle skins}, {red dragon scales}, {draken sulphurs}, {demonic essences}, {soul orbs}, {snake skins}, {compound eyes} and {wyrm scales}', cid)
elseif msgcontains(msg, 'frazzle skins') then
if getPlayerItemCount(cid,22533) >= 40 then
npcHandler:say('Did you bring me the 40 frazzle skins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {40 frazzle skins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,22533) >= 40 then
if doPlayerRemoveItem(cid,22533, 40) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'red dragon scales') then
if getPlayerItemCount(cid,5882) >= 20 then
npcHandler:say('Did you bring me the 20 red dragon scales?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {20 red dragon scales}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,5882) >= 20 then
if doPlayerRemoveItem(cid,5882, 20) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'draken sulphurs') then
if getPlayerItemCount(cid,12614) >= 30 then
npcHandler:say('Did you bring me the 30 draken sulphurs?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {30 draken sulphurs}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,12614) >= 30 then
if doPlayerRemoveItem(cid,22533, 30) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'demonic essences') then
if getPlayerItemCount(cid,6500) >= 50 then
npcHandler:say('Did you bring me the 50 demonic essences?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {50 demonic essences}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,6500) >= 50 then
if doPlayerRemoveItem(cid,6500, 50) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'soul orbs') then
if getPlayerItemCount(cid,5944) >= 100 then
npcHandler:say('Did you bring me the 100 soul orbs?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {100 soul orbs}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,5944) >= 100 then
if doPlayerRemoveItem(cid,5944, 100) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'snake skins') then
if getPlayerItemCount(cid,10611) >= 30 then
npcHandler:say('Did you bring me the 30 snake skins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {30 snake skins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,10611) >= 30 then
if doPlayerRemoveItem(cid,10611, 30) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'compound eyes') then
if getPlayerItemCount(cid,15486) >= 100 then
npcHandler:say('Did you bring me the 100 compound eyes?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {100 compound eyes}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,15486) >= 100 then
if doPlayerRemoveItem(cid,15486, 100) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'wyrm scales') then
if getPlayerItemCount(cid,10582) >= 100 then
npcHandler:say('Did you bring me the 100 wyrm scales?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need {100 wyrm scales}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,10582) >= 100 then
if doPlayerRemoveItem(cid,10582, 100) == TRUE then
npcHandler:say(done, cid)
doPlayerAddItem(cid, 21399, 1)
end
else
npcHandler:say(item, cid)
end
else
npcHandler:say(item, cid)
end
if msgcontains(msg, 'no') and npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 15 then
npcHandler:say('Well, then leave.')
npcHandler.topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())