Ir para conteúdo
  • Cadastre-se

(Resolvido)Erro no Script do NPC!


Ir para solução Resolvido por zipter98,

Posts Recomendados

Eu peguei um Script de um Npc que compra Pokémon do Servidor Pokémon KPDO By Cater e instalei no meu server! Configurei tudo corretamente e ao tentar vender um Pokémon pra esse Npc da o seguinte erro na Distro:

 

[09/01/2015 12:45:02] [Error - Npc interface] 
[09/01/2015 12:45:02] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 12:45:02] Description: 
[09/01/2015 12:45:02] data/npc/scripts/buy_pokemons.lua:130: bad argument #1 to 'pairs' (table expected, got nil)
[09/01/2015 12:45:02] stack traceback:
[09/01/2015 12:45:02] [C]: in function 'pairs'
[09/01/2015 12:45:02] data/npc/scripts/buy_pokemons.lua:130: in function 'sellPokemon'
[09/01/2015 12:45:02] data/npc/scripts/buy_pokemons.lua:407: in function 'callback'
[09/01/2015 12:45:02] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 12:45:02] data/npc/scripts/buy_pokemons.lua:8: in function <data/npc/scripts/buy_pokemons.lua:8>

 
Eu uso como base o Servidor Pokétibia Erondino V15 (Pokémon Dash)!
Obs: Meu servidor é sem Level System nos Pokémons!
 
Aqui os arquivos:
 
Pokemon Collector.xml

<?xml version="1.0"?>
<npc name="Pokemon Collector" script="data/npc/scripts/buy_pokemons.lua" walkinterval="0" floorchange="0">
<health now="150" max="150"/>
<look type="172" head="0" body="116" legs="116" feet="115"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. You Selling me {pokemon}? " />
</parameters>
</npc>

 
buy_pokemons.lua

local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {} 
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end 
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end 
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end 
function onThink() npcHandler:onThink() end 
 
function pairsByKeys (t, f) -- function for alphabetical order in list
      local a = {}
      for n in pairs(t) do table.insert(a, n) end
      table.sort(a, f)
      local i = 0
      local iter = function ()
        i = i + 1
        if a == nil then return nil
        else return a, t[a]
        end
      end
      return iter
    end
 
 
function sellPokemon(cid, name, price) 
local pokename = name
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local itemsball = getItemsInContainerById(bp.uid, 2224)
local itemsultra = getItemsInContainerById(bp.uid, 2227)
local itemsultra2 = getItemsInContainerById(bp.uid, 2657)
local itemsultra3 = getItemsInContainerById(bp.uid, 2658)
local itemsultra4 = getItemsInContainerById(bp.uid, 2659)
local itemsultra5 = getItemsInContainerById(bp.uid, 2222)
local itemsultra6 = getItemsInContainerById(bp.uid, 2651)
local itemsultra7 = getItemsInContainerById(bp.uid, 2653)
local itemsultra8 = getItemsInContainerById(bp.uid, 2220)
local itemsultra9 = getItemsInContainerById(bp.uid, 2655)
local priceselling = price*100
for _, pok in pairs(itemsball) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra2) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra3) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra4) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra5) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra6) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra7) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra8) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra9) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra10) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra11) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra12) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra13) do
if string.lower(getItemAttribute(pok,"nome")) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
    
local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!") 
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. "" 
doShowTextDialog(cid, 6579, str) 
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then 
selfSay("Then not") 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end 
return TRUE 
end 
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

 
Rep + pra quem me ajudar!

up


up


up

Editado por ducb (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Amigo, vamos tentar assim..

 

Primeiro vá a "DATA/LIB/0-50Functions.lua" e lá no final do arquivo, você adiciona esta função aqui.

getPlayerItems(cid[, id]) -- By OrochiElf

 

Agora altere o "buy_pokemons.lua" por este aqui.

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
      local a = {}
      for n in pairs(t) do table.insert(a, n) end
      table.sort(a, f)
      local i = 0
      local iter = function ()
        i = i + 1
        if a == nil then return nil
        else return a, t[a]
        end
      end
      return iter
    end
 
 
function sellPokemon(cid, name, price)
local pokename = name
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local itemsball = getPlayerItems(cid, 2224)
local itemsultra = getPlayerItems(cid, 2227)
local itemsultra2 = getPlayerItems(cid, 2657)
local itemsultra3 = getPlayerItems(cid, 2658)
local itemsultra4 = getPlayerItems(cid, 2659)
local itemsultra5 = getPlayerItems(cid, 2222)
local itemsultra6 = getPlayerItems(cid, 2651)
local itemsultra7 = getPlayerItems(cid, 2653)
local itemsultra8 = getPlayerItems(cid, 2220)
local itemsultra9 = getPlayerItems(cid, 2655)
local priceselling = price*100
for _, pok in pairs(itemsball) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra2) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra3) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra4) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra5) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra6) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra7) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra8) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra9) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra10) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra11) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra12) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra13) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por Orochi Elf (veja o histórico de edições)

Tony Araújo  ;D 

 

Link para o post
Compartilhar em outros sites

 

Amigo, vamos tentar assim..

 

Primeiro vá a "DATA/LIB/0-50Functions.lua" e lá no final do arquivo, você adiciona esta função aqui.

getPlayerItems(cid[, id]) -- By OrochiElf

 

Agora altere o "buy_pokemons.lua" por este aqui.

local Pokemons = {

["bulbasaur"] = {price = 3000},

["ivysaur"] = {price = 5500},

["venusaur"] = {price = 13500},

["charmander"] = {price = 3000},

["charmeleon"] = {price = 5500},

["charizard"] = {price = 13500},

["squirtle"] = {price = 3000},

["wartortle"] = {price = 5500},

["blastoise"] = {price = 13500},

["caterpie"] = {price = 0},

["metapod"] = {price = 250},

["butterfree"] = {price = 2500},

["weedle"] = {price = 0},

["kakuna"] = {price = 250},

["beedrill"] = {price = 2500},

["pidgey"] = {price = 50},

["pidgeotto"] = {price = 1500},

["pidgeot"] = {price = 8000},

["rattata"] = {price = 0},

["raticate"] = {price = 1200},

["spearow"] = {price = 150},

["fearow"] = {price = 6000},

["ekans"] = {price = 450},

["arbok"] = {price = 2500},

["pikachu"] = {price = 4000},

["raichu"] = {price = 8000},

["sandshrew"] = {price = 850},

["sandslash"] = {price = 7000},

["nidoranfe"] = {price = 250},

["nidorina"] = {price = 2000},

["nidoqueen"] = {price = 8000},

["nidoran"] = {price = 250},

["nidorino"] = {price = 2000},

["nidoking"] = {price = 8000},

["clefairy"] = {price = 3000},

["clefable"] = {price = 6000},

["vulpix"] = {price = 1200},

["ninetales"] = {price = 8500},

["jigglypuff"] = {price = 2500},

["wigglytuff"] = {price = 5500},

["zubat"] = {price = 120},

["golbat"] = {price = 2000},

["oddish"] = {price = 80},

["gloom"] = {price = 2000},

["vileplume"] = {price = 6500},

["paras"] = {price = 50},

["parasect"] = {price = 2500},

["venonat"] = {price = 1000},

["venomoth"] = {price = 4000},

["diglett"] = {price = 400},

["dugtrio"] = {price = 4000},

["meowth"] = {price = 1200},

["persian"] = {price = 4000},

["psyduck"] = {price = 1000},

["golduck"] = {price = 8000},

["mankey"] = {price = 600},

["primeape"] = {price = 5000},

["growlithe"] = {price = 3500},

["arcanine"] = {price = 10000},

["poliwag"] = {price = 110},

["poliwhirl"] = {price = 2200},

["poliwrath"] = {price = 8500},

["abra"] = {price = 800},

["kadabra"] = {price = 6000},

["alakazam"] = {price = 15000},

["machop"] = {price = 850},

["machoke"] = {price = 5000},

["machamp"] = {price = 10000},

["bellsprout"] = {price = 100},

["weepinbell"] = {price = 2000},

["victreebel"] = {price = 6500},

["tentacool"] = {price = 350},

["tentacruel"] = {price = 6000},

["geodude"] = {price = 500},

["graveler"] = {price = 2500},

["golem"] = {price = 8000},

["ponyta"] = {price = 850},

["rapidash"] = {price = 4500},

["slowpoke"] = {price = 850},

["slowbro"] = {price = 6000},

["magnemite"] = {price = 600},

["magneton"] = {price = 3200},

["doduo"] = {price = 650},

["dodrio"] = {price = 3200},

["seel"] = {price = 2000},

["dewgong"] = {price = 8000},

["grimer"] = {price = 600},

["muk"] = {price = 2200},

["shellder"] = {price = 600},

["cloyster"] = {price = 5500},

["gastly"] = {price = 3500},

["haunter"] = {price = 7000},

["gengar"] = {price = 15000},

["onix"] = {price = 10000},

["drowzee"] = {price = 1100},

["hypno"] = {price = 8000},

["krabby"] = {price = 135},

["kingler"] = {price = 4000},

["voltorb"] = {price = 450},

["electrode"] = {price = 3000},

["exeggcute"] = {price = 320},

["exeggutor"] = {price = 7000},

["cubone"] = {price = 1000},

["marowak"] = {price = 5000},

["hitmonlee"] = {price = 80000},

["hitmonchan"] = {price = 80000},

["lickitung"] = {price = 15000},

["koffing"] = {price = 500},

["weezing"] = {price = 2200},

["rhyhorn"] = {price = 1100},

["rhydon"] = {price = 6000},

["chansey"] = {price = 40000},

["tangela"] = {price = 4000},

["kangaskhan"] = {price = 40000},

["horsea"] = {price = 200},

["seadra"] = {price = 4000},

["seaking"] = {price = 3000},

["farfetchd"] = {price = 10000},

["starmie"] = {price = 4000},

["scyther"] = {price = 110000},

["jynx"] = {price = 40000},

["electabuzz"] = {price = 70000},

["magmar"] = {price = 60000},

["pinsir"] = {price = 4000},

["tauros"] = {price = 2500},

["magikarp"] = {price = 0},

["gyarados"] = {price = 40000},

["lapras"] = {price = 110000},

["ditto"] = {price = 70000},

["eevee"] = {price = 45000},

["vaporeon"] = {price = 50000},

["jolteon"] = {price = 50000},

["flareon"] = {price = 50000},

["porygon"] = {price = 60000},

["omanyte"] = {price = 18000},

["omastar"] = {price = 50000},

["kabuto"] = {price = 18000},

["kabutops"] = {price = 50000},

["aerodactyl"] = {price = 500000},

["snorlax"] = {price = 130000},

["dratini"] = {price = 35000},

["dragonair"] = {price = 50000},

["mr mime"] = {price = 50000},

["dragonite"] = {price = 120000},

["chikorita"] = {price = 11500},

["bayleef"] = {price = 15000},

["meganium"] = {price = 29000},

["cyndaquil"] = {price = 13500},

["quilava"] = {price = 15000},

["typhlosion"] = {price = 25000},

["totodile"] = {price = 15500},

["croconaw"] = {price = 18000},

["feraligatr"] = {price = 25000},

["sentret"] = {price = 1700},

["furret"] = {price = 4200},

["hoothoot"] = {price = 1500},

["noctowl"] = {price = 5300},

["ledyba"] = {price = 1700},

["ledian"] = {price = 4500},

["spinarak"] = {price = 2800},

["ariados"] = {price = 8500},

["crobat"] = {price = 8500},

["chinchou"] = {price = 12500},

["lanturn"] = {price = 25000},

["pichu"] = {price = 1000},

["cleffa"] = {price = 800},

["igglybuff"] = {price = 800},

["toggepi"] = {price = 50000},

["togetic"] = {price = 75000},

["natu"] = {price = 2000},

["xatu"] = {price = 8000},

["mareep"] = {price = 50000},

["flaaffy"] = {price = 70000},

["ampharos"] = {price = 140000},

["bellossom"] = {price = 40000},

["sunkern"] = {price = 40000},

["sunflora"] = {price = 50000},

["marill"] = {price = 2500},

["azumarill"] = {price = 7000},

["sudowoodo"] = {price = 240000},

["politoed"] = {price = 70000},

["espeon"] = {price = 70000},

["umbreon"] = {price = 70000},

["slowking"] = {price = 70000},

["girafarig"] = {price = 50000},

["steelix"] = {price = 25000},

["snubbull"] = {price = 10000},

["granbull"] = {price = 70000},

["scizor"] = {price = 220000},

["heracross"] = {price = 50000},

["teddiursa"] = {price = 90000},

["ursaring"] = {price = 290000},

["corsola"] = {price = 110000},

["houndoom"] = {price = 20000},

["houndour"] = {price = 7000},

["kingdra"] = {price = 69000},

["miltank"] = {price = 180000},

["blissey"] = {price = 150000},

["larvitar"] = {price = 95000},

["pupitar"] = {price = 145000},

["tyranitar"] = {price = 340000},

["skiploom"] = {price = 105000},

["Jumpluff"] = {price = 115000},

["hoppip"] = {price = 95000},

}

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

 

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

 

