local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
outfit_need_premium = 'Sorry, you need a premium account to get outfits.'
outfit_have_already = 'Sorry, you already have this addon.'
outfit_give = 'Here you are.'
if msgcontains(msg, 'norseman outfit') then
if isPremium(cid) then
selfSay('Would u like to buy norseman outfit for 10k?')
talk_state = 1
else
selfSay(outfit_need_premium)
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,7290) >= 5 then
outfit = getPlayerStorageValue(cid,150003)
if outfit == -1 then
if doPlayerTakeMoney(cid,10000) then
selfSay(addon_give)
doPlayerAddOutfit(cid, 251, 1)
doPlayerAddOutfit(cid, 252, 1)
doPlayerAddOutfit(cid, 251, 2)
doPlayerAddOutfit(cid, 252, 2)
setPlayerStorageValue(cid,150003,1)
end
else
selfSay(outfit_have_already)
end
else
selfSay(outfit_have_not_items)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
selfSay('Ok than.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())