LU

Saiba Tudo Sobre Npc,monster E Spells!

Por Lucas Rap, 25 de set. de 2006 em Tutoriais de Scripting

tibia
script
4.0 (5)
171
45.1k
MarcolinoGODM
04 de julho de 2007 às 12:11

Parabens! :D Me ajudou muito.

Obrigado e continue assim! ;)

Editado Julho 4 por Albert José

4 semanas depois...
zabuZ
30 de julho de 2007 às 17:09

:blink: amigo me ajuda com uma coisa , meu serv eh 8.0

 

e o poison field/ fire field / fire bomb / magic wall

 

estao demorando mt para sair qeria saber detalhadamente como

 

abaixar o tempo de duraçao deles

zabuZ
30 de julho de 2007 às 17:40

sabe fazer isso ?

MuadogibM
04 de agosto de 2007 às 13:02

bom tuto...mas o exemplo do npc podia ser mais util...eu pelo menos acho mto ruim um npc q sumona bixo pra vc, daki a poco vai virar pokemon >.<

só p deixar claro, achei o tutorial bom, só naum gostei do exemplo.

tentei fazer um npc pro citizen addon, mas parece q tem um erro...qm puder ajudar eu agradeço...

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('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('Hello ' .. creatureGetName(cid) .. '! How can i help you?.')

 

focus = cid

 

talk_start = os.clock()

 

 

 

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

 

selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

 

 

 

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

 

selfSay('Good bye, ' .. creatureGetName(cid) .. '!')

 

focus = 0

 

talk_start = 0

 

 

 

elseif focus == cid then

 

talk_start = os.clock()

 

 

 

if msgcontains(msg, 'addons') then

 

if isPremium(cid) then

 

selfSay('Ah, right, almost forgot about the backpack! Have you brought me 80 pieces of minotaur leather as requested?.')

 

talk_state = 0

 

else

 

selfSay('I have nothing for you.')

 

talk_state = 0

 

end

 

end

 

 

 

------------------------------------start addons-------------------------------------------

 

 

 

if msgcontains(msg, 'first addon') then

 

if isPremium(cid) then

 

if haveItem(cid, 5878, 80, 0, 1) == 1 then

 

selfSay('Did you bring me 80 minotaur leathers?')

 

talk_state = 1

 

else

 

selfSay('Alright then, if you bring me 100 pieces of fine minotaur leather I will see what I can do for you. You probably have to kill really many minotaurs though... so good luck!')

 

talk_state = 0

 

end

 

else

 

selfSay('Sorry, you need a premium account to get addons.')

 

talk_state = 0

 

end

 

 

 

elseif msgcontains(msg, 'second addon') then

 

if isPremium(cid) then

 

if haveItem(cid, 5890, 30, 0, 1) == 1 and haveItem(cid, 5902, 50, 0, 1) == 1 and haveItem(cid, 2480, 1, 0, 0) == 1 then

 

selfSay('Did you bring me 30 chicken feathers, 50 honeycombs and 1 legion helmet?')

 

talk_state = 2

 

else

 

selfSay('Okay, here we go, listen closely! I need a few things... a basic hat of course, maybe a legion helmet would do. Then about 30 chicken feathers... and 50 honeycombs as glue. That's it, come back to me once you gathered it!')

 

talk_state = 0

 

end

 

else

 

selfSay('Sorry, you need a premium account to get addons.')

 

talk_state = 0

 

end

 

------------------------------------message confirmation-------------------------------------------

 

 

 

if msgcontains(msg, 'no') then

 

selfSay('Ok than.')

 

talk_state = 0

 

 

 

elseif msgcontains(msg, 'yes') and talk_state == 1 then

 

talk_state = 0

 

if haveItem(cid, 5878, 80, 0, 1) == 1 then

 

xx = doPlayerAddAddon(cid, 1, 1)

 

if xx == 1 or xx == 3 then

 

if doPlayerRemoveItem(cid, 5878, 80) == 1 then

 

selfSay('Just in time! Your backpack is finished. Here you go, I hope you like it.')

 

end

 

else

 

selfSay('Sorry, you already have this addon.')

 

end

 

else

 

selfSay('Sorry, you dont have these items.')

 

end

 

 

 

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

 

talk_state = 0

 

if haveItem(cid, 5890, 30, 0, 1) == 1 and haveItem(cid, 5902, 50, 0, 1) == 1 and haveItem(cid, 2480, 1, 0, 0) == 1 then

 

xx = doPlayerAddAddon(cid, 1, 2)

 

if xx == 2 or xx == 3 then

 

if doPlayerRemoveItem(cid, 5890, 30) == 1 and doPlayerRemoveItem(cid, 5902, 50) == 1 and doPlayerRemoveItem(cid, 2480, 1) == 1 then

 

selfSay('Great job! That must have taken a lot of work. Okay, you put it like this... then glue like this... here you are!')

 

end

 

else

 

selfSay('Sorry, you already have this addon.')

 

end

 

else

 

selfSay('Sorry, you dont have these items.')

 

end

 

 

 

function onCreatureChangeOutfit(creature)

 

end

 

 

 

 

 

function onThink()

 

if focus > 0 then

 

x, y, z = creatureGetPosition(focus)

 

myx, myy, myz = selfGetPosition()

 

--npc by Soulblaster and Zorzin--

 

 

 

if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then

 

selfTurn(1)

 

end

 

if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then

 

selfTurn(3)

 

end

 

if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then

 

selfTurn(2)

 

end

 

if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then

 

selfTurn(0)

 

end

 

if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then

 

selfTurn(2)

 

end

 

if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then

 

selfTurn(0)

 

end

 

if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then

 

selfTurn(3)

 

end

 

if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then

 

selfTurn(1)

 

end

 

if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then

 

selfTurn(2)

 

end

 

if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then

 

selfTurn(0)

 

end

 

if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then

 

selfTurn(3)

 

end

 

if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then

 

selfTurn(1)

 

end

 

if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then

 

selfTurn(2)

 

end

 

if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then

 

selfTurn(0)

 

end

 

if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then

 

selfTurn(3)

 

end

 

if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then

 

selfTurn(1)

 

end

 

end

 

 

 

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

eu tinha o npc que vendia td os addons, mas tinha alguns dando erro e decidi fazer uns separados...mas ta dando esse erro qdo abre o ot: expected '>' near 's'

alguem sabe pq?

articussA
06 de agosto de 2007 às 19:15

Pow cara, Tuto muito bom, mais eu tava precisando de uma ajuda pra editar itens .. ou como criar um tbm .. se vc puder mi explicar alguma coisa .. agradeço desde já ;D

 

abraço

1 mês depois...
rookroxzR
20 de setembro de 2007 às 18:21

o.0 melhor tutorial de script's q ja vi e consegui compreende hehe!parabens pelo tutorial!

 

continue assim apavorando xD

salvatoreS
21 de setembro de 2007 às 18:32

muito bom, tutorial excelenteee

 

explicando tudindo e detalhadamente

parabens cara !

 

vai ajudar muita gente,

abraços!

PessottoP
23 de setembro de 2007 às 17:53

Mtu bom......

ajudo mtas pessoas......

vlw ae

flo

NanzinhuwN
23 de setembro de 2007 às 19:29

Funciona em ot 8.0?

2 meses depois...
williamstsW
23 de novembro de 2007 às 16:36

Concordo plenamente com os usuarios acima,

esse é um otimo tutorial, no qual se encontra

tudo bem explicado, para novatos como 'eu'

ele será muito util! :bigsmile:

Otimo tutorial Lucas Rap, continue a compartilhar

seus tutors com nosco.

xD

BartaB
23 de novembro de 2007 às 18:38

Aeeee Muito Bom Tutorial . . .!!!

Gostei Muito ,Muito Show ! Bem Explicado

1 mês depois...
gustavocordeiroG
08 de dezembro de 2007 às 12:56

Otimo tuto cara Parabens=]

 

Vc pode me dizer como poem o npc depois de feito no mapa? Ou como add o npc no mapa editor 8.0

 

abraços

crawzinhuhC
10 de dezembro de 2007 às 14:28

Bom tutorial

Aprovado =*

Cya.

xitaX
11 de dezembro de 2007 às 14:30

NOssa veio adorei o topico 1 dos melhores que eu ja vi

Vlww Vai ajudar muito aii quem souber de um bom Mapa que venha com mapa editor me manda pelo msn Vlwwww

alex_nasicimento_9@hotmail.com

vinitc2V
13 de dezembro de 2007 às 18:41

eu ja sabia dessas coisa mais ajuda os iniciantes e bom alem disso

foi bem explicado achei muito bom por min xD