function pairsByKeys (t, f) -- function for alphabetical order in list

      local a = {}

      for n in pairs(t) do table.insert(a, n) end

      table.sort(a, f)

      local i = 0

      local iter = function ()

        i = i + 1

        if a == nil then return nil

        else return a, t[a]

        end

      end

      return iter

    end

 

 

function sellPokemon(cid, name, price)

local pokename = name

local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

local itemsball = getPlayerItems(cid, 2224)

local itemsultra = getPlayerItems(cid, 2227)

local itemsultra2 = getPlayerItems(cid, 2657)

local itemsultra3 = getPlayerItems(cid, 2658)

local itemsultra4 = getPlayerItems(cid, 2659)

local itemsultra5 = getPlayerItems(cid, 2222)

local itemsultra6 = getPlayerItems(cid, 2651)

local itemsultra7 = getPlayerItems(cid, 2653)

local itemsultra8 = getPlayerItems(cid, 2220)

local itemsultra9 = getPlayerItems(cid, 2655)

local priceselling = price*100

for _, pok in pairs(itemsball) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra2) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra3) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra4) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra5) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra6) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra7) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra8) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra9) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra10) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra11) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra12) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra13) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

 

selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")

end

 

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then

selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")

talkState[talkUser] = 1

elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then

local str = ""

str = str .. "Pokemon Prices :\n\n"

for name, pos in pairsByKeys(Pokemons) do

str = str..name.." = "..pos.price.."\n"

end

str = str .. ""

doShowTextDialog(cid, 6579, str)

elseif talkState[talkUser] == 1 then

if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       

return selfSay("Please dont possible selling pokemons, you fly/ride")

elseif #getCreatureSummons(cid) >= 1 then

return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")

end

local pokemonsell = Pokemons[string.lower(msg)]

if not pokemonsell then

return selfSay("Me desculpe mas eu nao compro esse pokemon!")

end

sellPokemon(cid, string.lower(msg), pokemonsell.price)

elseif msg == "no" and talkState[talkUser] >= 1 then

selfSay("Then not")

talkState[talkUser] = 0

npcHandler:releaseFocus(cid)

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Estou com o seguinte erro: Eu digo o nome do Pokémon e o Npc não fala nada!

 

E também ta dando esse erro na Distro:

 

[Error - Npc interface] 
[09/01/2015 15:07:35] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:07:35] Description: 
[09/01/2015 15:07:35] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:07:35] [Error - Npc interface] 
[09/01/2015 15:07:35] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:07:35] Description: 
[09/01/2015 15:07:35] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:07:35] stack traceback:
[09/01/2015 15:07:35] [C]: in function 'lower'
[09/01/2015 15:07:35] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:07:35] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:07:35] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:07:35] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:07:40] [Error - Npc interface] 
[09/01/2015 15:07:40] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:07:40] Description: 
[09/01/2015 15:07:40] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:07:40] [Error - Npc interface] 
[09/01/2015 15:07:40] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:07:40] Description: 
[09/01/2015 15:07:40] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:07:40] stack traceback:
[09/01/2015 15:07:40] [C]: in function 'lower'
[09/01/2015 15:07:40] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:07:40] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:07:40] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:07:40] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:09:16] [Error - Npc interface] 
[09/01/2015 15:09:16] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:16] Description: 
[09/01/2015 15:09:16] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:09:16] [Error - Npc interface] 
[09/01/2015 15:09:16] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:16] Description: 
[09/01/2015 15:09:16] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:09:16] stack traceback:
[09/01/2015 15:09:16] [C]: in function 'lower'
[09/01/2015 15:09:16] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:09:16] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:09:16] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:09:16] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:09:27] [Error - Npc interface] 
[09/01/2015 15:09:27] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:27] Description: 
[09/01/2015 15:09:27] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:09:27] [Error - Npc interface] 
[09/01/2015 15:09:27] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:27] Description: 
[09/01/2015 15:09:27] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:09:27] stack traceback:
[09/01/2015 15:09:27] [C]: in function 'lower'
[09/01/2015 15:09:27] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:09:27] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:09:27] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:09:27] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:09:30] [Error - Npc interface] 
[09/01/2015 15:09:30] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:30] Description: 
[09/01/2015 15:09:30] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:09:30] [Error - Npc interface] 
[09/01/2015 15:09:30] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:30] Description: 
[09/01/2015 15:09:30] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:09:30] stack traceback:
[09/01/2015 15:09:30] [C]: in function 'lower'
[09/01/2015 15:09:30] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:09:30] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:09:30] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:09:30] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:09:33] [Error - Npc interface] 
[09/01/2015 15:09:33] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:33] Description: 
[09/01/2015 15:09:33] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:09:33] [Error - Npc interface] 
[09/01/2015 15:09:33] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:33] Description: 
[09/01/2015 15:09:33] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:09:33] stack traceback:
[09/01/2015 15:09:33] [C]: in function 'lower'
[09/01/2015 15:09:33] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:09:33] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:09:33] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:09:33] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:09:36] [Error - Npc interface] 
[09/01/2015 15:09:36] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:36] Description: 
[09/01/2015 15:09:36] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:09:36] [Error - Npc interface] 
[09/01/2015 15:09:36] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:09:36] Description: 
[09/01/2015 15:09:36] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:09:36] stack traceback:
[09/01/2015 15:09:36] [C]: in function 'lower'
[09/01/2015 15:09:36] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:09:36] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:09:36] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:09:36] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
[09/01/2015 15:09:51] > Broadcasted message: "Os 4 primeiros colocados desse test server vao ganhar premios no outro test server.".
[09/01/2015 15:09:59] [Warning - Monster::Monster] Unknown event name - eventname
[09/01/2015 15:10:08] Adiministrador has logged out.
[09/01/2015 15:10:08] Adiministrador has logged in.
[09/01/2015 15:10:11] [Warning - Monster::Monster] Unknown event name - eventname
 
