Pokedex System

Instalando Novos Pokes na Pokedex

 
Bom o script está simples mas esta bem funcional,
esse primeiro estarei ensinando como criar pokedex system em seu server e o segundo e como colocar novos pokes na pokedex , vamos lá
 
Na pasta actions abra a pasta scripts, crie uma pasta chamada pokemon e dentro dela um arquivo LUA e nomeie-o para pokedex.lua e cole isso:
 
function onUse(cid, item, fromPos, itemEx, toPos)
 
local pokemon = itemEx.uid
local pokemons = {
{"Bulbasaur", "1.txt", 11395, 20, 100, "name", 99101},
{"Ivysaur", "2.txt", 11396, 20, 100, "Ivysaur", 99102},
}
 
for _,n in pairs(pokemons) do
if isSummon(pokemon) then
local Dex = io.open('data/pokedex/' .. n[2],'r')
if getCreatureName(pokemon) == n[1] and getPlayerLevel(cid) >= n[4] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
doPlayerAddExperience(cid, n[5])
setPlayerStorageValue(cid, n[7], 1)
elseif getCreatureName(pokemon) == n[1] and getPlayerLevel(cid) < n[4] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need level " .. n[4] .. " to unlock this pokemon.")
elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
end
Dex:close()
elseif isMonster(pokemon) then
local Dex = io.open('data/pokedex/' .. n[2],'r')
if getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
doPlayerAddExperience(cid, n[5])
setPlayerStorageValue(cid, n[7], 1)
elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
end
Dex:close()
end
end
 
return true
 
end
 
 
 
agora vá na pasta actions e abra o actions.xml
e adicione esta tag em qualquer lugar:
 
<action itemid="xxxx" event="script" value="pokemon/pokedex.lua" allowfaruse="1" blockwalls="1"/> 
 
 
Substitua o xxxx pelo item que quer usar como pokedex.
 
 

Agora na pasta data crie uma outra pasta

chamada pokedex e salve este texto dentro

da pasta pokedex e nomeie-o para nomes

numerados: 1.txt, 2.txt, 3.txt ...

 

Name: Bulbasaur

Type: Grass
Requires Level: 20
 
Moves:
Quick Attack - m1 - level 20
Razor Leaf - m2 - level 20
Vine Whip - m3 - level 20
Headbutt - m4 - level 20
Leech Seed - m5 - level 22
Solar Beam - m6 - level 40
Sleep Powder - m7 - level 35
Stun Spore - m8 - level 28
Poison Powder - m9 - level 26
 
Evolutions:
 
Bulbasaur, requires level 20
Ivysaur, requires level 40
Vanusaur, requires level 80
 
Habilities:
Cut

 

 

