Ir para conteúdo
Entre para seguir isso  
Musicman

[N:Fácil]NPC 2º Promoção, 3º Promoção...

Recommended Posts

Musicman    0
Musicman

[ ! ] Aprenda a editar NPC Promotion.

[?] Olá usuários, procurei no fórum um tutorial sobre o assunto e não encontrei, então vamos começar?

 

[+] Perceba que as vocações são classificadas de 4 em 4. Um sorcerer tem a vocação id nº 1, sendo assim, um master sorcerer terá a vocação id nº 5. Baseado nisso, fica fácil editar o NPC para criar 2º, 3º e mais promoções.

  • NPC normal de Premium e Promotion:

local focus = 0
local talk_start = 0
local target = 0
local days = 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('Hello ' .. creatureGetName(cid) .. '! I sell premiums and promotions.')
        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, 'promotion') or msgcontains(msg, 'promote') then
            if getPlayerVocation(cid) > 4 then
                selfSay('Sorry, you are already promoted.')
                talk_state = 0
            elseif getPlayerLevel(cid) < 20 then
               selfSay('Sorry, you need level 20 to buy promotion.')
               talk_state = 0
           elseif not isPremium(cid) then
               selfSay('Sorry, you must be premium to buy promotion.')
               talk_state = 0
           else
               selfSay('Do you want to buy promotion for 20k?')
               talk_state = 1
           end

       elseif msgcontains(msg, 'premium') or msgcontains(msg, 'premmy') then
           selfSay('Do you want to buy 7 days of premium for 7k?')
           talk_state = 2

       elseif talk_state == 1 then
           if msgcontains(msg, 'yes') then
               if pay(cid,20000) then
                   doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
                   selfSay('You are now promoted!')
               else
                   selfSay('Sorry, you do not have enough money.')
               end
            end
           talk_state = 0

       elseif talk_state == 2 then
           if msgcontains(msg, 'yes') then
               if pay(cid,7000) then
                   selfSay('/premium '.. creatureGetName(cid) ..', 7')
                   selfSay('You have 7 days of premium more!')
               else
                   selfSay('Sorry, you do not have enough money.')
               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()
   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

[+] Entendo o texto para edição.

  • O texto a baixo se refere a um NPC, as funções básicas, nesta parte não se edita nada, vejamos:

local focus = 0

local talk_start = 0

local target = 0

local days = 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

  • O texto abaixo refere-se à funções de mensagens, conversa em geral com NPC, aqui deve-se fazer a edição:

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) .. '! I sell premiums and promotions.')

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, 'promotion') or msgcontains(msg, 'promote') then

if getPlayerVocation(cid) > 4 then

selfSay('Sorry, you are already promoted.')

talk_state = 0

elseif getPlayerLevel(cid) < 20 then

selfSay('Sorry, you need level 20 to buy promotion.')

talk_state = 0

elseif not isPremium(cid) then

selfSay('Sorry, you must be premium to buy promotion.')

talk_state = 0

else

selfSay('Do you want to buy promotion for 20k?')

talk_state = 1

end

 

elseif msgcontains(msg, 'premium') or msgcontains(msg, 'premmy') then

selfSay('Do you want to buy 7 days of premium for 7k?')

talk_state = 2

 

elseif talk_state == 1 then

if msgcontains(msg, 'yes') then

if pay(cid,20000) then

doPlayerSetVocation(cid, getPlayerVocation(cid)+4)

selfSay('You are now promoted!')

else

selfSay('Sorry, you do not have enough money.')

end

end

talk_state = 0

 

elseif talk_state == 2 then

if msgcontains(msg, 'yes') then

if pay(cid,7000) then

selfSay('/premium '.. creatureGetName(cid) ..', 7')

selfSay('You have 7 days of premium more!')

else

selfSay('Sorry, you do not have enough money.')

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()

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

  • Nesta explicação, as palavras destacadas por cor e em negrito são as que devem ser mudadas para a edição:

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

