• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Npc Pokemoncollector

Treed

New Member
Joined
Feb 8, 2011
Messages
1
Reaction score
0
this script is the vodkart from xtibia
Link

Comprador.xml
Code:
<?xml version="1.0"?>
<npc name="Comprador" script="data/npc/scripts/buy_pokemons.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. want to sell me some {pokemon}? " />
</parameters>
</npc>

in npc/script

buy_pokemons.lua
Code:
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

    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, price) -- n sei de quem é essa função
local pokename = name
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local itemsball = getItemsInContainerById(bp.uid, 2222)
local itemsultra = getItemsInContainerById(bp.uid, 2220)
for _, pok in pairs(itemsball) do
if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, price)
selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)
return true
end
break
end
for _, pok in pairs(itemsultra) do
if string.lower(getItemAttribute(pok, "poke"):sub(9, findLetter(getItemAttribute(pok, "poke"), "'")-1)) == pokename then
doRemoveItem(pok, 1)
doPlayerAddMoney(cid, price)
selfSay("Wow! Thanks for this wonderful pokemon! Take your money.",cid)
return true
end
break
end
selfSay("Hey, you dont have this pokemon("..pokename..")! Make sure if its not fainted and it is inside your backpack!",cid)
end

local Pokemons = {
["gloom"] = {price = 150000},
["kakuna"] = {price = 25000},
["sandshrew"] = {price = 85000},
["pidgeot"] = {price = 550000},
["rattata"] = {price = 130000},
["pidgeotto"] = {price = 120000},
["poliwag"] = {price = 11000},
["horsea"] = {price = 20000},
["oddish"] = {price = 8000},
["bellsprout"] = {price = 10000},
["pidgey"] = {price = 5000},
["beedrill"] = {price = 120000},
["magnemite"] = {price = 60000},
["magneton"] = {price = 250000},
["raticate"] = {price = 85000},
["seadra"] = {price = 250000},
["doduo"] = {price = 65000},
["dodrio"] = {price = 300000},
["golbat"] = {price = 120000},
["graveler"] = {price = 160000},
["electrode"] = {price = 200000},
["victreebel"] = {price = 500000},
["poliwhirl"] = {price = 220000},
["bulbasaur"] = {price = 300000}
}

if(msgcontains(msg, "pokemon") or msgcontains(msg, "POKEMON")) then
selfSay("has some pokemon you want sell me? or you can look at the {list}!", cid) 
talkState[talkUser] = 1
elseif (msgcontains(msg, "list") or msgcontains(msg, "LIST")) and talkState[talkUser] == 1 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 Pokemons[msg]  and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 25000) == 5 then       
return selfSay("Você está montando.",cid)
elseif getPlayerStorageValue(cid, 23000) == 5 then
return selfSay("Você está voando.",cid)
elseif #getCreatureSummons(cid) >= 1 then
return selfSay("Voce precisa botar seus pokemons dentro da pokebola.",cid)
end
sellPokemon(cid, msg, Pokemons[msg].price)
elseif msg == "no" and talkState[talkUser] >= 1 then 
selfSay("Then not", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end 
return TRUE 
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

REP +++++ ?
 
Back
Top