Para editar nesta parte basta mudar de acordo com a legenda:

 
Vermelho : Nome. ( Mude sempre ! )
Laranja : Tipo do pokemon.
( Mude caso mudar o tipo do pokemon. ex: mudar de bulbasaur para squirtle )
Azul : Level requerido para ser usado.
( Mudar sempre ! )
Preto : Lista de movimentos.
( Mude quando possivel, para saber os movimentos acesse : Centro Pokemon - Lista de Pokemons
Rosa : Lista de Evolução do pokemon que tem o nome citado no primeiro item da legenda.
( Mude quando for mudar o tipo do pokemon )
Amarelo : Lista de habilidades
( Fly, Surf, Ride, Dig, Cut, Rock Smash, Teleport, Control Mind e None
( Use none somente quando o pokemon não puder exercer nenhuma habilidade.
 
 

Editando Pokedex.

Agora vou ensinar a editar essa parte:

 

 

function onUse(cid, item, fromPos, itemEx, toPos)
 
local pokemon = itemEx.uid
local pokemons = {
{"Bulbasaur", "1.txt", 11395, 20, 100, "name", 99101},
{"Ivysaur", "2.txt", 11396, 20, 100, "Ivysaur", 99102},
}
 
for _,n in pairs(pokemons) do
if isSummon(pokemon) then
local Dex = io.open('data/pokedex/' .. n[2],'r')
if getCreatureName(pokemon) == n[1] and getPlayerLevel(cid) >= n[4] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
doPlayerAddExperience(cid, n[5])
setPlayerStorageValue(cid, n[7], 1)
elseif getCreatureName(pokemon) == n[1] and getPlayerLevel(cid) < n[4] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need level " .. n[4] .. " to unlock this pokemon.")
elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
end
Dex:close()
elseif isMonster(pokemon) then
local Dex = io.open('data/pokedex/' .. n[2],'r')
if getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
doPlayerAddExperience(cid, n[5])
setPlayerStorageValue(cid, n[7], 1)
elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
end
Dex:close()
end
end
 
return true
 
end

 

 
Configure de acordo com a legenda:
 
Vermelho : Nome do pokemon. ( Sempre mude ! )
Laranja : Arquivo que o script irá ler para mostrar o dex. ( Sempre mude ! )
Azul : Imagem que aparecerá no superior esquerdo. ( Foto do pokemon de preferência ( Sempre mude ! ) )
Cinza : Mude para o nome do pokemon citado no primeiro item da legenda
 
 
Se der erro...
 
Se der erro basta vc ir na pasta data\lib do seu server, criar um arquivo .lua com o nome issummon.lua e adicionar isto:
 
 
function isSummon(sid)
    for i, pid in ipairs(getPlayersOnline()) do
        for c, cid in pairs(getCreatureSummons(pid)) do
            if (cid == sid) then
                return true
            end
        end 
    end
    return false
end
 
Pronto!
 
 
Instalando + pokemons na dex
Em data\actions\scripts\pokemon abra o arquivo pokedex.lua onde vc encontrará isso:
 
 
 
 
 
function onUse(cid, item, fromPos, itemEx, toPos)
 
local pokemon = itemEx.uid
local pokemons = {
{"Bulbasaur", "1.txt", 11395, 20, 100, "name", 99101},
{"Ivysaur", "2.txt", 11396, 20, 100, "Ivysaur", 99102},
}
 
for _,n in pairs(pokemons) do
if isSummon(pokemon) then
local Dex = io.open('data/pokedex/' .. n[2],'r')
if getCreatureName(pokemon) == n[1] and getPlayerLevel(cid) >= n[4] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
doPlayerAddExperience(cid, n[5])
setPlayerStorageValue(cid, n[7], 1)
elseif getCreatureName(pokemon) == n[1] and getPlayerLevel(cid) < n[4] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need level " .. n[4] .. " to unlock this pokemon.")
elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
end
Dex:close()
elseif isMonster(pokemon) then
local Dex = io.open('data/pokedex/' .. n[2],'r')
if getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) <= 0 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
doPlayerAddExperience(cid, n[5])
setPlayerStorageValue(cid, n[7], 1)
elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
doShowTextDialog(cid, n[3], Dex:read("*all"))
end
Dex:close()
end
end
 
return true

 

Para colocar mais, basta adicionar : 

{"NOME DO POKEMON", "ARQUIVO TXT", ID DO ITEM DE FOTO, 20, 100, "NOME", 99101},

 

 

Abaixo da linha que está em laranja.
 
E também adicionar:
 
elseif isMonster(pokemon) then
             local Dex = io.open('data/pokedex/' .. n[2],'r')
                     if getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) <= 0 then
                        doShowTextDialog(cid, n[3], Dex:read("*all"))
                           doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have unlocked " .. n[6] .. " in your pokedex")
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have gained " .. n[5] .. " experience points.")
                           doPlayerAddExperience(cid, n[5])
                           setPlayerStorageValue(cid, n[7], 1)
                     elseif getCreatureName(pokemon) == n[1] and getPlayerStorageValue(cid, n[7]) >= 1 then
                        doShowTextDialog(cid, n[3], Dex:read("*all"))
                     end
                        Dex:close()
 
Abaixo da linha que está escrita em vermelha
 

Pronto e agora?

  Crie outro arquivo .txt em [b]data\pokedex[/b]
correspondente ao nome do arquivo .txt que vc colocou na linha [color="#FF8C00"]laranja[/color],
adicionando o que estará escrito ao dar dex.
 
Creditos:
Autor: brunin86
Forum: xtibia.com
Eu: David.Santo , por estar trazendo o conteudo a voces ;D