Postado Janeiro 10, 2015 10 anos Autor 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
Postado Janeiro 10, 2015 10 anos 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 Janeiro 10, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Janeiro 10, 2015 10 anos Autor 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
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.