[09/01/2015 15:11:20] [Error - Npc interface] 
[09/01/2015 15:11:20] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:20] Description: 
[09/01/2015 15:11:20] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:11:20] [Error - Npc interface] 
[09/01/2015 15:11:20] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:20] Description: 
[09/01/2015 15:11:20] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:11:20] stack traceback:
[09/01/2015 15:11:20] [C]: in function 'lower'
[09/01/2015 15:11:20] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:11:20] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:11:20] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:11:20] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:11:22] [Error - Npc interface] 
[09/01/2015 15:11:22] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:22] Description: 
[09/01/2015 15:11:22] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:11:22] [Error - Npc interface] 
[09/01/2015 15:11:22] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:22] Description: 
[09/01/2015 15:11:22] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:11:22] stack traceback:
[09/01/2015 15:11:22] [C]: in function 'lower'
[09/01/2015 15:11:22] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:11:22] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:11:22] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:11:22] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:11:25] [Error - Npc interface] 
[09/01/2015 15:11:25] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:25] Description: 
[09/01/2015 15:11:25] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:11:26] [Error - Npc interface] 
[09/01/2015 15:11:26] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:26] Description: 
[09/01/2015 15:11:26] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:11:26] stack traceback:
[09/01/2015 15:11:26] [C]: in function 'lower'
[09/01/2015 15:11:26] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:11:26] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:11:26] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:11:26] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
 
[09/01/2015 15:11:27] [Error - Npc interface] 
[09/01/2015 15:11:27] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:27] Description: 
[09/01/2015 15:11:27] (luaGetItemAttribute) Item not found
 
[09/01/2015 15:11:27] [Error - Npc interface] 
[09/01/2015 15:11:27] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:11:27] Description: 
[09/01/2015 15:11:27] data/npc/scripts/buy_pokemons.lua:293: bad argument #1 to 'lower' (string expected, got nil)
[09/01/2015 15:11:27] stack traceback:
[09/01/2015 15:11:27] [C]: in function 'lower'
[09/01/2015 15:11:27] data/npc/scripts/buy_pokemons.lua:293: in function 'sellPokemon'
[09/01/2015 15:11:27] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:11:27] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:11:27] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>

Editado por ducb (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Tente assim.

Vamos assim, 1 error de cada vez.

 

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
      local a = {}
      for n in pairs(t) do table.insert(a, n) end
      table.sort(a, f)
      local i = 0
      local iter = function ()
        i = i + 1
        if a == nil then return nil
        else return a, t[a]
        end
      end
      return iter
    end
 
 
function sellPokemon(cid, name, price)
local pokename = name
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local itemsball = getPlayerItems(cid, 2224)
local itemsultra = getPlayerItems(cid, 2227)
local itemsultra2 = getPlayerItems(cid, 2657)
local itemsultra3 = getPlayerItems(cid, 2658)
local itemsultra4 = getPlayerItems(cid, 2659)
local itemsultra5 = getPlayerItems(cid, 2222)
local itemsultra6 = getPlayerItems(cid, 2651)
local itemsultra7 = getPlayerItems(cid, 2653)
local itemsultra8 = getPlayerItems(cid, 2220)
local itemsultra9 = getPlayerItems(cid, 2655)
local priceselling = price*100
for _, pok in pairs(itemsball) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra2) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra3) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra4) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra5) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra6) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra7) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra8) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra9) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra10) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra11) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra12) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
for _, pok in pairs(itemsultra13) do
if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then
doRemoveItem(pok.uid, 1)
doPlayerAddMoney(cid, priceselling)
selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
return true
end
break
end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Tony Araújo  ;D 

 

Link para o post
Compartilhar em outros sites

 

Tente assim.

Vamos assim, 1 error de cada vez.

 

local Pokemons = {

["bulbasaur"] = {price = 3000},

["ivysaur"] = {price = 5500},

["venusaur"] = {price = 13500},

["charmander"] = {price = 3000},

["charmeleon"] = {price = 5500},

["charizard"] = {price = 13500},

["squirtle"] = {price = 3000},

["wartortle"] = {price = 5500},

["blastoise"] = {price = 13500},

["caterpie"] = {price = 0},

["metapod"] = {price = 250},

["butterfree"] = {price = 2500},

["weedle"] = {price = 0},

["kakuna"] = {price = 250},

["beedrill"] = {price = 2500},

["pidgey"] = {price = 50},

["pidgeotto"] = {price = 1500},

["pidgeot"] = {price = 8000},

["rattata"] = {price = 0},

["raticate"] = {price = 1200},

["spearow"] = {price = 150},

["fearow"] = {price = 6000},

["ekans"] = {price = 450},

["arbok"] = {price = 2500},

["pikachu"] = {price = 4000},

["raichu"] = {price = 8000},

["sandshrew"] = {price = 850},

["sandslash"] = {price = 7000},

["nidoranfe"] = {price = 250},

["nidorina"] = {price = 2000},

["nidoqueen"] = {price = 8000},

["nidoran"] = {price = 250},

["nidorino"] = {price = 2000},

["nidoking"] = {price = 8000},

["clefairy"] = {price = 3000},

["clefable"] = {price = 6000},

["vulpix"] = {price = 1200},

["ninetales"] = {price = 8500},

["jigglypuff"] = {price = 2500},

["wigglytuff"] = {price = 5500},

["zubat"] = {price = 120},

["golbat"] = {price = 2000},

["oddish"] = {price = 80},

["gloom"] = {price = 2000},

["vileplume"] = {price = 6500},

["paras"] = {price = 50},

["parasect"] = {price = 2500},

["venonat"] = {price = 1000},

["venomoth"] = {price = 4000},

["diglett"] = {price = 400},

["dugtrio"] = {price = 4000},

["meowth"] = {price = 1200},

["persian"] = {price = 4000},

["psyduck"] = {price = 1000},

["golduck"] = {price = 8000},

["mankey"] = {price = 600},

["primeape"] = {price = 5000},

["growlithe"] = {price = 3500},

["arcanine"] = {price = 10000},

["poliwag"] = {price = 110},

["poliwhirl"] = {price = 2200},

["poliwrath"] = {price = 8500},

["abra"] = {price = 800},

["kadabra"] = {price = 6000},

["alakazam"] = {price = 15000},

["machop"] = {price = 850},

["machoke"] = {price = 5000},

["machamp"] = {price = 10000},

["bellsprout"] = {price = 100},

["weepinbell"] = {price = 2000},

["victreebel"] = {price = 6500},

["tentacool"] = {price = 350},

["tentacruel"] = {price = 6000},

["geodude"] = {price = 500},

["graveler"] = {price = 2500},

["golem"] = {price = 8000},

["ponyta"] = {price = 850},

["rapidash"] = {price = 4500},

["slowpoke"] = {price = 850},

["slowbro"] = {price = 6000},

["magnemite"] = {price = 600},

["magneton"] = {price = 3200},

["doduo"] = {price = 650},

["dodrio"] = {price = 3200},

["seel"] = {price = 2000},

["dewgong"] = {price = 8000},

["grimer"] = {price = 600},

["muk"] = {price = 2200},

["shellder"] = {price = 600},

["cloyster"] = {price = 5500},

["gastly"] = {price = 3500},

["haunter"] = {price = 7000},

["gengar"] = {price = 15000},

["onix"] = {price = 10000},

["drowzee"] = {price = 1100},

["hypno"] = {price = 8000},

["krabby"] = {price = 135},

["kingler"] = {price = 4000},

["voltorb"] = {price = 450},

["electrode"] = {price = 3000},

["exeggcute"] = {price = 320},

["exeggutor"] = {price = 7000},

["cubone"] = {price = 1000},

["marowak"] = {price = 5000},

["hitmonlee"] = {price = 80000},

["hitmonchan"] = {price = 80000},

["lickitung"] = {price = 15000},

["koffing"] = {price = 500},

["weezing"] = {price = 2200},

["rhyhorn"] = {price = 1100},

["rhydon"] = {price = 6000},

["chansey"] = {price = 40000},

["tangela"] = {price = 4000},

["kangaskhan"] = {price = 40000},

["horsea"] = {price = 200},

["seadra"] = {price = 4000},

["seaking"] = {price = 3000},

["farfetchd"] = {price = 10000},

["starmie"] = {price = 4000},

["scyther"] = {price = 110000},

["jynx"] = {price = 40000},

["electabuzz"] = {price = 70000},

["magmar"] = {price = 60000},

["pinsir"] = {price = 4000},

["tauros"] = {price = 2500},

["magikarp"] = {price = 0},

["gyarados"] = {price = 40000},

["lapras"] = {price = 110000},

["ditto"] = {price = 70000},

["eevee"] = {price = 45000},

["vaporeon"] = {price = 50000},

["jolteon"] = {price = 50000},

["flareon"] = {price = 50000},

["porygon"] = {price = 60000},

["omanyte"] = {price = 18000},

["omastar"] = {price = 50000},

["kabuto"] = {price = 18000},

["kabutops"] = {price = 50000},

["aerodactyl"] = {price = 500000},

["snorlax"] = {price = 130000},

["dratini"] = {price = 35000},

["dragonair"] = {price = 50000},

["mr mime"] = {price = 50000},

["dragonite"] = {price = 120000},

["chikorita"] = {price = 11500},

["bayleef"] = {price = 15000},

["meganium"] = {price = 29000},

["cyndaquil"] = {price = 13500},

["quilava"] = {price = 15000},

["typhlosion"] = {price = 25000},

["totodile"] = {price = 15500},

["croconaw"] = {price = 18000},

["feraligatr"] = {price = 25000},

["sentret"] = {price = 1700},

["furret"] = {price = 4200},

["hoothoot"] = {price = 1500},

["noctowl"] = {price = 5300},

["ledyba"] = {price = 1700},

["ledian"] = {price = 4500},

["spinarak"] = {price = 2800},

["ariados"] = {price = 8500},

["crobat"] = {price = 8500},

["chinchou"] = {price = 12500},

["lanturn"] = {price = 25000},

["pichu"] = {price = 1000},

["cleffa"] = {price = 800},

["igglybuff"] = {price = 800},

["toggepi"] = {price = 50000},

["togetic"] = {price = 75000},

["natu"] = {price = 2000},

["xatu"] = {price = 8000},

["mareep"] = {price = 50000},

["flaaffy"] = {price = 70000},

["ampharos"] = {price = 140000},

["bellossom"] = {price = 40000},

["sunkern"] = {price = 40000},

["sunflora"] = {price = 50000},

["marill"] = {price = 2500},

["azumarill"] = {price = 7000},

["sudowoodo"] = {price = 240000},

["politoed"] = {price = 70000},

["espeon"] = {price = 70000},

["umbreon"] = {price = 70000},

["slowking"] = {price = 70000},

["girafarig"] = {price = 50000},

["steelix"] = {price = 25000},

["snubbull"] = {price = 10000},

["granbull"] = {price = 70000},

["scizor"] = {price = 220000},

["heracross"] = {price = 50000},

["teddiursa"] = {price = 90000},

["ursaring"] = {price = 290000},

["corsola"] = {price = 110000},

["houndoom"] = {price = 20000},

["houndour"] = {price = 7000},

["kingdra"] = {price = 69000},

["miltank"] = {price = 180000},

["blissey"] = {price = 150000},

["larvitar"] = {price = 95000},

["pupitar"] = {price = 145000},

["tyranitar"] = {price = 340000},

["skiploom"] = {price = 105000},

["Jumpluff"] = {price = 115000},

["hoppip"] = {price = 95000},

}

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

 

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

 

