local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 voices = { {text = "Sell VIP itens! Have a look!"} }
npcHandler:addModule(VoiceModule:new(voices))
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'Iron Pick'}, 27809, 100, 'Iron Pick')
shopModule:addSellableItem({'Small Stone'}, 27871, 12, 'Small Stone')
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
local vocationId = player:getVocation():getId()
local items = {
[1] = 2190,
[2] = 2182,
[5] = 2190,
[6] = 2182
}
--this part we can ignore for now --
if msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand') then
if table.contains({1, 2, 5, 6}, vocationId) then
if player:getStorageValue(PlayerStorageKeys.firstRod) == -1 then
selfSay('So you ask me for a {' .. ItemType(items[vocationId]):getName() .. '} to begin your adventure?', cid)
npcHandler.topic[cid] = 1
else
selfSay('What? I have already gave you one {' .. ItemType(items[vocationId]):getName() .. '}!', cid)
end
else
selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
end
elseif msgcontains(msg, 'yes') then
if npcHandler.topic[cid] == 1 then
player:addItem(items[vocationId], 1)
selfSay('Here you are young adept, take care yourself.', cid)
player:setStorageValue(PlayerStorageKeys.firstRod, 1)
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
selfSay('Ok then.', cid)
npcHandler.topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())