Antigamente eu usava esse NPC em um OT 0.2.3 TFS 8.40...
Hoje estou usando a versão 8.42 do TFS 0.3.4 PL2
O NPC A Sweaty Cyclops não funciona corretamente, ele não remove todos os itens nem adiciona o item ao player, ou seja, não executa as últimas funções corretamente.
O NPC é o seguinte:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'help') then
selfSay('Error, contact the administrator.', cid)
elseif msgcontains(msg, 'huge chunk of crude iron') then
if getPlayerItemCount(cid,2393) >= 1 then
selfSay('Did you bring me the Giant Sword?', cid)
talk_state = 1
else
selfSay('I need 1 Giant Sword, to give you the Huge Chunk of Crude Iron. 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,2393) >= 1 then
if doPlayerRemoveItem(cid,2393,1) == 1 then
doPlayerAddItem(cid,5892,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'warrior\'s sweat') then
if getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 then
selfSay('Did you bring me 4 Warrior Helmet?', cid)
talk_state = 2
else
selfSay('I need 4 Warrior Helmet, to give you the Warrior\'s Sweat. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 then
if doPlayerRemoveItem(cid,2475,1) == 1 and doPlayerRemoveItem(cid,2475,1) == 1 and doPlayerRemoveItem(cid,2475,1) == 1 and doPlayerRemoveItem(cid,2475,1) == 1 then
doPlayerAddItem(cid,5885,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'magic sulphur') then
if getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 then
selfSay('Did you bring me 3 Fire Sword?', cid)
talk_state = 3
else
selfSay('I need 3 Fire Sword, to give you the Magic Sulphur. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 then
if doPlayerRemoveItem(cid,2392,1) == 1 and doPlayerRemoveItem(cid,2392,1) == 1 and doPlayerRemoveItem(cid,2392,1) == 1 then
doPlayerAddItem(cid,5904,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'enchanted chicken wing') then
if getPlayerItemCount(cid,2195) >= 1 then
selfSay('Did you bring me Boots of Haste?', cid)
talk_state = 4
else
selfSay('I need 1 Boots of Haste, to give you the Enchanted Chicken Wing. 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,2195) >= 1 then
if doPlayerRemoveItem(cid,2195,1) == 1 then
doPlayerAddItem(cid,5891,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'piece of royal steel') then
if getPlayerItemCount(cid,2487) >= 1 then
selfSay('Did you bring me the Crown Armor?', cid)
talk_state = 5
else
selfSay('I need 1 Crown Armor, to give you the Piece of Royal Steel. 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,2487) >= 1 then
if doPlayerRemoveItem(cid,2487,1) == 1 then
doPlayerAddItem(cid,5887,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'piece of draconian steel') then
if getPlayerItemCount(cid,2516) >= 1 then
selfSay('Did you bring me the Dragon Shield?', cid)
talk_state = 6
else
selfSay('I need 1 Dragon Shield, to give you the Piece of Draconian Steel. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 6 then
talk_state = 0
if getPlayerItemCount(cid,2516) >= 1 then
if doPlayerRemoveItem(cid,2516,1) == 1 then
doPlayerAddItem(cid,5889,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'piece of hell steel') then
if getPlayerItemCount(cid,2462) >= 1 then
selfSay('Did you bring me the Devil Helmet?', cid)
talk_state = 7
else
selfSay('I need 1 Devil Helmet, to give you the Piece of Hell Steel. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 7 then
talk_state = 0
if getPlayerItemCount(cid,2462) >= 1 then
if doPlayerRemoveItem(cid,2462,1) == 1 then
doPlayerAddItem(cid,5888,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'elane\'s crossbow') then
if getPlayerItemCount(cid,5921) >= 3 then
selfSay('Did you bring me the 3 Heaven Blossom?', cid)
talk_state = 8
else
selfSay('I need 3 Heaven Blossom, to give you the Elane\'s Crossbow. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 8 then
talk_state = 0
if getPlayerItemCount(cid,5921) >= 3 then
if doPlayerRemoveItem(cid,5921,3) == 1 then
doPlayerAddItem(cid,5947,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'fighting spirit') then
if getPlayerItemCount(cid,2498) >= 1 and getPlayerItemCount(cid,2498) >= 1 then
selfSay('Did you bring me the 2 Royal Helmet?', cid)
talk_state = 9
else
selfSay('I need a 2 Royal Helmet, to give you the Fighting Spirit. 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,2498) >= 1 and getPlayerItemCount(cid,2498) >= 1 then
if doPlayerRemoveItem(cid,2498,1) == 1 and doPlayerRemoveItem(cid,2498,1) == 1 then
doPlayerAddItem(cid,5884,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'blue piece of cloth') then
if getPlayerItemCount(cid,2663) >= 1 then
selfSay('Did you bring me the Mystic Turban?', cid)
talk_state = 10
else
selfSay('I need a 1 Mystic Turban, to give you the Blue Piece of Cloth. 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,2663) >= 1 then
if doPlayerRemoveItem(cid,2663,1) == 1 then
doPlayerAddItem(cid,5912,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'green piece of cloth') then
if getPlayerItemCount(cid,2652) >= 1 then
selfSay('Did you bring me the Green Tunic?', cid)
talk_state = 11
else
selfSay('I need a 1 Green Tunic, to give you the Green Piece of Cloth. 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,2652) >= 1 then
if doPlayerRemoveItem(cid,2652,1) == 1 then
doPlayerAddItem(cid,5910,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'red piece of cloth') then
if getPlayerItemCount(cid,2655) >= 1 then
selfSay('Did you bring me the Red Robe?', cid)
talk_state = 12
else
selfSay('I need a 1 Red Robe, to give you the Red Piece of Cloth. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 12 then
talk_state = 0
if getPlayerItemCount(cid,2655) >= 1 then
if doPlayerRemoveItem(cid,2655,1) == 1 then
doPlayerAddItem(cid,5911,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'obsidian knife') then
if getPlayerItemCount(cid,2425) >= 1 and getPlayerItemCount(cid,5889) >= 1 then
selfSay('Did you bring me the Obsidian Lande and Piece of Draconian Steel?', cid)
talk_state = 13
else
selfSay('I need a 1 Obsidian Lance and 1 Piece of Draconian Steel, to give you the Obsidian Knife. 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,2425) >= 1 and getPlayerItemCount(cid,5889) >= 1 then
if doPlayerRemoveItem(cid,2425,1) == 1 and doPlayerRemoveItem(cid,5889,1) == 1 then
doPlayerAddItem(cid,5908,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'blessed wooden stake') then
if getPlayerItemCount(cid,5941) >= 1 and getPlayerItemCount(cid,7759) >= 5 and getPlayerItemCount(cid,7760) >= 5 and getPlayerItemCount(cid,7761) >= 5 and getPlayerItemCount(cid,7762) >= 5 then
selfSay('Did you bring me the Wooden Stake, five Enchanted Smalls Ruby, Emerald, Sapphire and Amethyst?', cid)
talk_state = 14
else
selfSay('I need the 1 Wooden Stake, 5 Enchanted Small Ruby, 5 Enchanted Small Emerald, 5 Enchanted Small Sapphire and 5 Enchanted Small Amethystl, to give you the Blessed Wooden Stake. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 14 then
talk_state = 0
if getPlayerItemCount(cid,5941) >= 1 and getPlayerItemCount(cid,7759) >= 5 and getPlayerItemCount(cid,7760) >= 5 and getPlayerItemCount(cid,7761) >= 5 and getPlayerItemCount(cid,7762) >= 5 then
if doPlayerRemoveItem(cid,5941,1) == 1 and doPlayerRemoveItem(cid,7759,5) == 1 and doPlayerRemoveItem(cid,7760,5) == 1 and doPlayerRemoveItem(cid,7761,5) == 1 and doPlayerRemoveItem(cid,7762,5) == 1 then
doPlayerAddItem(cid,5942,1)
selfSay('Thanks.', cid)
talk_state = 0
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 13) then
selfSay('Ok than.', cid)
talk_state = 0
end
return true
end
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You can here change some items for {enchanted} {chicken} {wing}, {huge} {chunk} {of} {crude} {iron}, {warrior\'s} {sweat}, {magic} {sulphur}, {piece} {of} {hell} {steel}, {piece} {of} {draconian} {steel}, {piece} {of} {royal} {steel}, {elane\'s} {crossbow}, {fighting} {spirit}, {blue} {piece} {of} {cloth}, {red} {piece} {of} {cloth}, {green} {piece} {of} {cloth}, {blessed} {wooden} {stake} and {obsidian knife}."})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Por favor, espero que me ajudem.
Agradeço desde já.