function pairsByKeys (t, f) -- function for alphabetical order in list

      local a = {}

      for n in pairs(t) do table.insert(a, n) end

      table.sort(a, f)

      local i = 0

      local iter = function ()

        i = i + 1

        if a == nil then return nil

        else return a, t[a]

        end

      end

      return iter

    end

 

 

function sellPokemon(cid, name, price)

local pokename = name

local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

local itemsball = getPlayerItems(cid, 2224)

local itemsultra = getPlayerItems(cid, 2227)

local itemsultra2 = getPlayerItems(cid, 2657)

local itemsultra3 = getPlayerItems(cid, 2658)

local itemsultra4 = getPlayerItems(cid, 2659)

local itemsultra5 = getPlayerItems(cid, 2222)

local itemsultra6 = getPlayerItems(cid, 2651)

local itemsultra7 = getPlayerItems(cid, 2653)

local itemsultra8 = getPlayerItems(cid, 2220)

local itemsultra9 = getPlayerItems(cid, 2655)

local priceselling = price*100

for _, pok in pairs(itemsball) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra2) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra3) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra4) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra5) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra6) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra7) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra8) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra9) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra10) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra11) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra12) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

for _, pok in pairs(itemsultra13) do

if string.lower(getItemAttribute(pok.uid,"nome")) == pokename then

doRemoveItem(pok.uid, 1)

doPlayerAddMoney(cid, priceselling)

selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

return true

end

break

end

 

selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")

end

 

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then

selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")

talkState[talkUser] = 1

elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then

local str = ""

str = str .. "Pokemon Prices :\n\n"

for name, pos in pairsByKeys(Pokemons) do

str = str..name.." = "..pos.price.."\n"

end

str = str .. ""

doShowTextDialog(cid, 6579, str)

elseif talkState[talkUser] == 1 then

if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       

return selfSay("Please dont possible selling pokemons, you fly/ride")

elseif #getCreatureSummons(cid) >= 1 then

return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")

end

local pokemonsell = Pokemons[string.lower(msg)]

if not pokemonsell then

return selfSay("Me desculpe mas eu nao compro esse pokemon!")

end

sellPokemon(cid, string.lower(msg), pokemonsell.price)

elseif msg == "no" and talkState[talkUser] >= 1 then

selfSay("Then not")

talkState[talkUser] = 0

npcHandler:releaseFocus(cid)

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Estou conseguindo vender os Pokémons, porém continuo com o seguinte erro:

 

[09/01/2015 15:26:59] [Error - Npc interface] 
[09/01/2015 15:26:59] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 15:26:59] Description: 
[09/01/2015 15:26:59] data/npc/scripts/buy_pokemons.lua:337: bad argument #1 to 'pairs' (table expected, got nil)
[09/01/2015 15:26:59] stack traceback:
[09/01/2015 15:26:59] [C]: in function 'pairs'
[09/01/2015 15:26:59] data/npc/scripts/buy_pokemons.lua:337: in function 'sellPokemon'
[09/01/2015 15:26:59] data/npc/scripts/buy_pokemons.lua:406: in function 'callback'
[09/01/2015 15:26:59] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 15:26:59] data/npc/scripts/buy_pokemons.lua:215: in function <data/npc/scripts/buy_pokemons.lua:215>
Link para o post
Compartilhar em outros sites

Nossa, esse script está muito muito ruim, mas eu tentei modificar um pouco o código dele.

 

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
    local a = {}
    for n in pairs(t) do table.insert(a, n) end
        table.sort(a, f)
        local i = 0
        local iter = function ()
        i = i + 1
        if a == nil then return nil
            else return a, t[a]
        end
    end
    return iter
