fiz uma por trade
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 shopWindow = {}
local spells = {
{id=1950, buy = 10000, name = "find person", vocations = {1,2,3,4,5,6,7,8}, level = 15},
{id=1950, buy = 15000, name = "flame strike", vocations = {1,2,5,6}, level = 20}
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if not getPlayerLearnedInstantSpell(cid, shopWindow[item].SpellName) then
if getPlayerLevel(cid) >= shopWindow[item].Level then
if isInArray(shopWindow[item].Vocs, getPlayerVocation(cid)) then
doPlayerRemoveMoney(cid, shopWindow[item].Price)
doPlayerLearnInstantSpell(cid, shopWindow[item].SpellName)
npcHandler:say("você aprendeu uma nova magia chamada "..shopWindow[item].SpellName, cid)
else
npcHandler:say("você não tem a vocação para comprar está spell.", cid)
end
else
npcHandler:say("você precisa ter level "..shopWindow[item].Level.." ou mais para comprar essa magia.", cid)
end
else
npcHandler:say("você já aprendeu essa magia.", cid)
end
return true
end
if msgcontains(msg, 'trade') or msgcontains(msg, 'spell') then
for var, item in pairs(spells) do
shopWindow[item.id] = {Level = item.level, Vocs = item.vocations, item_id = item.id, Price = item.buy, subType = 0, SpellName = item.name}
end
openShopWindow(cid, spells, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Te ajudei? Use por favor!!

Fan