Npc Para Servers Com Rpg

zimbituba
em NPCs, monsters e raids

zimbituba

Crystal Server Founder
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 19/01/08Posts: 704Char no Tibia: Atera Knight

Primeiro não sei se é aqui que devo postar :( eu ia postar em tutoriais de script mais tava dando erro dizendo que eu não podia postar lá então caso não seja aqui peço aos moderadores que movam o tópico para a sessão correta. E também não achei aqui no fórum se tiver me descupem.

 

créditos vão para:

LuNaTiC - por criar o tutorial ( não é do Xtibia)

Shynzo - por trazer ao xtibia :)

 

Então agora vamos começar:

 

Existem muitas formas de troca, que muita gente não sabe como colocar, geral as pessoas tentam colocar :

 

buy(cid,2455,1,0)

sell(cid,2455,1,0)

 

 

Mas sempre dava a mesma coisa, ele sempre pega o item sem devolver um....

 

O Script de troca é esse:

 

elseif talk_state == 1 then

if msgcontains(msg, 'yes') then

itemstatus = doPlayerRemoveItem(cid,2379,1)

if itemstatus == 0 then

selfSay('Sorry, you not have this item.')

else

doPlayerAddItem(cid,2148,2)

selfSay('Thanks for this item.')

end

end

talk_state = 0

 

Explicando:

 

Mensagem que o player irá dizer para a troca, no caso, eu fiz um exemplo de uma confirmação.

Esse comando serve para remover o item do player, no caso, uma dagger.

No caso, ai está o tal comando de se o player não tiver o item, ele não trocara o item.

Essa mensagem o NPC falará quando o player não tiver o item para a troca.

Esse comando server para adicionar um item ao player, no caço 2 gps pela dagger.

Essa mensagem o NPC irá falar quando vocês trocarem o item.

 

 

Importante¹: Se for para adicionar mais de 100 gold tem que colocar 2 comando, exemplo: doPlayerAddItem(cid,2148,43) e doPlayerAddItem(cid,2152,2), no caso o player ganhara 243 gps.

 

Aqui está um exemplo de um NPC de Troca:

 

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('Olá ' .. creatureGetName(cid) .. '! Eu te dou um Demon Shield por um Royal Helmet.')

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 focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'troca') or msgcontains(msg,'trade') then

if queststatus == -1 then

selfSay('Você quer trocar um royal helmet por um demon shield?')

talk_state = 1

 

elseif msgcontains(msg, 'exemplo de quest') or msgcontains(msg,'exemplo de quest.') then

selfSay('Você quer trocar um royal helmet por um demon shield?')

talk_state = 2

 

elseif talk_state == 1 then

if msgcontains(msg, 'yes') then

itemstatus = doPlayerRemoveItem(cid,2498,1) <------ Item que será removido para trocar

if itemstatus == 0 then

selfSay('Sorry, you not have items.')

else

doPlayerAddItem(cid,2520,2) <---- Item que o player ganhará na troca

selfSay('Thanks for items.')

end

end

talk_state = 0

 

elseif talk_state == 2 then

if msgcontains(msg, 'yes') then

itemstatus = doPlayerRemoveItem(cid,2498,1)

if itemstatus == 0 then

selfSay('Sorry, you not have items.')

else

doPlayerAddItem(cid,2520,2)

selfSay('Thanks for items.')

end

end

