OTHispano
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

Ir abajo
Yerenix
Yerenix
Aportador
Mensajes Mensajes : 98

NPC que Compra Pokemons Empty NPC que Compra Pokemons

Dom Sep 25, 2011 12:34 am
bueno pille este script y se los traigo por k me parecio bueno para los k tienen su server pokemon XD

en data/npc acen copean algun npc.xml y lo ponen ai con el nombre de comprador luego lo abren borran todo y ponen esto:

Código:
<?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>

luego data/npc/scripts copean alguno le ponen de nombre buy_pokemons.lua y lo abren, borran todo y ponen esto:

Código:
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())

bueno para agregar mas pokemons ponen una linea como esta:

Código:
["gloom"] = {price = 150000},

["gloom"] = nombre del poke
{price = 150000} = dinero k te daran por el poke (10000 = 1cc tibia o 1hd pokemon)

y bueno eso XD

Creditos:
vodkart (xTibia)
ﻝhonLedit
ﻝhonLedit
Moderador
Mensajes Mensajes : 312
http://www.otsuporter.com/

NPC que Compra Pokemons Empty Re: NPC que Compra Pokemons

Dom Sep 25, 2011 3:26 pm
xD este npc esta muy bueno amm si te mereses tu rep
Volver arriba
Permisos de este foro:
No puedes responder a temas en este foro.