end
 
 
function sellPokemon(cid, name)
    for i = 1, #validBalls do
        for _, ball in (getPlayerItems(cid, validBalls)) do
            if(getItemAttribute(ball.uid, "name") == name then
                
                doRemoveItem(ball.uid)
                doPlayerAddMoney(cid, Pokemons[name].price)
                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
                return true
                break
            end
        end
    end
end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Tony Araújo  ;D 

 

Link para o post
Compartilhar em outros sites

 

Nossa, esse script está muito muito ruim, mas eu tentei modificar um pouco o código dele.

 

local Pokemons = {

["bulbasaur"] = {price = 3000},

["ivysaur"] = {price = 5500},

["venusaur"] = {price = 13500},

["charmander"] = {price = 3000},

["charmeleon"] = {price = 5500},

["charizard"] = {price = 13500},

["squirtle"] = {price = 3000},

["wartortle"] = {price = 5500},

["blastoise"] = {price = 13500},

["caterpie"] = {price = 0},

["metapod"] = {price = 250},

["butterfree"] = {price = 2500},

["weedle"] = {price = 0},

["kakuna"] = {price = 250},

["beedrill"] = {price = 2500},

["pidgey"] = {price = 50},

["pidgeotto"] = {price = 1500},

["pidgeot"] = {price = 8000},

["rattata"] = {price = 0},

["raticate"] = {price = 1200},

["spearow"] = {price = 150},

["fearow"] = {price = 6000},

["ekans"] = {price = 450},

["arbok"] = {price = 2500},

["pikachu"] = {price = 4000},

["raichu"] = {price = 8000},

["sandshrew"] = {price = 850},

["sandslash"] = {price = 7000},

["nidoranfe"] = {price = 250},

["nidorina"] = {price = 2000},

["nidoqueen"] = {price = 8000},

["nidoran"] = {price = 250},

["nidorino"] = {price = 2000},

["nidoking"] = {price = 8000},

["clefairy"] = {price = 3000},

["clefable"] = {price = 6000},

["vulpix"] = {price = 1200},

["ninetales"] = {price = 8500},

["jigglypuff"] = {price = 2500},

["wigglytuff"] = {price = 5500},

["zubat"] = {price = 120},

["golbat"] = {price = 2000},

["oddish"] = {price = 80},

["gloom"] = {price = 2000},

["vileplume"] = {price = 6500},

["paras"] = {price = 50},

["parasect"] = {price = 2500},

["venonat"] = {price = 1000},

["venomoth"] = {price = 4000},

["diglett"] = {price = 400},

["dugtrio"] = {price = 4000},

["meowth"] = {price = 1200},

["persian"] = {price = 4000},

["psyduck"] = {price = 1000},

["golduck"] = {price = 8000},

["mankey"] = {price = 600},

["primeape"] = {price = 5000},

["growlithe"] = {price = 3500},

["arcanine"] = {price = 10000},

["poliwag"] = {price = 110},

["poliwhirl"] = {price = 2200},

["poliwrath"] = {price = 8500},

["abra"] = {price = 800},

["kadabra"] = {price = 6000},

["alakazam"] = {price = 15000},

["machop"] = {price = 850},

["machoke"] = {price = 5000},

["machamp"] = {price = 10000},

["bellsprout"] = {price = 100},

["weepinbell"] = {price = 2000},

["victreebel"] = {price = 6500},

["tentacool"] = {price = 350},

["tentacruel"] = {price = 6000},

["geodude"] = {price = 500},

["graveler"] = {price = 2500},

["golem"] = {price = 8000},

["ponyta"] = {price = 850},

["rapidash"] = {price = 4500},

["slowpoke"] = {price = 850},

["slowbro"] = {price = 6000},

["magnemite"] = {price = 600},

["magneton"] = {price = 3200},

["doduo"] = {price = 650},

["dodrio"] = {price = 3200},

["seel"] = {price = 2000},

["dewgong"] = {price = 8000},

["grimer"] = {price = 600},

["muk"] = {price = 2200},

["shellder"] = {price = 600},

["cloyster"] = {price = 5500},

["gastly"] = {price = 3500},

["haunter"] = {price = 7000},

["gengar"] = {price = 15000},

["onix"] = {price = 10000},

["drowzee"] = {price = 1100},

["hypno"] = {price = 8000},

["krabby"] = {price = 135},

["kingler"] = {price = 4000},

["voltorb"] = {price = 450},

["electrode"] = {price = 3000},

["exeggcute"] = {price = 320},

["exeggutor"] = {price = 7000},

["cubone"] = {price = 1000},

["marowak"] = {price = 5000},

["hitmonlee"] = {price = 80000},

["hitmonchan"] = {price = 80000},

["lickitung"] = {price = 15000},

["koffing"] = {price = 500},

["weezing"] = {price = 2200},

["rhyhorn"] = {price = 1100},

["rhydon"] = {price = 6000},

["chansey"] = {price = 40000},

["tangela"] = {price = 4000},

["kangaskhan"] = {price = 40000},

["horsea"] = {price = 200},

["seadra"] = {price = 4000},

["seaking"] = {price = 3000},

["farfetchd"] = {price = 10000},

["starmie"] = {price = 4000},

["scyther"] = {price = 110000},

["jynx"] = {price = 40000},

["electabuzz"] = {price = 70000},

["magmar"] = {price = 60000},

["pinsir"] = {price = 4000},

["tauros"] = {price = 2500},

["magikarp"] = {price = 0},

["gyarados"] = {price = 40000},

["lapras"] = {price = 110000},

["ditto"] = {price = 70000},

["eevee"] = {price = 45000},

["vaporeon"] = {price = 50000},

["jolteon"] = {price = 50000},

["flareon"] = {price = 50000},

["porygon"] = {price = 60000},

["omanyte"] = {price = 18000},

["omastar"] = {price = 50000},

["kabuto"] = {price = 18000},

["kabutops"] = {price = 50000},

["aerodactyl"] = {price = 500000},

["snorlax"] = {price = 130000},

["dratini"] = {price = 35000},

["dragonair"] = {price = 50000},

["mr mime"] = {price = 50000},

["dragonite"] = {price = 120000},

["chikorita"] = {price = 11500},

["bayleef"] = {price = 15000},

["meganium"] = {price = 29000},

["cyndaquil"] = {price = 13500},

["quilava"] = {price = 15000},

["typhlosion"] = {price = 25000},

["totodile"] = {price = 15500},

["croconaw"] = {price = 18000},

["feraligatr"] = {price = 25000},

["sentret"] = {price = 1700},

["furret"] = {price = 4200},

["hoothoot"] = {price = 1500},

["noctowl"] = {price = 5300},

["ledyba"] = {price = 1700},

["ledian"] = {price = 4500},

["spinarak"] = {price = 2800},

["ariados"] = {price = 8500},

["crobat"] = {price = 8500},

["chinchou"] = {price = 12500},

["lanturn"] = {price = 25000},

["pichu"] = {price = 1000},

["cleffa"] = {price = 800},

["igglybuff"] = {price = 800},

["toggepi"] = {price = 50000},

["togetic"] = {price = 75000},

["natu"] = {price = 2000},

["xatu"] = {price = 8000},

["mareep"] = {price = 50000},

["flaaffy"] = {price = 70000},

["ampharos"] = {price = 140000},

["bellossom"] = {price = 40000},

["sunkern"] = {price = 40000},

["sunflora"] = {price = 50000},

["marill"] = {price = 2500},

["azumarill"] = {price = 7000},

["sudowoodo"] = {price = 240000},

["politoed"] = {price = 70000},

["espeon"] = {price = 70000},

["umbreon"] = {price = 70000},

["slowking"] = {price = 70000},

["girafarig"] = {price = 50000},

["steelix"] = {price = 25000},

["snubbull"] = {price = 10000},

["granbull"] = {price = 70000},

["scizor"] = {price = 220000},

["heracross"] = {price = 50000},

["teddiursa"] = {price = 90000},

["ursaring"] = {price = 290000},

["corsola"] = {price = 110000},

["houndoom"] = {price = 20000},

["houndour"] = {price = 7000},

["kingdra"] = {price = 69000},

["miltank"] = {price = 180000},

["blissey"] = {price = 150000},

["larvitar"] = {price = 95000},

["pupitar"] = {price = 145000},

["tyranitar"] = {price = 340000},

["skiploom"] = {price = 105000},

["Jumpluff"] = {price = 115000},

["hoppip"] = {price = 95000},

}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

 

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

 

function pairsByKeys (t, f) -- function for alphabetical order in list

    local a = {}

    for n in pairs(t) do table.insert(a, n) end

        table.sort(a, f)

        local i = 0

        local iter = function ()

        i = i + 1

        if a == nil then return nil

            else return a, t[a]

        end

    end

    return iter

end

 

 

function sellPokemon(cid, name)

    for i = 1, #validBalls do

        for _, ball in (getPlayerItems(cid, validBalls)) do

            if(getItemAttribute(ball.uid, "name") == name then

                

                doRemoveItem(ball.uid)

                doPlayerAddMoney(cid, Pokemons[name].price)

                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

                return true

                break

            end

        end

    end

end

 

selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")

end

 

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then

selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")

talkState[talkUser] = 1

elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then

local str = ""

str = str .. "Pokemon Prices :\n\n"

for name, pos in pairsByKeys(Pokemons) do

str = str..name.." = "..pos.price.."\n"

end

str = str .. ""

doShowTextDialog(cid, 6579, str)

elseif talkState[talkUser] == 1 then

if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       

return selfSay("Please dont possible selling pokemons, you fly/ride")

elseif #getCreatureSummons(cid) >= 1 then

return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")

end

local pokemonsell = Pokemons[string.lower(msg)]

if not pokemonsell then

return selfSay("Me desculpe mas eu nao compro esse pokemon!")

end

sellPokemon(cid, string.lower(msg), pokemonsell.price)

elseif msg == "no" and talkState[talkUser] >= 1 then

selfSay("Then not")

talkState[talkUser] = 0

npcHandler:releaseFocus(cid)

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Eu peguei esse Script do Server Pokémon KPDO e estou tentando adaptar ele pro meu Erondino V15 (Pokémon Dash), vou testar essa sua correção aqui!

 

Nossa, esse script está muito muito ruim, mas eu tentei modificar um pouco o código dele.

 

local Pokemons = {

["bulbasaur"] = {price = 3000},

["ivysaur"] = {price = 5500},

["venusaur"] = {price = 13500},

["charmander"] = {price = 3000},

["charmeleon"] = {price = 5500},

["charizard"] = {price = 13500},

["squirtle"] = {price = 3000},

["wartortle"] = {price = 5500},

["blastoise"] = {price = 13500},

["caterpie"] = {price = 0},

["metapod"] = {price = 250},

["butterfree"] = {price = 2500},

["weedle"] = {price = 0},

["kakuna"] = {price = 250},

["beedrill"] = {price = 2500},

["pidgey"] = {price = 50},

["pidgeotto"] = {price = 1500},

["pidgeot"] = {price = 8000},

["rattata"] = {price = 0},

["raticate"] = {price = 1200},

["spearow"] = {price = 150},

["fearow"] = {price = 6000},

["ekans"] = {price = 450},

["arbok"] = {price = 2500},

["pikachu"] = {price = 4000},

["raichu"] = {price = 8000},

["sandshrew"] = {price = 850},

["sandslash"] = {price = 7000},

["nidoranfe"] = {price = 250},

["nidorina"] = {price = 2000},

["nidoqueen"] = {price = 8000},

["nidoran"] = {price = 250},

["nidorino"] = {price = 2000},

["nidoking"] = {price = 8000},

["clefairy"] = {price = 3000},

["clefable"] = {price = 6000},

["vulpix"] = {price = 1200},

["ninetales"] = {price = 8500},

["jigglypuff"] = {price = 2500},

["wigglytuff"] = {price = 5500},

["zubat"] = {price = 120},

["golbat"] = {price = 2000},

["oddish"] = {price = 80},

["gloom"] = {price = 2000},

["vileplume"] = {price = 6500},

["paras"] = {price = 50},

["parasect"] = {price = 2500},

["venonat"] = {price = 1000},

["venomoth"] = {price = 4000},

["diglett"] = {price = 400},

["dugtrio"] = {price = 4000},

["meowth"] = {price = 1200},

["persian"] = {price = 4000},

["psyduck"] = {price = 1000},

["golduck"] = {price = 8000},

["mankey"] = {price = 600},

["primeape"] = {price = 5000},

["growlithe"] = {price = 3500},

["arcanine"] = {price = 10000},

["poliwag"] = {price = 110},

["poliwhirl"] = {price = 2200},

["poliwrath"] = {price = 8500},

["abra"] = {price = 800},

["kadabra"] = {price = 6000},

["alakazam"] = {price = 15000},

["machop"] = {price = 850},

["machoke"] = {price = 5000},

["machamp"] = {price = 10000},

["bellsprout"] = {price = 100},

["weepinbell"] = {price = 2000},

["victreebel"] = {price = 6500},

["tentacool"] = {price = 350},

["tentacruel"] = {price = 6000},

["geodude"] = {price = 500},

["graveler"] = {price = 2500},

["golem"] = {price = 8000},

["ponyta"] = {price = 850},

["rapidash"] = {price = 4500},

["slowpoke"] = {price = 850},

["slowbro"] = {price = 6000},

["magnemite"] = {price = 600},

["magneton"] = {price = 3200},

["doduo"] = {price = 650},

["dodrio"] = {price = 3200},

["seel"] = {price = 2000},

["dewgong"] = {price = 8000},

["grimer"] = {price = 600},

["muk"] = {price = 2200},

["shellder"] = {price = 600},

["cloyster"] = {price = 5500},

["gastly"] = {price = 3500},

["haunter"] = {price = 7000},

["gengar"] = {price = 15000},

["onix"] = {price = 10000},

["drowzee"] = {price = 1100},

["hypno"] = {price = 8000},

["krabby"] = {price = 135},

["kingler"] = {price = 4000},

["voltorb"] = {price = 450},

["electrode"] = {price = 3000},

["exeggcute"] = {price = 320},

["exeggutor"] = {price = 7000},

["cubone"] = {price = 1000},

["marowak"] = {price = 5000},

["hitmonlee"] = {price = 80000},

["hitmonchan"] = {price = 80000},

["lickitung"] = {price = 15000},

["koffing"] = {price = 500},

["weezing"] = {price = 2200},

["rhyhorn"] = {price = 1100},

["rhydon"] = {price = 6000},

["chansey"] = {price = 40000},

["tangela"] = {price = 4000},

["kangaskhan"] = {price = 40000},

["horsea"] = {price = 200},

["seadra"] = {price = 4000},

["seaking"] = {price = 3000},

["farfetchd"] = {price = 10000},

["starmie"] = {price = 4000},

["scyther"] = {price = 110000},

["jynx"] = {price = 40000},

["electabuzz"] = {price = 70000},

["magmar"] = {price = 60000},

["pinsir"] = {price = 4000},

["tauros"] = {price = 2500},

["magikarp"] = {price = 0},

["gyarados"] = {price = 40000},

["lapras"] = {price = 110000},

["ditto"] = {price = 70000},

["eevee"] = {price = 45000},

["vaporeon"] = {price = 50000},

["jolteon"] = {price = 50000},

["flareon"] = {price = 50000},

["porygon"] = {price = 60000},

["omanyte"] = {price = 18000},

["omastar"] = {price = 50000},

["kabuto"] = {price = 18000},

["kabutops"] = {price = 50000},

["aerodactyl"] = {price = 500000},

["snorlax"] = {price = 130000},

["dratini"] = {price = 35000},

["dragonair"] = {price = 50000},

["mr mime"] = {price = 50000},

["dragonite"] = {price = 120000},

["chikorita"] = {price = 11500},

["bayleef"] = {price = 15000},

["meganium"] = {price = 29000},

["cyndaquil"] = {price = 13500},

["quilava"] = {price = 15000},

["typhlosion"] = {price = 25000},

["totodile"] = {price = 15500},

["croconaw"] = {price = 18000},

["feraligatr"] = {price = 25000},

["sentret"] = {price = 1700},

["furret"] = {price = 4200},

["hoothoot"] = {price = 1500},

["noctowl"] = {price = 5300},

["ledyba"] = {price = 1700},

["ledian"] = {price = 4500},

["spinarak"] = {price = 2800},

["ariados"] = {price = 8500},

["crobat"] = {price = 8500},

["chinchou"] = {price = 12500},

["lanturn"] = {price = 25000},

["pichu"] = {price = 1000},

["cleffa"] = {price = 800},

["igglybuff"] = {price = 800},

["toggepi"] = {price = 50000},

["togetic"] = {price = 75000},

["natu"] = {price = 2000},

["xatu"] = {price = 8000},

["mareep"] = {price = 50000},

["flaaffy"] = {price = 70000},

["ampharos"] = {price = 140000},

["bellossom"] = {price = 40000},

["sunkern"] = {price = 40000},

["sunflora"] = {price = 50000},

["marill"] = {price = 2500},

["azumarill"] = {price = 7000},

["sudowoodo"] = {price = 240000},

["politoed"] = {price = 70000},

["espeon"] = {price = 70000},

["umbreon"] = {price = 70000},

["slowking"] = {price = 70000},

["girafarig"] = {price = 50000},

["steelix"] = {price = 25000},

["snubbull"] = {price = 10000},

["granbull"] = {price = 70000},

["scizor"] = {price = 220000},

["heracross"] = {price = 50000},

["teddiursa"] = {price = 90000},

["ursaring"] = {price = 290000},

["corsola"] = {price = 110000},

["houndoom"] = {price = 20000},

["houndour"] = {price = 7000},

["kingdra"] = {price = 69000},

["miltank"] = {price = 180000},

["blissey"] = {price = 150000},

["larvitar"] = {price = 95000},

["pupitar"] = {price = 145000},

["tyranitar"] = {price = 340000},

["skiploom"] = {price = 105000},

["Jumpluff"] = {price = 115000},

["hoppip"] = {price = 95000},

}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

 

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

 

function pairsByKeys (t, f) -- function for alphabetical order in list

    local a = {}

    for n in pairs(t) do table.insert(a, n) end

        table.sort(a, f)

        local i = 0

        local iter = function ()

        i = i + 1

        if a == nil then return nil

            else return a, t[a]

        end

    end

    return iter

end

 

 

function sellPokemon(cid, name)

    for i = 1, #validBalls do

        for _, ball in (getPlayerItems(cid, validBalls)) do

            if(getItemAttribute(ball.uid, "name") == name then

                

                doRemoveItem(ball.uid)

                doPlayerAddMoney(cid, Pokemons[name].price)

                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")

                return true

                break

            end

        end

    end

end

 

selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")

end

 

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then

selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")

talkState[talkUser] = 1

elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then

local str = ""

str = str .. "Pokemon Prices :\n\n"

for name, pos in pairsByKeys(Pokemons) do

str = str..name.." = "..pos.price.."\n"

end

str = str .. ""

doShowTextDialog(cid, 6579, str)

elseif talkState[talkUser] == 1 then

if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       

return selfSay("Please dont possible selling pokemons, you fly/ride")

elseif #getCreatureSummons(cid) >= 1 then

return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")

end

local pokemonsell = Pokemons[string.lower(msg)]

if not pokemonsell then

return selfSay("Me desculpe mas eu nao compro esse pokemon!")

end

sellPokemon(cid, string.lower(msg), pokemonsell.price)

elseif msg == "no" and talkState[talkUser] >= 1 then

selfSay("Then not")

talkState[talkUser] = 0

npcHandler:releaseFocus(cid)

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Agora não quer nem carregar o Script!

 

[09/01/2015 16:01:02] [Error - LuaScriptInterface::loadFile] data/npc/scripts/buy_pokemons.lua:238: ')' expected near 'then'
[09/01/2015 16:01:02] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/buy_pokemons.lua
[09/01/2015 16:01:02] data/npc/scripts/buy_pokemons.lua:238: ')' expected near 'then'
Link para o post
Compartilhar em outros sites

Tenta assim:

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
    local a = {}
    for n in pairs(t) do table.insert(a, n) end
        table.sort(a, f)
        local i = 0
        local iter = function ()
        i = i + 1
        if a[i] == nil then return nil
            else return a[i], t[a[i]]
        end
    end
    return iter
end
 
 
function sellPokemon(cid, name)
    for i = 1, #validBalls do
        for _, ball in (getPlayerItems(cid, validBalls[i])) do
            if(getItemAttribute(ball.uid, "name") == name) then
                
                doRemoveItem(ball.uid)
                doPlayerAddMoney(cid, Pokemons[name].price)
                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
                return true
                break
            end
        end
    end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Tinha um erro no escopo aí tentei arrumar rapidão, ñ li o script, então pf teste tudo que o npc faz.

Editado por danihcv (veja o histórico de edições)

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites

 

Nossa verdade, eu tinha esquecido de fechar os parênteses.

 

Usei o script que o amigo mandou a cima e está dando esse erro!

 

[09/01/2015 16:57:30] [Error - LuaScriptInterface::loadFile] data/npc/scripts/buy_pokemons.lua:244: 'end' expected (to close 'if' at line 238) near 'break'
[09/01/2015 16:57:30] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/buy_pokemons.lua
[09/01/2015 16:57:30] data/npc/scripts/buy_pokemons.lua:244: 'end' expected (to close 'if' at line 238) near 'break'
Link para o post
Compartilhar em outros sites

Tenta assim:

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
    local a = {}
    for n in pairs(t) do table.insert(a, n) end
        table.sort(a, f)
        local i = 0
        local iter = function ()
        i = i + 1
        if a[i] == nil then return nil
            else return a[i], t[a[i]]
        end
    end
    return iter
end
 
 
function sellPokemon(cid, name)
    for i = 1, #validBalls do
        for _, ball in (getPlayerItems(cid, validBalls[i])) do
            if(getItemAttribute(ball.uid, "name") == name) then
                
                doRemoveItem(ball.uid)
                doPlayerAddMoney(cid, Pokemons[name].price)
                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
                return true
                break
            end
        end
    end
end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites

Tenta assim:

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
    local a = {}
    for n in pairs(t) do table.insert(a, n) end
        table.sort(a, f)
        local i = 0
        local iter = function ()
        i = i + 1
        if a[i] == nil then return nil
            else return a[i], t[a[i]]
        end
    end
    return iter
end
 
 
function sellPokemon(cid, name)
    for i = 1, #validBalls do
        for _, ball in (getPlayerItems(cid, validBalls[i])) do
            if(getItemAttribute(ball.uid, "name") == name) then
                
                doRemoveItem(ball.uid)
                doPlayerAddMoney(cid, Pokemons[name].price)
                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
                return true
                break
            end
        end
    end
end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Continua com erro!

 

[09/01/2015 17:20:21] [Error - LuaScriptInterface::loadFile] data/npc/scripts/buy_pokemons.lua:244: 'end' expected (to close 'if' at line 238) near 'break'
[09/01/2015 17:20:21] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/buy_pokemons.lua
[09/01/2015 17:20:21] data/npc/scripts/buy_pokemons.lua:244: 'end' expected (to close 'if' at line 238) near 'break'
Link para o post
Compartilhar em outros sites

:hum:  Tente assim:

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
    local a = {}
    for n in pairs(t) do table.insert(a, n) end
        table.sort(a, f)
        local i = 0
        local iter = function ()
        i = i + 1
        if a[i] == nil then return nil
            else return a[i], t[a[i]]
        end
    end
    return iter
end
 
 
function sellPokemon(cid, name)
    for i = 1, #validBalls do
        for _, ball in (getPlayerItems(cid, validBalls[i])) do
            if(getItemAttribute(ball.uid, "name") == name) then
                
                doRemoveItem(ball.uid)
                doPlayerAddMoney(cid, Pokemons[name].price)
                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
                return true
				end
                break
            end
        end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Te ajudei?? REP + e ficamos quites... <ahttp://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'>

Atenciosamente,

Daniel.

Abraços!

Link para o post
Compartilhar em outros sites

:hum:  Tente assim:

local Pokemons = {
["bulbasaur"] = {price = 3000},
["ivysaur"] = {price = 5500},
["venusaur"] = {price = 13500},
["charmander"] = {price = 3000},
["charmeleon"] = {price = 5500},
["charizard"] = {price = 13500},
["squirtle"] = {price = 3000},
["wartortle"] = {price = 5500},
["blastoise"] = {price = 13500},
["caterpie"] = {price = 0},
["metapod"] = {price = 250},
["butterfree"] = {price = 2500},
["weedle"] = {price = 0},
["kakuna"] = {price = 250},
["beedrill"] = {price = 2500},
["pidgey"] = {price = 50},
["pidgeotto"] = {price = 1500},
["pidgeot"] = {price = 8000},
["rattata"] = {price = 0},
["raticate"] = {price = 1200},
["spearow"] = {price = 150},
["fearow"] = {price = 6000},
["ekans"] = {price = 450},
["arbok"] = {price = 2500},
["pikachu"] = {price = 4000},
["raichu"] = {price = 8000},
["sandshrew"] = {price = 850},
["sandslash"] = {price = 7000},
["nidoranfe"] = {price = 250},
["nidorina"] = {price = 2000},
["nidoqueen"] = {price = 8000},
["nidoran"] = {price = 250},
["nidorino"] = {price = 2000},
["nidoking"] = {price = 8000},
["clefairy"] = {price = 3000},
["clefable"] = {price = 6000},
["vulpix"] = {price = 1200},
["ninetales"] = {price = 8500},
["jigglypuff"] = {price = 2500},
["wigglytuff"] = {price = 5500},
["zubat"] = {price = 120},
["golbat"] = {price = 2000},
["oddish"] = {price = 80},
["gloom"] = {price = 2000},
["vileplume"] = {price = 6500},
["paras"] = {price = 50},
["parasect"] = {price = 2500},
["venonat"] = {price = 1000},
["venomoth"] = {price = 4000},
["diglett"] = {price = 400},
["dugtrio"] = {price = 4000},
["meowth"] = {price = 1200},
["persian"] = {price = 4000},
["psyduck"] = {price = 1000},
["golduck"] = {price = 8000},
["mankey"] = {price = 600},
["primeape"] = {price = 5000},
["growlithe"] = {price = 3500},
["arcanine"] = {price = 10000},
["poliwag"] = {price = 110},
["poliwhirl"] = {price = 2200},
["poliwrath"] = {price = 8500},
["abra"] = {price = 800},
["kadabra"] = {price = 6000},
["alakazam"] = {price = 15000},
["machop"] = {price = 850},
["machoke"] = {price = 5000},
["machamp"] = {price = 10000},
["bellsprout"] = {price = 100},
["weepinbell"] = {price = 2000},
["victreebel"] = {price = 6500},
["tentacool"] = {price = 350},
["tentacruel"] = {price = 6000},
["geodude"] = {price = 500},
["graveler"] = {price = 2500},
["golem"] = {price = 8000},
["ponyta"] = {price = 850},
["rapidash"] = {price = 4500},
["slowpoke"] = {price = 850},
["slowbro"] = {price = 6000},
["magnemite"] = {price = 600},
["magneton"] = {price = 3200},
["doduo"] = {price = 650},
["dodrio"] = {price = 3200},
["seel"] = {price = 2000},
["dewgong"] = {price = 8000},
["grimer"] = {price = 600},
["muk"] = {price = 2200},
["shellder"] = {price = 600},
["cloyster"] = {price = 5500},
["gastly"] = {price = 3500},
["haunter"] = {price = 7000},
["gengar"] = {price = 15000},
["onix"] = {price = 10000},
["drowzee"] = {price = 1100},
["hypno"] = {price = 8000},
["krabby"] = {price = 135},
["kingler"] = {price = 4000},
["voltorb"] = {price = 450},
["electrode"] = {price = 3000},
["exeggcute"] = {price = 320},
["exeggutor"] = {price = 7000},
["cubone"] = {price = 1000},
["marowak"] = {price = 5000},
["hitmonlee"] = {price = 80000},
["hitmonchan"] = {price = 80000},
["lickitung"] = {price = 15000},
["koffing"] = {price = 500},
["weezing"] = {price = 2200},
["rhyhorn"] = {price = 1100},
["rhydon"] = {price = 6000},
["chansey"] = {price = 40000},
["tangela"] = {price = 4000},
["kangaskhan"] = {price = 40000},
["horsea"] = {price = 200},
["seadra"] = {price = 4000},
["seaking"] = {price = 3000},
["farfetchd"] = {price = 10000},
["starmie"] = {price = 4000},
["scyther"] = {price = 110000},
["jynx"] = {price = 40000},
["electabuzz"] = {price = 70000},
["magmar"] = {price = 60000},
["pinsir"] = {price = 4000},
["tauros"] = {price = 2500},
["magikarp"] = {price = 0},
["gyarados"] = {price = 40000},
["lapras"] = {price = 110000},
["ditto"] = {price = 70000},
["eevee"] = {price = 45000},
["vaporeon"] = {price = 50000},
["jolteon"] = {price = 50000},
["flareon"] = {price = 50000},
["porygon"] = {price = 60000},
["omanyte"] = {price = 18000},
["omastar"] = {price = 50000},
["kabuto"] = {price = 18000},
["kabutops"] = {price = 50000},
["aerodactyl"] = {price = 500000},
["snorlax"] = {price = 130000},
["dratini"] = {price = 35000},
["dragonair"] = {price = 50000},
["mr mime"] = {price = 50000},
["dragonite"] = {price = 120000},
["chikorita"] = {price = 11500},
["bayleef"] = {price = 15000},
["meganium"] = {price = 29000},
["cyndaquil"] = {price = 13500},
["quilava"] = {price = 15000},
["typhlosion"] = {price = 25000},
["totodile"] = {price = 15500},
["croconaw"] = {price = 18000},
["feraligatr"] = {price = 25000},
["sentret"] = {price = 1700},
["furret"] = {price = 4200},
["hoothoot"] = {price = 1500},
["noctowl"] = {price = 5300},
["ledyba"] = {price = 1700},
["ledian"] = {price = 4500},
["spinarak"] = {price = 2800},
["ariados"] = {price = 8500},
["crobat"] = {price = 8500},
["chinchou"] = {price = 12500},
["lanturn"] = {price = 25000},
["pichu"] = {price = 1000},
["cleffa"] = {price = 800},
["igglybuff"] = {price = 800},
["toggepi"] = {price = 50000},
["togetic"] = {price = 75000},
["natu"] = {price = 2000},
["xatu"] = {price = 8000},
["mareep"] = {price = 50000},
["flaaffy"] = {price = 70000},
["ampharos"] = {price = 140000},
["bellossom"] = {price = 40000},
["sunkern"] = {price = 40000},
["sunflora"] = {price = 50000},
["marill"] = {price = 2500},
["azumarill"] = {price = 7000},
["sudowoodo"] = {price = 240000},
["politoed"] = {price = 70000},
["espeon"] = {price = 70000},
["umbreon"] = {price = 70000},
["slowking"] = {price = 70000},
["girafarig"] = {price = 50000},
["steelix"] = {price = 25000},
["snubbull"] = {price = 10000},
["granbull"] = {price = 70000},
["scizor"] = {price = 220000},
["heracross"] = {price = 50000},
["teddiursa"] = {price = 90000},
["ursaring"] = {price = 290000},
["corsola"] = {price = 110000},
["houndoom"] = {price = 20000},
["houndour"] = {price = 7000},
["kingdra"] = {price = 69000},
["miltank"] = {price = 180000},
["blissey"] = {price = 150000},
["larvitar"] = {price = 95000},
["pupitar"] = {price = 145000},
["tyranitar"] = {price = 340000},
["skiploom"] = {price = 105000},
["Jumpluff"] = {price = 115000},
["hoppip"] = {price = 95000},
}

local validBalls = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
 
function pairsByKeys (t, f) -- function for alphabetical order in list
    local a = {}
    for n in pairs(t) do table.insert(a, n) end
        table.sort(a, f)
        local i = 0
        local iter = function ()
        i = i + 1
        if a[i] == nil then return nil
            else return a[i], t[a[i]]
        end
    end
    return iter
end
 
 
function sellPokemon(cid, name)
    for i = 1, #validBalls do
        for _, ball in (getPlayerItems(cid, validBalls[i])) do
            if(getItemAttribute(ball.uid, "name") == name) then
                
                doRemoveItem(ball.uid)
                doPlayerAddMoney(cid, Pokemons[name].price)
                selfSay("Obrigado por me vender esse maravilhoso pokemon! Aqui esta seu dinheiro.")
                return true
				end
                break
            end
        end
 
selfSay("Voce nao tem um(a) ("..pokename..")! Certifique-se que ele esteja vivo e dentro de sua mochila!")
end
 
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
 
if msgcontains(string.lower(msg), "pokemon") or msgcontains(string.lower(msg), "help") or msgcontains(string.lower(msg), "sell") then
selfSay("Voce quer me vender algum pokemon? Diga {list} para ver os pokemons que eu compro!")
talkState[talkUser] = 1
elseif msgcontains(msg, "list") or msgcontains(msg, "LIST") then
local str = ""
str = str .. "Pokemon Prices :\n\n"
for name, pos in pairsByKeys(Pokemons) do
str = str..name.." = "..pos.price.."\n"
end
str = str .. ""
doShowTextDialog(cid, 6579, str)
elseif talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
return selfSay("Please dont possible selling pokemons, you fly/ride")
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!")
end
local pokemonsell = Pokemons[string.lower(msg)]
if not pokemonsell then
return selfSay("Me desculpe mas eu nao compro esse pokemon!")
end
sellPokemon(cid, string.lower(msg), pokemonsell.price)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not")
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Continua com o erro!

 

[09/01/2015 20:38:28] [Error - Npc interface] 
[09/01/2015 20:38:28] data/npc/scripts/buy_pokemons.lua:onCreatureSay
[09/01/2015 20:38:28] Description: 
[09/01/2015 20:38:28] data/npc/scripts/buy_pokemons.lua:237: attempt to call a table value
[09/01/2015 20:38:28] stack traceback:
[09/01/2015 20:38:28] data/npc/scripts/buy_pokemons.lua:237: in function 'sellPokemon'
[09/01/2015 20:38:28] data/npc/scripts/buy_pokemons.lua:281: in function 'callback'
[09/01/2015 20:38:28] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[09/01/2015 20:38:28] data/npc/scripts/buy_pokemons.lua:217: in function <data/npc/scripts/buy_pokemons.lua:217>
 
Se vocês me ajudassem a criar um novo Script desse Npc ficaria muito agradecido!
Uso Erondino v15 (Pokémon Dash) como base!
Link para o post
Compartilhar em outros sites
  • Solução

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    local pokeballs = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}      
    
    local poke_price = {
        --["pokemon"] = price,
        ["bulbasaur"] = 3000,
        ["ivysaur"] = 5500,
        ["venusaur"] = 13500,
        ["charmander"] = 3000,
        ["charmeleon"] = 5500,
        ["charizard"] = 13500,
        ["squirtle"] = 3000,
        ["wartortle"] = 5500,
        ["blastoise"] = 13500,
    }
    
    local function sellPokemon(cid, name)
        local price = poke_price[name] * 100
        local balls = getPlayerSlotItem(cid, 8).uid
        local bag = getPlayerSlotItem(cid, 3).uid
        if balls > 0 then
            local poke = getItemAttribute(balls, "nome")
            if poke:lower() == name then
                selfSay("Thank you sir! Take your "..price.." dollars.", cid)
                doPlayerAddMoney(cid, price)
                doRemoveItem(balls, 1)
                talkState[talkUser] = 0
                return true
            end
        end
        for i = 1, #pokeballs do
            local pokeball = getItemsInContainerById(bag, pokeballs[i])
            for _, ball in pairs(pokeball) do
                local poke = getItemAttribute(ball, "nome")
                if poke:lower() == name then
                    selfSay("Thank you sir! Take your "..poke_price[name].." dollars.", cid)
                    doPlayerAddMoney(cid, price)
                    doRemoveItem(ball, 1)
                    talkState[talkUser] = 0
                    return true
                end
            end
        end
        return selfSay("You do not have this pokemon, or hi's fainted.", cid)
    end
        
    if msgcontains(msg:lower(), "pokemon") or msgcontains(msg:lower(), "help") or msgcontains(msg:lower(), "sell") then
        selfSay("Hi, do you wanna sell me some pokemon? Say {list} if you're curious about what pokemons I buy.", cid)
        talkState[talkUser] = 1
        return true
    elseif msgcontains(msg:lower(), "list") and talkState[talkUser] == 1 then
        local str = "Pokemon prices:"
        for poke, price in pairs(poke_price) do          
            str = str.."\n"..poke.." - "..price
        end
        doPlayerPopupFYI(cid, str)
        return true
    elseif talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
            return selfSay("Please dont possible selling pokemons, you fly/ride", cid)
        elseif #getCreatureSummons(cid) >= 1 then
            return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!", cid) 
        elseif not poke_price[msg:lower()] then
            return selfSay("I don't buy this pokemon.", cid)
        else
            sellPokemon(cid, msg:lower())
        end
    elseif msgcontains(msg:lower(), "no") or msgcontains(msg:lower(), "nao") and talkState[talkUser] == 1 then
        selfSay("Ok. Bye!", cid)
        talkState[talkUser] = 0
        return true
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())            

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    local pokeballs = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}      
    
    local poke_price = {
        --["pokemon"] = price,
        ["bulbasaur"] = 3000,
        ["ivysaur"] = 5500,
        ["venusaur"] = 13500,
        ["charmander"] = 3000,
        ["charmeleon"] = 5500,
        ["charizard"] = 13500,
        ["squirtle"] = 3000,
        ["wartortle"] = 5500,
        ["blastoise"] = 13500,
    }
    
    local function sellPokemon(cid, name)
        local price = poke_price[name] * 100
        local balls = getPlayerSlotItem(cid, 8).uid
        local bag = getPlayerSlotItem(cid, 3).uid
        if balls > 0 then
            local poke = getItemAttribute(balls, "poke")
            if poke:lower() == name then
                selfSay("Thank you sir! Take your "..price.." dollars.", cid)
                doPlayerAddMoney(cid, price)
                doRemoveItem(balls, 1)
                talkState[talkUser] = 0
                return true
            end
        end
        for i = 1, #pokeballs do
            local pokeball = getItemsInContainerById(bag, pokeballs[i])
            for _, ball in pairs(pokeball) do
                local poke = getItemAttribute(ball, "poke")
                if poke:lower() == name then
                    selfSay("Thank you sir! Take your "..poke_price[name].." dollars.", cid)
                    doPlayerAddMoney(cid, price)
                    doRemoveItem(ball, 1)
                    talkState[talkUser] = 0
                    return true
                end
            end
        end
        return selfSay("You do not have this pokemon, or hi's fainted.", cid)
    end
        
    if msgcontains(msg:lower(), "pokemon") or msgcontains(msg:lower(), "help") or msgcontains(msg:lower(), "sell") then
        selfSay("Hi, do you wanna sell me some pokemon? Say {list} if you're curious about what pokemons I buy.", cid)
        talkState[talkUser] = 1
        return true
    elseif msgcontains(msg:lower(), "list") and talkState[talkUser] == 1 then
        local str = "Pokemon prices:"
        for poke, price in pairs(poke_price) do          
            str = str.."\n"..poke.." - "..price
        end
        doPlayerPopupFYI(cid, str)
        return true
    elseif talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
            return selfSay("Please dont possible selling pokemons, you fly/ride", cid)
        elseif #getCreatureSummons(cid) >= 1 then
            return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!", cid) 
        elseif not poke_price[msg:lower()] then
            return selfSay("I don't buy this pokemon.", cid)
        else
            sellPokemon(cid, msg:lower())
        end
    elseif msgcontains(msg:lower(), "no") or msgcontains(msg:lower(), "nao") and talkState[talkUser] == 1 then
        selfSay("Ok. Bye!", cid)
        talkState[talkUser] = 0
        return true
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())            