talk_state = 0

 

 

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

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

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('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Agora é só configura como eu disse acima....

Agora vou ensinar como o NPC falará com você apenas se você tiver feito alguma quest.

Depois de:

 

if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4

 

Adicione:

 

and queststatus > 0 then

 

Ficando assim:

 

if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 and queststatus > 0 then

 

Em cima adicione isto:

 

queststatus = getPlayerStorageValue(cid,2520)

 

Esse é o StorageValue da quest, se você fez ela ou não...

 

Em baixo de:

 

elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then

selfSay('Bye human.')

focus = 0

talk_start = 0

end

 

Adicione isto:

 

else

 

selfSay('Você não pode conversar comigo sem fazer a quest')

 

Mensagem que irá aparecer se o player não tiver feito a quest

 

Pronto, estou acabando meu tutorial por aqui, espero ter ajudado as pessoas a fazerem seu server com mais RPG do que o normal.

If you would like to thank me for my Crystal Server and others, feel free to donate.
Paypal: shynzomapper@hotmail.com

Orange

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 20/04/08Posts: 71Char no Tibia: Maskonic

Aprovado --

 

Nota 10

Orange Serv


Server em desenvolvimento
Aguarde um dos melhores servidores de tibia.

Slinix

The Slinix ® TCS Developer
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 19/04/08Posts: 53Char no Tibia: Akilles Palyy

GoGoGo , Vai Ajudar Muitos , Inclusive um Pouco eu , que não sou tão eperte , Go go go team , Tks Shynzo.

slinixmapper.jpgsimbo.jpg

 

 

slinixfanbar2dz1.jpguserlovefirefox7dm4arohvk6.gif

 

headerqh0.jpg

opensourcelogo.jpg

maximusot

avatar
Barão
Barão

INFOS

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

Valeu por trazer ao xtibia. (pelomenos você colocou os créditos)

nota: 8

APROVADO

 

 

só me faça uma favor, mude isso:

tenque

Em cima dicione isto:

para isso:

tem que

Em cima adiciona isto:



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

zimbituba

Crystal Server Founder
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 19/01/08Posts: 704Char no Tibia: Atera Knight

hehe ja vou rrumar é pq fiz na madruga tudo no escuro

e outra coisa tudo que eu posto no Xtibia coloco os créditos pois nao acho justo roubaros créditos dos outros :)

If you would like to thank me for my Crystal Server and others, feel free to donate.
Paypal: shynzomapper@hotmail.com

gabrifer

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 26/10/07Posts: 100Char no Tibia: Climber Man

Muito bom!

Organizado e bem explicado!

Parabéns e APROVADO!

Abraços,

Escalador.



Sou Fan:




Ès meu Fan?

kruxdudu

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 26/07/07Posts: 284

Precisa dizer que vc me ajudou denovo? (Como sempre)

auhauha

Parabéns caraaa

 

Vc sempre mi ajuda :p

 

Abraços!

Sou fan de:



Flyw

ϟ Yeah baby,Yeah!
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 28/03/08Posts: 423

Cabei de vira seu fã >.<

Att, Lucas F. Mendonça - FlyWorld

 

orkutqr.pngϟ Lucas F Mendonça

msnicon.png lGk@SoldatX.com / Flyw_@Live.com

skypeicon.png Lucas.Ferreira.Maoe

zimbituba

Crystal Server Founder
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 19/01/08Posts: 704Char no Tibia: Atera Knight

o0

mais um fan

omg

If you would like to thank me for my Crystal Server and others, feel free to donate.
Paypal: shynzomapper@hotmail.com

PedroHEll

Brasil
avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 12/04/08Posts: 191

Aeeew muito bom.

 

=DD

Pedro Henrique



pedrohellsign.png

zimbituba

Crystal Server Founder
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 19/01/08Posts: 704Char no Tibia: Atera Knight

Valeu galera

comenta ai plz

If you would like to thank me for my Crystal Server and others, feel free to donate.
Paypal: shynzomapper@hotmail.com

FelipeAugustoGuimaraesGome

Eu??
avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 30/06/08Posts: 117Char no Tibia: Menor De Rook

Shynzo Seu safado kkkkkkkkk copiou minha letra ne :surprised: kkkkk tem problema nao mas eu gostei desse NPC muito bom xD Flws

furiavr

avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 27/04/08Posts: 156Char no Tibia: Retired!

Nossa vey parabéns mais uma vez...muito bom mesmo!!!

gto222

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/05/08Posts: 68

nossa

muito bom o tuto

vai ajuda muita gente

vlw



Wufer Outfit

me use na sua fake[/img]

Metas
[X]1....Post....SERVO............
[X]10...Posts...CAMPONÊS.....
[X]25...Posts...CAÇADOR......
[X]50...Posts...CAVALEIRO....
[_]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.....


-------------------------------------------------------------------------

te ajudei???gosta de mim??? use minha fanbar


Sou Fan


Users