951357 1 Postado Novembro 30, 2009 Share Postado Novembro 30, 2009 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á. Link para o comentário Compartilhar em outros sites More sharing options...
marcotozx 0 Postado Novembro 30, 2009 Share Postado Novembro 30, 2009 fala cara eu tenho um desse aqui aii vc muda do seu jeito... e os itens q vc quer! tenho ele pronto e uso no meu serv. 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 -- XVX FORGER START -- function amulet(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then return false end if getPlayerItemCount(cid,8262) >= 1 and getPlayerItemCount(cid,8263) >= 1 and getPlayerItemCount(cid,8264) >= 1 and getPlayerItemCount(cid,8265) >= 1 then if doPlayerRemoveItem(cid,8262,1) and doPlayerRemoveItem(cid,8263,1) and doPlayerRemoveItem(cid,8264,1) and doPlayerRemoveItem(cid,8265,1) and (doPlayerRemoveMoney(cid, 5000) == TRUE) then npcHandler:say('Here is your item!', cid) doPlayerAddItem(cid,8266,1) end else npcHandler:say('You don\'t have these items!', cid) end end function obsidian(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then return false end if getPlayerItemCount(cid,2516) >= 1 and getPlayerItemCount(cid,2425) >= 1 then if doPlayerRemoveItem(cid,2516,1) and doPlayerRemoveItem(cid,2425,1) then npcHandler:say('Here is your item!', cid) doPlayerAddItem(cid,5908,1) end else npcHandler:say('You don\'t have these items!', cid) end end function crude(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then return false end if getPlayerItemCount(cid,5879) >= 1 then if doPlayerRemoveItem(cid,5879,1) then npcHandler:say('Here is your item!', cid) doPlayerAddItem(cid,5892,1) end else npcHandler:say('You don\'t have these items!', cid) end end function draconian(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then return false end if getPlayerItemCount(cid,2516) >= 1 then if doPlayerRemoveItem(cid,2516,1) then npcHandler:say('Here is your item!', cid) doPlayerAddItem(cid,5889,1) end else npcHandler:say('You don\'t have these items!', cid) end end -- XVX FORGER END -- keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Posso Forjar Amulet, Obsidian Knife, Huge Chunk of Crude Iron e Piece of Draconian Steel!"}) local node1 = keywordHandler:addKeyword({'amulet'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hum Humm! Welcume lil. Me can do unbroken but Big Ben want gold 5000 and Big Ben need a lil time to make it unbroken. Yes or no??'}) node1:addChildKeyword({'yes'}, amulet, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true}) local node2 = keywordHandler:addKeyword({'obsidian'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade a Dragon Shield and an Obsidian Lance for a Obsidian Knife?'}) node2:addChildKeyword({'yes'}, obsidian, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true}) local node3 = keywordHandler:addKeyword({'crude'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade a Giant Spider Silk for a Huge Chunk of Crude Iron?'}) node3:addChildKeyword({'yes'}, crude, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true}) local node4 = keywordHandler:addKeyword({'draconian'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade a Dragon Shield for a Piece of Draconian Steel?'}) node4:addChildKeyword({'yes'}, draconian, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true}) npcHandler:addModule(FocusModule:new()) abraço e bom uso... PS: testado no meu serv nao sei se vai no seu! :smile_positivo: Link para o comentário Compartilhar em outros sites More sharing options...
951357 1 Postado Dezembro 1, 2009 Autor Share Postado Dezembro 1, 2009 Olá zalo, O NPC enviado por você deu certo! Agora só vou configurar do meu jeito e inserir no meu servidor. Agradeço pela colaboração com o XTibia. Reportei o fechamento do tópico. Continue assim! Link para o comentário Compartilhar em outros sites More sharing options...
Henrique Moura 193 Postado Dezembro 1, 2009 Share Postado Dezembro 1, 2009 Obrigado ao membro por contribuir e obrigado ao outro por sempre seguir as regras do XTibia. Tópico fechado :button_cancel: Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados