Npc Que Troca Item Por...

maximusot
em Tutoriais de Scripting

maximusot

avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 05/03/07Posts: 219

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



CLIQUE AKI DEPOIS CLIQUE NO CLICK AQUI DA SEGUNDA LINHA NÃO DEMORA NEM 1 MINUTO


MINHAS METAS

~~~~~~~~~~~~~~
~~
MINHAS METAS~~
~~~~~~~~~~~~~~


1 post (X)
10 posts (X)
20 posts (X)
30 posts (X)
40 posts (X)
50 posts (X)
60 posts (X)
70 posts (X)
80 posts (X)
90 posts (X)
100 posts (X)
120 posts (X)
150 posts (X)
200 posts (X)
300 posts (X)
400 posts (X)
500 posts (X)
600 posts (X)
700 posts (X)
800 posts (_)
900 posts (_)
1000 potsts (_)
1300 posts (_)
1500 posts (_)
1800 posts (_)
2000 posts (_)
----------------------------------------------------

MEUS TRABALHOS

Rustty

Ex - Coordenador de Conteúdo
avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 30/07/07Posts: 151

Olá usuário Xtibia.com

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

 

 

Parabéns.

DaNDaNrOxX

oi mosso
avatar
Marquês
Marquês

INFOS

Grupo: MarquêsRegistrado: 18/01/08Posts: 1455Char no Tibia: Saint Claire

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.

 

 

Entrada na equipe: 23/10/2008 Cargo: Estagiário

Promoção: 25/11/2008 Cargo: Moderador

Promoção: 21/10/2009 Cargo: Coordenador

Remoção: 09/05/2010 Motivo: Estudos

Retorno: 15/11/2010 Cargo: Moderador

Remoção: 20/12/2012.

 

 

darkmale157

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 06/02/08Posts: 89Char no Tibia: Mateuz Dracon Wielky

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




Gostou de Min é Meu Fan ! Use meu Fanbar !


~~ Meus Trabalhos ~~


~~ Minha Cidade ~~

População
Industrias
//Cada Link que voçê entrar, Vai aparecer um Ponto, Mais só da uma vez, Para Entrar de Novo quando sair da internet retorne a entrar no Link, E Aumenta mais um Ponto...

~~ Metas ~~

[X]1.....Post.... SERVO
[X]10...Posts...CAMPONÊS
[X]25...Posts...CAÇADOR
[X]50...Posts...CAVALEIRO
[X]100..Posts...BARONETE
[_]200..Posts...BARÃO
[_]300..Posts...VISCONDE
[_]400..Posts...DUQUE
[_]600..Posts...ARQUEDUQUE
[_]800..Posts...ARISTOCRATA
[_]1000.Posts...REGENTE
[_]1400.Posts...SÁBIO
[_]1800.Posts...SACERDOTE
[_]2500.Posts...PRÍNCIPE


nightshade

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 03/02/08Posts: 18Char no Tibia: Ysuldur

muito bom agora ja sei como fazer

 

 

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

 

cya



Sou fan de..

maximusot

avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 05/03/07Posts: 219

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



CLIQUE AKI DEPOIS CLIQUE NO CLICK AQUI DA SEGUNDA LINHA NÃO DEMORA NEM 1 MINUTO


MINHAS METAS

~~~~~~~~~~~~~~
~~
MINHAS METAS~~
~~~~~~~~~~~~~~


1 post (X)
10 posts (X)
20 posts (X)
30 posts (X)
40 posts (X)
50 posts (X)
60 posts (X)
70 posts (X)
80 posts (X)
90 posts (X)
100 posts (X)
120 posts (X)
150 posts (X)
200 posts (X)
300 posts (X)
400 posts (X)
500 posts (X)
600 posts (X)
700 posts (X)
800 posts (_)
900 posts (_)
1000 potsts (_)
1300 posts (_)
1500 posts (_)
1800 posts (_)
2000 posts (_)
----------------------------------------------------

MEUS TRABALHOS

Tonynh

Miau! É isso ai!
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 07/01/08Posts: 2282Gênero: MasculinoChar no Tibia: Tonynh

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:

maximusot

avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 05/03/07Posts: 219

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



CLIQUE AKI DEPOIS CLIQUE NO CLICK AQUI DA SEGUNDA LINHA NÃO DEMORA NEM 1 MINUTO


MINHAS METAS

~~~~~~~~~~~~~~
~~
MINHAS METAS~~
~~~~~~~~~~~~~~


1 post (X)
10 posts (X)
20 posts (X)
30 posts (X)
40 posts (X)
50 posts (X)
60 posts (X)
70 posts (X)
80 posts (X)
90 posts (X)
100 posts (X)
120 posts (X)
150 posts (X)
200 posts (X)
300 posts (X)
400 posts (X)
500 posts (X)
600 posts (X)
700 posts (X)
800 posts (_)
900 posts (_)
1000 potsts (_)
1300 posts (_)
1500 posts (_)
1800 posts (_)
2000 posts (_)
----------------------------------------------------

MEUS TRABALHOS

vini_xxe

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 03/11/06Posts: 260

Ficou muito bom mesmo

E bem organizadooo

E funcionou direitinho ainda

Vlws mano

=D

Bem na moral galera
Enquanto vocês ficam ae preocupados com uns OT SERVER
com um joguinho MEDIOCRE que nao leva a NADA
A vida ta passando
Comecei a jogar de brincadeira, quando me dei conta
4 ANOS se passaram, e ai, oq eu ganhei?
Perdi muitas minas, perdi muitas festas, muitos jogos :S
PAREI, PEGO GERAL, TO EM TODAS AS FESTAS
Fiquem ae jogando NERDS
Que eu vo vive minha vida
@@@@@@@@@@@@@@@@@@@@@@@@@@@@;

TIBIA, UM JOGO QUE VICIA, E EH PIOR QUE ALCOOL
NAO MATA A PESSOA
SOH ACABA COM SEU CONVIVIO SOCIAL
VOCE DEIXA SUA MAE LA SOZINHA PRA PEGA UM SKILL DE SWORD
WTF?
VC NAO SAI COM A GALERA PRA PEGA MINA, PQ TEM Q UPA --"
NERD !@;

grilodauh

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 09/07/06Posts: 58Char no Tibia: Ursinho Carinhoso

Fiko bem daora o tutorial ta de parabens

[Assinatura Irregular]

765765

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 09/02/08Posts: 28

fiko massa

parabens

merece

up

up

up

BY 765765




FanBar...Te ajudei ??? Gosta de min ??? Usa minha Fanbar



Sou Fan de...

vitiman

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 04/04/07Posts: 100

tava presisando disso vlw