MA

Npc Que Troca Item Por...

Por maximusot, 25 de fev. de 2008 em Tutoriais de Scripting

otserv
tibia
script
13
5.8k
25 de fevereiro de 2008 às 01:08

TOPICO EXCLUSIVO AO XTIBIA.

CREDITOS 100% MEUS, NÃO ACEITO COPIA

 

(EDIT: estou com alguns problemas em algumas cores)

 

 

Bom como vi que muitas pessoas estavam pedindo resolvi fazer um npc de trocar 2 itens por um certo addon...

Este exemplo é o do 1° addon de pirate

Então vamos começar 1° abra data/npc depois copie qualquer arquivo .xml e cole (CTRL + C e CTRL + V) depois clique com botão direito e vá em editar, depois disso apague tudo que estiver escrito lá e cole isso

 

<?xml version="1.0"?>

 

<npc name="pirate addon 1" script="data/npc/scripts/pirate 1.lua" access="3" lookdir="2" autowalk="25">

<mana now="800" max="800"/>

<health now="200" max="200"/>

<look type="151" head="114" body="114" legs="114" feet="0" addons="3"/>

</npc>

 

--Traduzindo

Vermelho: nome do npc

Azul: local onde o arquivo .lua do npc está localizado

Verde: outfit do npc

 

depois abra a pasta data/npc/scripts copie qualquer arquivo .lua de lá e cole...

renomei-o para pirate 1.lua depois abra ele com o bloco de notas apague tudo que estiver dentro e cole issu

 

-- by ADM Leo leonardo caetano

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Tchau!!.')

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('Ola ' .. getCreatureName(cid) .. ' Eu posso lhe dar o Pirate Addon 1, diga help para mais informacoes.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('desculpe, ' .. getCreatureName(cid) .. '! falo com voce jaja.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'help') then

selfSay('Eu posso lhe dar o Pirate Addon 1, se estiver interessado diga: pirate addon 1')

 

 

elseif msgcontains(msg, 'pirate addon 1') then

if getPlayerStorageValue(cid,8009) >= 2 then

selfSay('voce ja tem esse addon.')

 

else if getPlayerStorageValue(cid,8009) == 1 then

selfSay('Precisarei de 100 peg legs, voce as trouxe?')

addon_state = 2

else

setPlayerStorageValue(cid,8009,1)

selfSay('Precisarei de 100 peg legs, voce as trouxe?')

end

end

elseif msgcontains(msg, 'yes') and addon_state == 2 then

if doPlayerRemoveItem(cid,6126,100) == 0 then

selfSay('Desculpe, mas voce nao as trouxe.')

else

selfSay('parabens agora voce e um pirata.')

if getPlayerSex(cid) == 0 then

doPlayerAddAddon(cid, 155, 1)

setPlayerStorageValue(cid,8009,2)

else

doPlayerAddAddon(cid, 151, 1)

setPlayerStorageValue(cid,8009,2)

talk_state = 1

end

end

 

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Ate mais, ' .. getCreatureName(cid) .. '! e volte sempre..')

focus = 0

talk_start = 0

end

end

end

 

 

function onCreatureChangeOutfit(creature)

 

end

 

function onThink()

 

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Proximo...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Tchau!.')

focus = 0

end

end

end

 

--Traduzindo
Vermelho: id do addon, o pirate feminino e 1 seguinifica que é o primeiro addon.
Verde: id do addon, o pirate masculino e 1 seguinifica  que é o primeiro addon
Laranja: id do item peg legs e a quantidade necessaria
Pink: falas do player
Roxo: falas do npc

 

 

Este exemplo é o do 2° addon de pirate

Então vamos lá, 1° abra data/npc depois copie qualquer arquivo .xml e cole (CTRL + C e CTRL + V) depois clique com botão direito e vá em editar, depois disso apague tudo que estiver escrito lá e cole issu

 

<?xml version="1.0"?>

 

<npc name="Addon pirate 2" script="data/npc/scripts/pirate 2.lua" access="3" lookdir="2" autowalk="25">

<mana now="800" max="800"/>

<health now="200" max="200"/>

<look type="155" head="79" body="18" legs="0" feet="114" addons="3"/></npc>

 

[b]--Traduzindo
Vermelho: nome do npc
Azul: local onde o arquivo .lua do npc está localizado
Verde: outfit do npc[/b]

 

depois abra a pasta data/npc/scripts copie qualquer arquivo .lua de lá e cole...

renomei-o para pirate 2.lua depois abra ele com o bloco de notas apague tudo que estiver dentro e cole issu

