Tente assim:
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 msg = string.lower(msg)
local promote = {
["vip"] = {level = 300, price = 0, promotion = 2, premium = true}
}
if promote[msg] then
if promote[msg].premium == true and not isPremium(cid) then
npcHandler:say('You need a premium account in order to get promoted', cid)
return true
end
if getPlayerPromotionLevel(cid) < promote[msg].promotion then
if getPlayerLevel(cid) >= promote[msg].level then
if doPlayerRemoveItem(cid, 2157, 400) then
setPlayerPromotionLevel(cid, promote[msg].promotion)
npcHandler:say('Congratulations! You are now promoted!', cid)
if getPlayerVocation(cid) == 9 then -- epic sorcerer
local newmana = getPlayerLevel(cid) * 8 + getCreatureMaxMana(cid)
setCreatureMaxMana(cid, newmana)
local newhp = getPlayerLevel(cid) * 5 + getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, newhp)
elseif getPlayerVocation(cid) == 10 then -- epic druid
local newmana = getPlayerLevel(cid) * 8 + getCreatureMaxMana(cid)
setCreatureMaxMana(cid, newmana)
local newhp = getPlayerLevel(cid) * 5 + getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, newhp)
elseif getPlayerVocation(cid) == 11 then -- epic paladin
local newmana = getPlayerLevel(cid) * 5 + getCreatureMaxMana(cid)
setCreatureMaxMana(cid, newmana)
local newhp = getPlayerLevel(cid) * 5 + getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, newhp)
elseif getPlayerVocation(cid) == 12 then -- epic knight
local newmana = getPlayerLevel(cid) * 2 + getCreatureMaxMana(cid)
setCreatureMaxMana(cid, newmana)
local newhp = getPlayerLevel(cid) * 20 + getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, newhp)
end
else
npcHandler:say('You need 200 epic Coins to buy this promotion.', cid)
end
else
npcHandler:say('I am sorry, but I can only promote you once you have reached level '..promote[msg].level, cid)
end
else
npcHandler:say('You are already promoted!', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())