Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
item = 'You do not have the required items.'
done = 'Here you are.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'offer') then
selfSay('You can exchange some items for {spool of yarn}, {huge chunk of crude iron}, {piece of draconian steel}, {warrior's sweat}, {magic sulphur}, {enchanted chicken wing}, {piece of royal steel}, {piece of hell steel}, {engraved crossbow}, {fighting spirit}, {blue piece of cloth}, {green piece of cloth} {red piece of cloth}, {lottery ticket}, {staff}, {mermaid comb}, {damaged steel helmet}, {ceiron's wolf tooth chain}, {obsidian knife} and {blessed wooden stake}.', cid)
elseif msgcontains(msg, 'spider silk yarn') then
if getPlayerItemCount(cid,5879) >= 10 then
selfSay('Did you bring me 10 giant spider silks ?', cid)
talk_state = 1
else
selfSay('I need 10 giant spider silks, to give you a spool of yarn. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,5879) >= 10 then
if doPlayerRemoveItem(cid,5879, 10) == TRUE then
selfSay(done, cid)
doPlayerAddItem(cid, 5886, 1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'huge chunk of crude iron') then
if getPlayerItemCount(cid,2393) >= 1 then
selfSay('Did you bring a giant sword ?', cid)
talk_state = 2
else
selfSay('I need a giant sword, to give you a huge chunk of crude iron. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,2393) >= 1 then
if doPlayerRemoveItem(cid,2393,1) == TRUE then
selfSay(done, cid)
doPlayerAddItem(cid,5892,1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'ticket') or msgcontains(msg, 'lottery') or msgcontains(msg, 'lottery ticket') or msgcontains(msg, 'lotery ticket') then
if getPlayerItemCount(cid,2160) >= 5 then
selfSay('Did you bring me 10 beholder eyes', cid)
talk_state = 15
else
selfSay('I need 10 beholder eyes, to give you a lottery ticket. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 15 then
talk_state = 0
if getPlayerItemCount(cid,5898) >= 10 then
if doPlayerRemoveItem(cid,5898,10) == TRUE then
selfSay(addon_give)
doPlayerAddItem(cid,5958,1)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'piece of draconian steel') then
if getPlayerItemCount(cid,2516) >= 1 then
selfSay('Did you bring me a dragon shield ?', cid)
talk_state = 3
else
selfSay('I need a dragon shield, to give you a piece of draconian steel. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,2516) >= 1 then
if doPlayerRemoveItem(cid,2516,1) == TRUE then
doPlayerAddItem(cid,5889,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'warrior's sweat') then
if getPlayerItemCount(cid,2475) >= 4 then
selfSay('Did you bring me 4 warrior helmets ?', cid)
talk_state = 4
else
selfSay('I need 4 warrior helmets, to give you a warrior's sweat. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 4 then
talk_state = 0
if getPlayerItemCount(cid,2475) >= 4 then
if doPlayerRemoveItem(cid,2475,4) == TRUE then
doPlayerAddItem(cid,5885,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'magic sulphur') then
if getPlayerItemCount(cid,2392) >= 3 then
selfSay('Did you bring me 3 fire swords?', cid)
talk_state = 5
else
selfSay('I need 3 fire swords, to give you a magic sulphur. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 5 then
talk_state = 0
if getPlayerItemCount(cid,2392) >= 3 then
if doPlayerRemoveItem(cid,2392,3) == TRUE then
doPlayerAddItem(cid,5904,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'enchanted chicken wing') then
if getPlayerItemCount(cid,2195) >= 1 then
selfSay('Did you bring me a boots of haste ?', cid)
talk_state = 6
else
selfSay('I need a boots of haste, to give you the enchanted chicken wing. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 6 then
talk_state = 0
if getPlayerItemCount(cid,2195) >= 1 then
if doPlayerRemoveItem(cid,2195,1) == TRUE then
doPlayerAddItem(cid,5891,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'piece of royal steel') then
if getPlayerItemCount(cid,2487) >= 1 then
selfSay('Did you bring me a crown armor ?', cid)
talk_state = 7
else
selfSay('I need a crown armor, to give you a piece of royal steel. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 7 then
talk_state = 0
if getPlayerItemCount(cid,2487) >= 1 then
if doPlayerRemoveItem(cid,2487,1) == TRUE then
doPlayerAddItem(cid,5887,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'piece of hell steel') then
if getPlayerItemCount(cid,2462) >= 1 then
selfSay('Did you bring me a devil helmet ?', cid)
talk_state = 8
else
selfSay('I need a devil helmet, to give you a piece of hell steel. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 8 then
talk_state = 0
if getPlayerItemCount(cid,2462) >= 1 then
if doPlayerRemoveItem(cid,2462,1) == TRUE then
doPlayerAddItem(cid,5888,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'engraved crossbow') then
if getPlayerItemCount(cid,6087) >= 1 and getPlayerItemCount(cid,6088) >= 1 and getPlayerItemCount(cid,6089) >= 1 and getPlayerItemCount(cid,6090) >= 1 and then
selfSay('Did you bring me all the verses of the hymn ?', cid)
talk_state = 9
else
selfSay('I need all verses of hymn, to give you the engraved crossbow. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 9 then
talk_state = 0
if getPlayerItemCount(cid,6087) >= 1 and getPlayerItemCount(cid,6088) >= 1 and getPlayerItemCount(cid,6089) >= 1 and getPlayerItemCount(cid,6090) >= 1 then
if doPlayerRemoveItem(cid,6087,1) == TRUE and doPlayerRemoveItem(cid,6088,1) == TRUE and doPlayerRemoveItem(cid,6089,1) == TRUE and doPlayerRemoveItem(cid,6090,1) == TRUE then
doPlayerAddItem(cid,5947,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'fighting spirit') then
if getPlayerItemCount(cid,2498) >= 2 then
selfSay('Did you bring me the 2 royal helmets ?', cid)
talk_state = 10
else
selfSay('I need 2 Royal Helmets, to give you a fighting spirit. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 10 then
talk_state = 0
if getPlayerItemCount(cid,2498) >= 2 then
if doPlayerRemoveItem(cid,2498,2) == TRUE then
doPlayerAddItem(cid,5884,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'staff') then
if getPlayerItemCount(cid,5877) >= 20 and if getPlayerItemCount(cid,5920) >= 20 and then
selfSay('Did you bring me 20 green dragon leathers and 20 green dragon scales ?', cid)
talk_state = 11
else
selfSay('I need 20 green dragon leathers and 20 green dragon scales, to give you the simon the beggar\'s favorite staff. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 11 then
talk_state = 0
if getPlayerItemCount(cid,5877) >= 20 getPlayerItemCount(cid,5920) >= 20 then
if doPlayerRemoveItem(cid,5877,20) == TRUE and doPlayerRemoveItem(cid,5920,20) == TRUEthen
doPlayerAddItem(cid,6107,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'blue piece of cloth') then
if getPlayerItemCount(cid,2663) >= 1 then
selfSay('Did you bring me a mystic turban?', cid)
talk_state = 12
else
selfSay('I need a mystic turban, to give you the blue piece of cloth. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 12 then
talk_state = 0
if getPlayerItemCount(cid,2663) >= 1 then
if doPlayerRemoveItem(cid,2663,1) == TRUE then
doPlayerAddItem(cid,5912,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'green piece of cloth') then
if getPlayerItemCount(cid,2652) >= 1 then
selfSay('Did you bring me 20 green tunics ?', cid)
talk_state = 13
else
selfSay('I need 20 green tunics, to give you a green piece of cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 13 then
talk_state = 0
if getPlayerItemCount(cid,2652) >= 20 then
if doPlayerRemoveItem(cid,2652,20) == TRUE then
doPlayerAddItem(cid,5910,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'red piece of cloth') then
if getPlayerItemCount(cid,2655) >= 1 then
selfSay('Did you bring me a red robe ?', cid)
talk_state = 14
else
selfSay('I need a red robe, to give you a red piece of cloth. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 14 then
talk_state = 0
if getPlayerItemCount(cid,2655) >= 1 then
if doPlayerRemoveItem(cid,2655,1) == TRUE then
doPlayerAddItem(cid,5911,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'mermaid comb') then
if getPlayerItemCount(cid,5480) >= 1 then
selfSay('Did you bring me a cat'/s paw ?', cid)
talk_state = 15
else
selfSay('I need a cat'/s paw, to give you a mermaid comb. Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 15 then
talk_state = 0
if getPlayerItemCount(cid,5480) >= 1 then
if doPlayerRemoveItem(cid,5480,1) == TRUE then
doPlayerAddItem(cid,5945,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'damaged steel helmet') then
if getPlayerItemCount(cid,3957) >= 51 then
selfSay('Did you bring me a war horn ?', cid)
talk_state = 16
else
selfSay('I need a war horn, to give you a ramsay the reckless lost helmet . Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 16 then
talk_state = 0
if getPlayerItemCount(cid,3957) >= 1 then
if doPlayerRemoveItem(cid,3957,1) == TRUE then
doPlayerAddItem(cid,5924,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'obsidian knife') then
if getPlayerItemCount(cid,5889) >= 1 and getPlayerItemCount(cid,2425) >= 1 then
selfSay('Did you bring me a piece of draconian steel and an obsidian lance ?', cid)
talk_state = 17
else
selfSay('I need a war horn, to give you an obsidian knife . Come back when you have it.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 17 then
talk_state = 0
if getPlayerItemCount(cid,5889) >= 1 and getPlayerItemCount(cid,2425) >= 1 then
if doPlayerRemoveItem(cid,5889,1) == TRUE and doPlayerRemoveItem(cid,2425,1) == TRUE then
doPlayerAddItem(cid,5924,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'ceiron/'s wolf tooth chain') then
if getPlayerItemCount(cid,5908) >= 5 then
selfSay('Did you bring me 10 demon horns ?', cid)
talk_state = 18
else
selfSay('I need 10 demon horns, to give a ceiron'/s wolf tooth chain. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 18 then
talk_state = 0
if getPlayerItemCount(cid,5954) >= 10 then
if doPlayerRemoveItem(cid,5954,10) == TRUE then
doPlayerAddItem(cid,5940,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'blessed wooden stake') then
if getPlayerItemCount(cid,5921) >= 10 then
selfSay('Did you bring me 10 heaven blossoms ?', cid)
talk_state = 18
else
selfSay('I need 10 heaven blossoms, to give a blessed wooden stake. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 19 then
talk_state = 0
if getPlayerItemCount(cid,5921) >= 1 then
if doPlayerRemoveItem(cid,5921,1) == TRUE then
doPlayerAddItem(cid,5942,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 18) then
selfSay('Ok then.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I'm having this error:
[31/05/2009 21:32:14] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/exchange.lua
[31/05/2009 21:32:15] data/npc/scripts/exchange.lua:19: ')' expected near 'sweat'
but there's probably more please fix it for me.