O erro saiu e rodou direitinho! Só que agora eu vou la e falo o nome do Pokémon e ele me fala isso:

 

09:36 Pokemon Collector: You do not have this pokemon, or hi's fainted.

 

E o pokémon ta na minha Bag!

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    local pokeballs = {2224, 2227, 2657, 2658, 2659, 2222, 2651, 2653, 2220, 2655}      
    
    local poke_price = {
        --["pokemon"] = price,
        ["bulbasaur"] = 3000,
        ["ivysaur"] = 5500,
        ["venusaur"] = 13500,
        ["charmander"] = 3000,
        ["charmeleon"] = 5500,
        ["charizard"] = 13500,
        ["squirtle"] = 3000,
        ["wartortle"] = 5500,
        ["blastoise"] = 13500,
    }
    
    local function sellPokemon(cid, name)
        local price = poke_price[name] * 100
        local balls = getPlayerSlotItem(cid, 8).uid
        local bag = getPlayerSlotItem(cid, 3).uid
        if balls > 0 then
            local poke = getItemAttribute(balls, "poke")
            if poke:lower() == name then
                selfSay("Thank you sir! Take your "..price.." dollars.", cid)
                doPlayerAddMoney(cid, price)
                doRemoveItem(balls, 1)
                talkState[talkUser] = 0
                return true
            end
        end
        for i = 1, #pokeballs do
            local pokeball = getItemsInContainerById(bag, pokeballs[i])
            for _, ball in pairs(pokeball) do
                local poke = getItemAttribute(ball, "poke")
                if poke:lower() == name then
                    selfSay("Thank you sir! Take your "..poke_price[name].." dollars.", cid)
                    doPlayerAddMoney(cid, price)
                    doRemoveItem(ball, 1)
                    talkState[talkUser] = 0
                    return true
                end
            end
        end
        return selfSay("You do not have this pokemon, or hi's fainted.", cid)
    end
        
    if msgcontains(msg:lower(), "pokemon") or msgcontains(msg:lower(), "help") or msgcontains(msg:lower(), "sell") then
        selfSay("Hi, do you wanna sell me some pokemon? Say {list} if you're curious about what pokemons I buy.", cid)
        talkState[talkUser] = 1
        return true
    elseif msgcontains(msg:lower(), "list") and talkState[talkUser] == 1 then
        local str = "Pokemon prices:"
        for poke, price in pairs(poke_price) do          
            str = str.."\n"..poke.." - "..price
        end
        doPlayerPopupFYI(cid, str)
        return true
    elseif talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) > 1 then       
            return selfSay("Please dont possible selling pokemons, you fly/ride", cid)
        elseif #getCreatureSummons(cid) >= 1 then
            return selfSay("Por favor, chame seu pokemon para a ball e mova para sua mochila!", cid) 
        elseif not poke_price[msg:lower()] then
            return selfSay("I don't buy this pokemon.", cid)
        else
            sellPokemon(cid, msg:lower())
        end
    elseif msgcontains(msg:lower(), "no") or msgcontains(msg:lower(), "nao") and talkState[talkUser] == 1 then
        selfSay("Ok. Bye!", cid)
        talkState[talkUser] = 0
        return true
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())            

Deu esse erro aqui, não sei se tem a ver com o Script!

 

[10/01/2015 12:01:33] [Error - MoveEvent::executeStep] Call stack overflow.

 

E também eu falo o nome do Pokémon e ele fala que eu não tenho esse Pokémon sendo que ele está na minha bag e vivo!

up

Link para o post
Compartilhar em outros sites

Ops, my bad. Eu errei o atributo. Editei meu comentário anterior com a correção.

Ah, e esse erro que você citou não tem nada a ver com o script.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Ops, my bad. Eu errei o atributo. Editei meu comentário anterior com a correção.

Ah, e esse erro que você citou não tem nada a ver com o script.

Poxa, vlw mesmo ta funcionando perfeitamente!

 

Reputado!

 

Se puder me ajudar em outro tópico eu agradeço!

 

http://www.tibiaking.com/forum/topic/49316-pedido-npc-que-vende-outfit/#entry286500

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo