Olá galera do TibiaKing, a um tempo eu estava querendo um NPC que vendia spells (magias)
Porém, eu não achava, na época não tinha, então, eu fui no ##### e pedi lá esse NPC que vendia spells pelo NPC, ai o "VODKART", postou esse NPC lá e me ajudou, e se não me engano, não existe esse NPC aqui no TK, então agora irá ter.
Chega de papo/enrolação e vamos para o que interessa.
Abra a pasta do seu OT/data/npc/NOME DO SEU NPC.xml e coloque isso:
Agora abra a pasta do seu OT/data/npc/scripts/spell_seller.lua e coloque isso:
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 moeda = 2157
local t = {
["light healing"] = {price = 15,vocations = {1,2,3,4},level = 9},
["find person"] = {price = 25,vocations = {3,4},level = 8},
["light magic missile"] = {price =30,vocations = {1,5,7,8},level = 15},
["energy strike"] = {price =20,vocations = {1,2,5,6},level = 12},
["flame strike"] = {price =100,vocations = {1,2,5,6},level = 12}
}
if (msgcontains(msg, 'SPELLS') or msgcontains(msg, 'spells'))then
local str = ""
str = str .. "Eu vendo estas Magias: "
for name, pos in pairs(t) do
str = str.." {"..name.."} = "..pos.price.." Moedas /"
end
str = str .. "."
npcHandler:say(str, cid)
elseif t[msg] then
if not getPlayerLearnedInstantSpell(cid, msg) then
if getPlayerLevel(cid) >= t[msg].level then
if isInArray(t[msg].vocations, getPlayerVocation(cid)) then
if doPlayerRemoveItem(cid,moeda,t[msg].price) then
doPlayerLearnInstantSpell(cid, msg)
npcHandler:say("Você aprendeu uma nova magia chamada ".. msg .."!", cid)
else
npcHandler:say("você não tem "..t[msg].price.." ".. getItemNameById(moeda), cid)
end
else
npcHandler:say("você não tem a vocação para comprar está spell.", cid)
end
else
npcHandler:say("você precisa ter level "..t[msg].level.." ou mais para comprar essa magia.", cid)
end
else
npcHandler:say("você já aprendeu essa magia.", cid)
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Configurando as spells que serão vendidas é aqui:
local t = {
["light Healing"] = {price = 15,vocations = {1,2,3,4},level = 9},
["find person"] = {price = 25,vocations = {3,4},level = 8},
["light magic missile"] = {price =30,vocations = {1,5,7,8},level = 15},
["energy strike"] = {price =20,vocations = {1,2,5,6},level = 12},
["flame strike"] = {price =100,vocations = {1,2,5,6},level = 12}
}
["Nome da Spells"] ={price = Quantos Coins (NO CASO ESTÁ COINS) irá custar.
Vocations ={ID DAS VOC},level = level para poder usar a magia}
E para usar a magia só quem comprou você faz o seguinte
vai em spells.xml e na tag da magia nessa parte:
needlearn="0"
Você coloca assim:
needlearn="1"
EXPLICANDO SOBRE O NEEDLEARN:
needlearn="1" -- Aqui está que precisa comprar a magia no NPC para poder usa-la.
needlearn="0" -- Aqui está que não precisa comprar a magia no NPC para poder usa-la.
CRÉDITOS:
Vodkart (Pelo Script)
Thiagobji (Pelo Tópico, Pelo Pedido e por postar no TibiaKing.com)
É ISSO GALERA, QUALQUER DÚVIDA SÓ POSTAR.