local focus = 0
local talk_start = 0
local conv = 0
local cost = 0
local pname = ""
local baseprice = 0
local pokePrice = {
["Bulbasaur"] = 3000,
["Ivysaur"] = 8000,
["Venusaur"] = 18000,
["Charmander"] = 3000,
["Charmeleon"] = 8000,
["Charizard"] = 18000,
["Squirtle"] = 3000,
["Wartortle"] = 8000,
["Blastoise"] = 18000,
["Caterpie"] = 5,
["Metapod"] = 250,
["Butterfree"] = 2000,
["Weedle"] = 5,
["Kakuna"] = 250,
["Beedrill"] = 2000,
["Pidgey"] = 60,
["Pidgeotto"] = 1500,
["Pidgeot"] = 11500,
["Rattata"] = 5,
["Raticate"] = 2000,
["Spearow"] = 100,
["Fearow"] = 5100,
["Ekans"] = 300,
["Arbok"] = 3000,
["Pikachu"] = 8000,
["Raichu"] = 18000,
["Sandshrew"] = 1000,
["Sandslash"] = 6000,
["nidoranfe"] = 125,
["Nidorina"] = 2250,
["Nidoqueen"] = 12250,
["niroranma"] = 125,
["Nidorino"] = 2250,
["Nidoking"] = 12250,
["Clefairy"] = 8000,
["Clefable"] = 18000,
["Vulpix"] = 1000,
["Ninetales"] = 8500,
["Jigglypuff"] = 8000,
["Wigglytuff"] = 18000,
["Zubat"] = 300,
["Golbat"] = 3000,
["Oddish"] = 80,
["Gloom"] = 2250,
["Vileplume"] = 12000,
["Paras"] = 60,
["Parasect"] = 7250,
["Venonat"] = 1500,
["Venomoth"] = 7250,
["Diglett"] = 200,
["Dugtrio"] = 3000,
["Meowth"] = 300,
["Persian"] = 3000,
["Psyduck"] = 1500,
["Golduck"] = 11500,
["Mankey"] = 300,
["Primeape"] = 7250,
["Growlithe"] = 3500,
["Arcanine"] = 13500,
["Poliwag"] = 80,
["Poliwhirl"] = 3000,
["Poliwrath"] = 13000,
["Abra"] = 800,
["Kadabra"] = 5800,
["Alakazam"] = 15800,
["Machop"] = 2000,
["Machoke"] = 7000,
["Machamp"] = 17000,
["Bellsprout"] = 80,
["Weepinbell"] = 2250,
["Victreebel"] = 12000,
["Tentacool"] = 300,
["Tentacruel"] = 10000,
["Geodude"] = 300,
["Graveler"] = 5000,
["Golem"] = 15000,
["Ponyta"] = 1500,
["Rapidash"] = 6500,
["Slowpoke"] = 400,
["Slowbro"] = 5400,
["Magnemite"] = 400,
["Magneton"] = 5400,
["Farfetch'd"] = 10000,
["Doduo"] = 600,
["Dodrio"] = 5600,
["Seel"] = 2000,
["Dewgong"] = 12000,
["Grimer"] = 300,
["Muk"] = 3000,
["Shellder"] = 200,
["Cloyster"] = 10200,
["Gastly"] = 3000,
["Haunter"] = 8000,
["Gengar"] = 18000,
["Onix"] = 6000,
["Drowzee"] = 1000,
["Hypno"] = 6000,
["Krabby"] = 200,
["Kingler"] = 5200,
["Voltorb"] = 250,
["Electrode"] = 3000,
["Exeggcute"] = 200,
["Exeggutor"] = 10000,
["Cubone"] = 1000,
["Marowak"] = 11000,
["Hitmonlee"] = 500000,
["Hitmonchan"] = 500000,
["Lickitung"] = 60000,
["Koffing"] = 300,
["Weezing"] = 3000,
["Rhyhorn"] = 3000,
["Rhydon"] = 13000,
["Chansey"] = 40000,
["Tangela"] = 10000,
["Kangaskhan"] = 120000,
["Horsea"] = 200,
["Seadra"] = 8000,
["Goldeen"] = 200,
["Seaking"] = 3000,
["Staryu"] = 400,
["Starmie"] = 3000,
["Mr. Mime"] = 40000,
["Scyther"] = 120000,
["Jynx"] = 120000,
["Electabuzz"] = 120000,
["Magmar"] = 120000,
["Pinsir"] = 9000,
["Tauros"] = 5000,
["Magikarp"] = 5,
["Gyarados"] = 55000,
["Lapras"] = 120000,
["Ditto"] = 70000,
["Eevee"] = 45000,
["Vaporeon"] = 50000,
["Jolteon"] = 50000,
["Flareon"] = 50000,
["Porygon"] = 60000,
["Omanyte"] = 20000,
["Omastar"] = 75000,
["Kabuto"] = 20000,
["Kabutops"] = 75000,
["Aerodactyl"] = 2000000,
["Snorlax"] = 200000,
["Dratini"] = 15000,
["Dragonair"] = 65000,
["Dragonite"] = 125000,
}
function sellPokemon(cid, name, price)
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
if getPlayerSlotItem(cid, 8).uid ~= 0 then
if string.lower(getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke")) == string.lower(name) then
if not getItemAttribute(getPlayerSlotItem(cid, 8).uid, "unique") then --alterado v1.6
selfSay("Wow! Thanks for this wonderful "..name.."! Take yours "..price.." dollars. Would you like to sell another pokemon?")
doRemoveItem(getPlayerSlotItem(cid, 8).uid, 1) --alterado v1.6
doPlayerAddMoney(cid, price * 100)
doTransformItem(getPlayerSlotItem(cid, CONST_SLOT_LEGS).uid, 2395)
return true
end
end
end
for a, b in pairs(pokeballs) do
local balls = getItemsInContainerById(bp.uid, b.on)
for _, ball in pairs (balls) do
if string.lower(getItemAttribute(ball, "poke")) == string.lower(name) then
if not getItemAttribute(ball, "unique") then --alterado v1.6
selfSay("Wow! Thanks for this wonderful "..getItemAttribute(ball, "poke").."! Take yours "..price.." dollars. Would you like to sell another pokemon?")
doRemoveItem(ball, 1)
doPlayerAddMoney(cid, price * 100)
return true
end
end
end
end
selfSay("You don't have a "..name..", make sure it is in your backpack and it is not fainted and it is not in a Unique Ball!") --alterado v1.6
return false
end
function onCreatureSay(cid, type, msg)
local msg = string.lower(msg)
if string.find(msg, "!") or string.find(msg, ",") then
return true
end
if focus == cid then
talk_start = os.clock()
end
if msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) <= 3 then
selfSay('Welcome to my store! I buy pokemons of all species, just tell me the name of the pokemon you want to sell.')
focus = cid
conv = 1
talk_start = os.clock()
cost = 0
pname = ""
return true
end
if msgcontains(msg, 'bye') and focus == cid then
selfSay('See you around then!')
focus = 0
return true
end
if msgcontains(msg, 'yes') and focus == cid and conv == 4 then
selfSay('Tell me the name of the pokemon you would like to sell.')
conv = 1
return true
end
if msgcontains(msg, 'no') and conv == 4 and focus == cid then
selfSay('Ok, see you around then!')
focus = 0
return true
end
local common = {}
if conv == 1 and focus == cid then
for a = 1, #common do
if msgcontains(msg, common[a]) then
selfSay('I dont buy such a common pokemon!')
return true
end
end
end
if msgcontains(msg, 'no') and conv == 3 and focus == cid then
selfSay('Well, then what pokemon would you like to sell?')
conv = 1
return true
end
if (conv == 1 or conv == 4) and focus == cid then
local name = doCorrectPokemonName(msg)
local pokemon = pokes[name]
if not pokemon then
selfSay("Sorry, I don't know what pokemon you're talking about! Are you sure you spelled it correctly?")
return true
end
baseprice = pokePrice[name] or math.floor(pokemon.level * 150) --alterado v1.6
cost = baseprice
pname = name
selfSay("Are you sure you want to sell a "..name.." for "..cost.." dollars?")
conv = 3
end
if isConfirmMsg(msg) and focus == cid and conv == 3 then
if sellPokemon(cid, pname, cost) then
conv = 4
else
conv = 1
end
return true
end
end
local intervalmin = 38
local intervalmax = 70
local delay = 25
local number = 1
local messages = {"Buying some beautiful pokemons! Come here to sell them!",
"Wanna sell a pokemon? Came to the right place!",
"Buy pokemon! Excellent offers!",
"Tired of a pokemon? Why don't you sell it to me then?",
}
function onThink()
if focus == 0 then
selfTurn(1)
delay = delay - 0.5
if delay <= 0 then
selfSay(messages[number])
number = number + 1
if number > #messages then
number = 1
end
delay = math.random(intervalmin, intervalmax)
end
return true
else
if not isCreature(focus) then
focus = 0
return true
end
local npcpos = getThingPos(getThis())
local focpos = getThingPos(focus)
if npcpos.z ~= focpos.z then
focus = 0
return true
end
if (os.clock() - talk_start) > 70 then
focus = 0
selfSay("I have other clients too, talk to me when you feel like selling a pokemon.")
end
if getDistanceToCreature(focus) > 3 then
selfSay("Good bye then and thanks!")
focus = 0
return true
end
local dir = doDirectPos(npcpos, focpos)
selfTurn(dir)
end
return true
end