-- by ADM Leo leonardo caetano

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Tchau!.')

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('ola ' .. getCreatureName(cid) .. ' Eu posso liberar o Pirate Addon 2, mas voce tem de ter feito o Pirate Addon 1, para melhores informacoes diga help.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('desculpe, ' .. getCreatureName(cid) .. '! eu falo com voce ja ja.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'help') then

selfSay('Bem se voce ja fez o Pirate Addon 1 e estiver interessado no Pirate Addon 2, diga: pirate 2')

 

 

elseif msgcontains(msg, 'pirate 2') then

if getPlayerStorageValue(cid,8041) >= 4 then

selfSay('Voce ja tem esse addon.')

 

else if getPlayerStorageValue(cid,8041) == 3 then

selfSay('Precisarei de 1 Ron the Rippers Sabre e 100 Eye Patches, voce os trouxe?')

addon_state = 2

else

setPlayerStorageValue(cid,8041,3)

selfSay('Precisarei de 1 Ron the Rippers Sabre e 100 Eye Patches, voce os trouxe?')

end

end

elseif msgcontains(msg, 'yes') and addon_state == 2 then

if doPlayerRemoveItem(cid,6098,100) == 0 or doPlayerRemoveItem(cid,6101,1) == 0 then

selfSay('Desculpe voce nao os trouxe.')

else

selfSay('Valeu, agora voce possui este addon.')

if getPlayerSex(cid) == 0 then

doPlayerAddAddon(cid, 155, 2)

setPlayerStorageValue(cid,8041,4)

else

doPlayerAddAddon(cid, 151, 2)

setPlayerStorageValue(cid,8041,4)

talk_state = 1

end

end

 

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Tchau, ' .. getCreatureName(cid) .. '! volte sempre..')

focus = 0

talk_start = 0

end

end

end

 

 

function onCreatureChangeOutfit(creature)

 

end

 

function onThink()

 

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Proximo...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Ate mais!.')

focus = 0

end

end

end

 

--Traduzindo

Vermelho: id do addon, o pirate feminino e 2 segunifica que é o segundo addon.

Verde: id do addon, o pirate masculino e 2 segunifica que é o segundo addon

Azul quase preto:id do item Ron the Rippers Sabre e a quantidade necessaria

Laranja: id do item eye patch e a quantidade necessaria

Pink: falas do player

Roxo: falas do npc

Editado Fevereiro 25 por maximusot

RusttyR
02 de março de 2008 às 22:44

Olá usuário Xtibia.com

Seu tutorial foi aprovado, gostaria de parabenizar por acrescentar esse tutorial ao Xtibia.

 

 

Parabéns.

DaNDaNrOxXD
04 de março de 2008 às 10:00

Muito bom maximusot, mas quase todos os servers vem com isto já :D

Mas é bom para quem ainda não tem, obrigado por postar aqui.

2 semanas depois...
darkmale157D
17 de março de 2008 às 23:21

Meu server n tem nada =D arrumei tudo... e apaguei tudo action

nightshadeN
20 de março de 2008 às 23:54

muito bom agora ja sei como fazer

 

 

ahhhh nao vi se alguem ja lhe falou mas pode colocar os creditos do thyranic

 

cya

23 de março de 2008 às 02:05

Não é creditos para o thyranic não foi ele quem fez...

e o npc tá bem diferente do que vem no servidor

 

Atenciosamente,

Maximus

TonynhT
27 de março de 2008 às 19:33

Muito bom! :smile_positivo:

 

mais tipo ta bem explicado e tal..

 

mais quando eu criei o npc aqui, deu erro no "execute" que abre o ot, aparecia todos aqueles nomes "Warning: e seu motivo que apontava o npc" :sad:

27 de março de 2008 às 21:39

É que tem algumas cores que não apareceram e com isso ficou o codigo das cores lá é só você apagar que funciona direitinho

vini_xxeV
31 de março de 2008 às 18:51

Ficou muito bom mesmo

E bem organizadooo

E funcionou direitinho ainda

Vlws mano

=D

TprocheiraT
01 de abril de 2008 às 11:42

Achei legal, só não sei porque ele é tão parecido com os NPCs do Thyrania Oo. Mas de qualquer jeito, muito bom o tópico!

Parabéns!

2 meses depois...
grilodauhG
23 de junho de 2008 às 18:22

Fiko bem daora o tutorial ta de parabens

7657657
23 de junho de 2008 às 18:58

fiko massa

parabens

merece

up

up

up

Editado Junho 23 por 765765

1 mês depois...
vitimanV
27 de julho de 2008 às 15:14

tava presisando disso vlw