george100 5 Postado Março 12, 2010 Share Postado Março 12, 2010 coloquei um Npc que ele troca 5 queijos por um shield... mais ele nao pega os queijo ele está bugado... só falar Yes que ele da o shield sem precisar estar com os 5 queijos! alguem ai pode me ajudar? ta ai o script -- NPC de troca - By Conde Sapo local focus = 0 local talk_start = 0 local target = 0 local following = false local attacking = false local addon_state = 0 function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 end end function onCreatureTurn(creature) end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) msg = string.lower(msg) if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then selfSay('Olá ' .. getCreatureName(cid) .. '... Eu daria tudo por alguns queijos... Você tem 5 sobrando aí? Eu posso te dar meu escudo em troca!') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'queijo') or msgcontains(msg, 'escudo') then if doPlayerRemoveItem(cid,2696,5) == 0 then selfSay('Eu disse 5 QUEIJOS!') addon_state = 0 else selfSay('Obrigado, muito mesmo! Tome, isto pode ser útil para você!') doPlayerAddItem(cid, 2512, 1) talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Next Please...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end end end obrigado Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/ Compartilhar em outros sites More sharing options...
GodBz 6 Postado Março 12, 2010 Share Postado Março 12, 2010 (editado) Eu usei a mesma base de script para fazer um npc que troca itens e deu tudo certo, existe esse npc aqui no forum, se vc o pegou em outro lugar ele pode estar imcompleto, o que eu peguei aqui funcionou perfeitamente, confira na seção de npcs... Editado Março 12, 2010 por GodBz Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/#findComment-852644 Compartilhar em outros sites More sharing options...
george100 5 Postado Março 12, 2010 Autor Share Postado Março 12, 2010 acontece que eu ja testei o outro também. e está bugado entao por isso que vim pedir aqui eu nao faço topicos inuteis. Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/#findComment-852692 Compartilhar em outros sites More sharing options...
GodBz 6 Postado Março 12, 2010 Share Postado Março 12, 2010 (editado) Não disse que seu topco era inutil, se fosse eu não teria respondido, faça o seguinte, use o meu script e modifique-o para os itens q vc deseja: -- NPC de troca - By Conde Sapolocal focus = 0 local talk_start = 0 local target = 0 local following = false local attacking = false local addon_state = 0 function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 end end function onCreatureTurn(creature) end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) msg = string.lower(msg) if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then selfSay('Olá ' .. getCreatureName(cid) .. '...Hiho! eu preciso de ->queijos<- vc viu algum por ai?') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'trade') or msgcontains(msg, 'queijo') then if doPlayerRemoveItem(cid,XXXX,5) == 0 then selfSay('achou alguma queijo?!') addon_state = 0 else selfSay('Vc achou! pegue seu presente!!') doPlayerAddItem(cid, XXXX, 1) talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. getCreatureName(cid) .. '! Obrigado!..') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Se achar mais queijos me avise...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end end end Basta mudar os XXXX em vermelho para o id dos itens e mudar as msgs, eu uso ele no meu server e roda perfeitamente... Creditos: Conde Sapo 98% {quem criou eu acho} GodBz (eu) 2% {arrumei uns bugs) Editado Março 12, 2010 por GodBz Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/#findComment-852768 Compartilhar em outros sites More sharing options...
george100 5 Postado Março 12, 2010 Autor Share Postado Março 12, 2010 pode cre valeu mano POde da closed Topic =) Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/#findComment-852776 Compartilhar em outros sites More sharing options...
GodBz 6 Postado Março 12, 2010 Share Postado Março 12, 2010 (editado) Por nada, precisando só fala Editado Março 12, 2010 por GodBz Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/#findComment-852778 Compartilhar em outros sites More sharing options...
Vilden 137 Postado Março 25, 2010 Share Postado Março 25, 2010 Dúvida sanada, tópico fechado. Link para o comentário https://xtibia.com/forum/topic/129404-resolvido-npc-bugado/#findComment-855766 Compartilhar em outros sites More sharing options...
Posts Recomendados