local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 cost = 500000
if msgcontains(msg, "necro") or msgcontains(msg, "necromancer") then
if getPlayerMoney(cid) >= cost then
npcHandler:say("Would you like to purchase the {Necromancer} outfit for 50 crystal coin's?", cid)
Topic[cid] = 1
else
npcHandler:say("Oh sorry, you don't have enough money.", cid)
npcHandler:releaseFocus(cid)
end
elseif msgcontains(msg, "yes") and Topic[cid] == 1 then
if not canPlayerWearOutfit(cid, 9, 0) then
if doPlayerRemoveMoney(cid, cost) then
doPlayerAddOutfit(cid, 9, 0)
npcHandler:say("Enjoy your new outfit, please logout to save your character.", cid)
Topic[cid] = 0
else
npcHandler:say("Oh sorry, you don't have enough money.", cid)
Topic[cid] = 0
end
else
npcHandler:say("Oh sorry, it seems you can wear this outfit already.", cid)
Topic[cid] = 0
end
elseif msgcontains(msg, "no") then
selfSay("Then leave!", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())