selfSay('
Hello
' .. creatureGetName(cid) .. '
! I sell premiums and promotions.
')

 

O que você deve dizer para ativar a conversa;

A distância que você precisa estar para o NPC te ouvir;

O nome do char que está falando com o NPC;

O que o NPC lhe falará.

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

 

O que o NPC falará se estiver ocupado.

O nome do char que está falando com o NPC.

 

if msgcontains(msg, '
promotion
') or msgcontains(msg, '
promote
') then

if getPlayerVocation(cid) > 4 then

selfSay('
Sorry, you are already promoted.
')

 

O que você ira dizer para pedir a promotion;

O que o NPC dirá se você já estiver promovido.

 

elseif getPlayerLevel(cid)
< 20
then

selfSay('
Sorry, you need level 20 to buy promotion.
')

 

O level necessário para se promover;

O que o NPC dirá se não tiver o level necessário.

 

elseif
not isPremium
(cid) then

selfSay('
Sorry, you must be premium to buy promotion.
')

 

Se o char não for P.A;

Mensagem dizendo que o char precisa ser P.A para poder comprar promotion.

 

selfSay('
Do you want to buy promotion for 20k?
')

talk_state = 1

 

NPC perguntando se deseja comprar a promotion por 20k (20000 moedas de ouro).

 

elseif msgcontains(msg, '
premium
') or msgcontains(msg, '
premmy
') then

selfSay('
Do you want to buy 7 days of premium for 7k?
')

talk_state = 2

 

O que o player deverá dizer para comprar P.A;

NPC perguntando se deseja comprar P.A por 7 dias num valor de 7k (7000 moedas de ouro)

 

elseif talk_state == 1 then

if msgcontains(msg, '
yes
') then

if pay(cid,
20000
) then

doPlayerSetVocation(cid,
getPlayerVocation(cid)+4
)

selfSay('
You are now promoted!
')

 

O que o player deve dizer para aceitar;

O valor que o player irá pagar (20k ou 20000 moedas de ouro);

Adicionando +4 ids de vocation;

NPC dizendo que você foi promovido.

 

selfSay('
Sorry, you do not have enough money.
')

 

O que o NPC dirá se você não tiver o valor suficiente em moedas de ouro (não precisa ser necessariamente em moedas de ouro, mas você tem que ter este valor).

 

elseif talk_state == 2 then

if msgcontains(msg, '
yes
') then

if pay(cid,
7000
) then

selfSay('
/premium
'.. creatureGetName(cid) ..',
7
')

selfSay('
You have 7 days of premium more!
')

 

Resposta do player para a pergunta a respeito de P.A;

Valor pago pelo player para comprar a P.A (7k ou 7000 em moedas de ouro);

Comando utilizado pelo NPC para ofertar a P.A e a quantidade de dias;

NPC dizendo que você tem 7 dias de P.A.

 

selfSay('
S
orry, you do not have enough money.
')

 

O que o NPC dirá se você não tiver o valor suficiente em moedas de ouro (não precisa ser necessariamente em moedas de ouro, mas você tem que ter este valor).

 

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

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

focus = 0

talk_start = 0

 

O que você diz para se despedir;

Distância necessária para o NPC lhe ouvir;

O que o NPC dirá se você despedir-se dele;

O nome do char que está a conversar com o NPC.

 

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

if focus > 0 then

selfSay('
Next Please...
')

 

Tempo que você te para ficar inativo na conversa;

O que o NPC dirá se você ultrapassar o tempo.

 

if getDistanceToCreature(focus)
> 5
then

selfSay('
Good bye then.
')

 

Distância que você deve se afastar para encerrar a conversa com o NPC;

O que NPC dirá se você se afastar.

 

 

  • Mas Liqnkr, o que eu faço agora?

[+]Agora que você sabe o que é o que, pode-se editar o NPC ao seu jeito, pode-se mudar as falas, o level, o valor, entre outros.

 

[+] Para criar NPCs para outras promoções, você edita o seguinte:

if msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then

if getPlayerVocation(cid) > 4 then

selfSay('Sorry, you are already promoted.')

talk_state = 0

elseif getPlayerLevel(cid) < 20 then

selfSay('Sorry, you need level 20 to buy promotion.')

talk_state = 0

elseif not isPremium(cid) then

selfSay('Sorry, you must be premium to buy promotion.')

talk_state = 0

else

selfSay('Do you want to buy promotion for 20k?')

talk_state = 1

end

[+] Onde:

 

if getPlayerVocation(cid)
> 4
then

 

Como a contagem dos ids começa sempre do inicial, para 2º promotion deve utilizar "> 8", para 3º promotion usa-se "> 12", assim por diante, sempre de 4 em 4.

 

elseif getPlayerLevel(cid)
< 20
then

selfSay('
Sorry, you need level 20 to buy promotion.
')

 

Aqui é level necessário, você edita da forma que bem entender, por exemplo: se quer que a segunda promotion seja no level 100, deve-se colocar "< 100", para level 200, deve-se colocar "< 200", e assim por diante, tudo depende das rates do seu server, pois seria sem graça uma promoção no level 1000 se as rates são iguais as do Tibia Global;

A mensagem que o NPC dirá se você não ter o Level necessário, no caso do level necessário ser 100, ficará "Sorry, you need level 100 to buy promotion."

 

selfSay('
Do you want to buy promotion for 20k?
')

 

Aqui é preço cobrado para se promover.

 

  • Encerrando...

[+]Desnecessário dizer que deve-se trocar todas as falas, para um melhor entendimento do player ao conversar com o NPC, como por exemplo, na segunda promotion o NPC dira: I sell second promotion ao invés de dizer somente: I sell promotion.

 

[+] Espero que este seja do entendimento de todos, espero que ajude aqueles que necessitavam destas informações. Não sou scripter, apenas leio o script e procuro entender o significado, se estiver algo errado, me corrijam por favor.

 

  • Aos moderadores...

[+]Se este não estiver dentro das regras, conforme o permitido ou com dificuldade de visualização, favor me reportar via MP para correção. Grato

 

see you later...

Compartilhar este post


Link para o post
Compartilhar em outros sites
vHp    6
vHp

Ótimo :)

Aprovado.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Musicman    0
Musicman

@DD: Obrigado Dragon Dark, por aprovar este tutorial, é um sinal de que estou evoluindo em minha jornada rumo ao profissionalismo.

see you later ...

Compartilhar este post


Link para o post
Compartilhar em outros sites
RobinhoOo    0
RobinhoOo

Mto bom tuto Oo fiko bom msm, deve te demorado em xD

Compartilhar este post


Link para o post
Compartilhar em outros sites
Musicman    0
Musicman

@Rob: Na verdade eu não sabia nada sobre isso, ai resolvi pegar o NPC e estudá-lo, então entendi e resolvi postar aqui.

 

see you later...

Compartilhar este post


Link para o post
Compartilhar em outros sites
cleyson    0
cleyson

eu abri o npc...

mais num tinha nada desses code lah...

sera q eu abri no lugar certo, foi na pasta npc do data, peguei o npc Johnny

e ajuda

vlw

Compartilhar este post


Link para o post
Compartilhar em outros sites
Musicman    0
Musicman

Dentro da pasta NPC, há os arquivos xml, dentro da pasta scripts, que fica dentro da pasta NPC, há os arquivos lua.

 

Um arquivo lua é aquele que carrega o script do NPC, já os arquivos xml, servem para o server "LER" o NPC.

 

Os NPCs são editados nos arquivos .lua, dentro da pasta scripts, que fica dentro da pasta NPC, que fica dentro da pasta data, que fica dentro da pasta do server.

 

No caso do Johnny, em xml fica:

 

<?xml version="1.0"?>

 

<npc name="Johnny" script="data/npc/scripts/promote.lua" access="3" lookdir="2">

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

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

<look type="133" head="114" body="119" legs="132" feet="114"/>

</npc>

 

Endereço do local onde está o arquivo .lua referido ao Johnny. (pasta data/pasta NPC/pasta scripts/arquivo.lua).

 

O arquivo correspondente ao Johnny é o arquivo promote.lua, onde ele contém os scripts, segue abaixo:

 

local focus = 0
local talk_start = 0
local target = 0
local days = 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('Hello ' .. creatureGetName(cid) .. '! I sell premiums and promotions.')
        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, 'promotion') or msgcontains(msg, 'promote') then
            if getPlayerVocation(cid) > 4 then
                selfSay('Sorry, you are already promoted.')
                talk_state = 0
            elseif getPlayerLevel(cid) < 20 then
               selfSay('Sorry, you need level 20 to buy promotion.')
               talk_state = 0
           elseif not isPremium(cid) then
               selfSay('Sorry, you must be premium to buy promotion.')
               talk_state = 0
           else
               selfSay('Do you want to buy promotion for 20k?')
               talk_state = 1
           end

       elseif msgcontains(msg, 'premium') or msgcontains(msg, 'premmy') then
           selfSay('Do you want to buy 7 days of premium for 7k?')
           talk_state = 2

       elseif talk_state == 1 then
           if msgcontains(msg, 'yes') then
               if pay(cid,20000) then
                   doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
                   selfSay('You are now promoted!')
               else
                   selfSay('Sorry, you do not have enough money.')
               end
            end
           talk_state = 0

       elseif talk_state == 2 then
           if msgcontains(msg, 'yes') then
               if pay(cid,7000) then
                   selfSay('/premium '.. creatureGetName(cid) ..', 7')
                   selfSay('You have 7 days of premium more!')
               else
                   selfSay('Sorry, you do not have enough money.')
               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()
   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

 

Feito tudo isso, não esqueça de colocar o NPC no mapa, através do respaw. Você pode fazer isso pelo map-editor, onde, para adiciona-lo no map-editor, você precisa ir em: pasta map-editor/arquivo creatures.xml, e adicionar a tag:

 

<creature looktype="133" head="114" body="119" legs="132" feet="114" name="Johnny" type="npc" />

 

Para fazer isso manualmente, vá em pasta do server/pasta data/pasta world/arquivo spawn.xml, adicione a tag:

 

<spawn centerx="x" centery="x" centerz="x" radius="5">

<npc name="Johnny" x="0" y="0"/>

 

esta é a posição do NPC no mapa.

 

Espero ter sido claro, se estiver errado alguém corrija por favor.

 

see you later...

Compartilhar este post


Link para o post
Compartilhar em outros sites
cleyson    0
cleyson

ok vlw mano aju mtu

vlw mesmo...

Compartilhar este post


Link para o post
Compartilhar em outros sites
Musicman    0
Musicman

@Cleyson: Mais uma vez não foi nada. Me agrada o fato de poder ter te ajudo com um tutorial meu, imagine que eu fiz este ontem às 23:11. Por pouco não poderia te ajudar.

 

 

Uma dica: Quando tiver dúvidas, procure na seção de dowloads ou tutoriais, além de você poder conferir tudo passo-a-passo, você pode achar outras coisas interessantes para seu server ao pesquisar pelas páginas.

 

see you later...

Compartilhar este post


Link para o post
Compartilhar em outros sites
cleyson    0
cleyson

tipo como altera o valor do premium, tipo o level vc pois como faz, mais o valor naum...

to perdido me ajuda...

Compartilhar este post


Link para o post
Compartilhar em outros sites
cleyson    0
cleyson

ja achei , numprecisa responde naum, vlw

Compartilhar este post


Link para o post
Compartilhar em outros sites
Musicman    0
Musicman

Troque a fala para dar sentido ao NPC:

 

selfSay('Do you want to buy 7 days of premium for 7k?

 

onde está escrito 7k, coloque o novo valor. EX: 9k

Modifique aqui:

 

if pay(cid,7000) then

 

Onde está escrito 7000, modifique pelo mesmo valor que colocou na tag acima citada. No meu exemplo ficará 9000.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Print Screen    1
Print Screen

OMG

muito muito bom em cara...

 

Yaap~~•

Compartilhar este post


Link para o post
Compartilhar em outros sites
Blazeiker    0
Blazeiker

Cara...

 

Onde q fica issu aqi ó

 

<?xml version="1.0"?>

 

<npc name="Johnny" script="data/npc/scripts/promote.lua" access="3" lookdir="2">

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

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

<look type="133" head="114" body="119" legs="132" feet="114"/>

</npc>

 

 

Nem sei onde q fica issu, fala ae \o/

Compartilhar este post


Link para o post
Compartilhar em outros sites
kiko5    0
kiko5

otimo topico,

gostei muito

Compartilhar este post


Link para o post
Compartilhar em outros sites
Musicman    0
Musicman

@Blazeiker: Isso aí é o NPC em sí.

 

Ele fica dentro da pasta data/npc.

 

<?xml version="1.0"?>

 

<npc name="Johnny" script="data/npc/scripts/promote.lua" access="3" lookdir="2">

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

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

<look type="133" head="114" body="119" legs="132" feet="114"/>

</npc>

este é o endereço do local onde deve estar o script referente a este NPC, no caso o nome do script é promote.lua

 

De nada irá adiantar se você fizer o script e não fizer o NPC. Você deve fazer o NPC para colocá-lo no mapa e o script é para o NPC interagir com o player e dar a promotion.

Compartilhar este post


Link para o post
Compartilhar em outros sites
arlindo    0
arlindo

Boa cara continue assim e va sempre melhorando muito bom ^^

Compartilhar este post


Link para o post
Compartilhar em outros sites
otserv1992    0
otserv1992

ROx xD, Aprovado

Compartilhar este post


Link para o post
Compartilhar em outros sites
[ B a l i l l o ]    0
[ B a l i l l o ]

Tutorial está muito bem organizado, parabens!

Continue assim.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Addicted    1
Addicted

Perfeito hein?

Parabéns!

Obrigado por postar! :)

Compartilhar este post


Link para o post
Compartilhar em outros sites

Faça login para comentar

Você vai ser capaz de deixar um comentário após fazer o login



Entrar Agora
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×