Reformulei o script do npc
-- Do not remove the credits --
-- Developed by Rigby --
-- Xtibia.com --
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
local needVocation = 1
local config = {
["Master sorcerer"] = {items = {2033, 1}, items2 = {5882, 5}, gainVocation = 5, storage = 221321321},
["Dark wizard"] = {items = {4852, 1}, items2 = {2144, 15}, gainVocation = 11, storage = 221321322},
["Blood Mage"] = {items = {10601, 10}, items2 = {5905, 2}, gainVocation = 12, storage = 221321323},
}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'yes') then
if getPlayerVocation(cid) == needVocation then
selfSay('Qual você quer?', cid)
for k, v in pairs(config) do
selfSay('{'..k..'}', cid)
talkState[talkUser] = 1
end
else
selfSay('Sua vocação não e digna destas promotions, ou voce ja recebeu sua promotion.', cid)
end
end
for i, q in pairs(config) do
if talkState[talkUser] == 1 and msgcontains(msg, ''..i..'') then
if getPlayerItemCount(cid, q.items[1]) >= q.items[2] and getPlayerItemCount(cid, q.items2[1]) >= q.items[2] then
selfSay('Parabêns você acaba de se tornar '..i..'', cid)
doPlayerSetVocation(cid, q.gainVocation)
doPlayerRemoveItem(cid, q.items[1], q.items[2])
doPlayerRemoveItem(cid, q.items2[1], q.items2[2])
setPlayerStorageValue(cid, q.storage, 1)
talkState[talkUser] = 2
else
selfSay('Você ter '..q.items[2]..' '..getItemNameById(q.items[1])..' e '..q.items2[2]..' '..getItemNameById(q.items2[1])..'.', cid)
end
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
e para que ele não perca a vocation
local config = {
--[storage] = vocation,
[221321321] = 5,
[221321322] = 11,
[221321323] = 12,
}
function onLogin(cid)
for i, q in pairs(config) do
if getPlayerStorageValue(cid, i) == 1 then
doPlayerSetVocation(cid, q)
end
end
return true
end