local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
npcHandler.talkRadius = 3
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 greet(cid)
npcHandler:say('Hello ' ..getPlayerName(cid).. '! I can make a global {broadcast} in case you are searching for a team to embark on a quest.', cid)
Topic[cid] = nil
npcHandler:addFocus(cid)
return false
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local price1, price2, price3 = 500, 500, 500
if msgcontains(msg, 'broadcast') then
npcHandler:say('So, you are interested! Very well. And you are looking to gather a team for which quest: {anihi1}, {anihi2}, {anihi3}?', cid)
elseif msgcontains(msg, 'anihi1') then
npcHandler:say('That broadcast will cost you ' ..price1.. ' gp. Do we have a deal?', cid)
Topic[cid] = 1
elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then
if doPlayerRemoveMoney(cid, price1) then
doPlayerBroadcastMessage(getNpcCid(), getPlayerName(cid).. " is calling all players to anihi1!")
npcHandler:say('Here we go - broadcasting live...', cid)
else
npcHandler:say('You don\'t have enough money.', cid)
end
elseif msgcontains(msg, 'anihi2') then
npcHandler:say('That broadcast will cost you ' ..price2.. ' gp. Do we have a deal?', cid)
Topic[cid] = 2
elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
if doPlayerRemoveMoney(cid, price2) then
doPlayerBroadcastMessage(getNpcCid(), getPlayerName(cid).. " is calling all players to anihi2!")
npcHandler:say('Here we go - broadcasting live...', cid)
else
npcHandler:say('You don\'t have enough money.', cid)
end
elseif msgcontains(msg, 'anihi3') then
npcHandler:say('That broadcast will cost you ' ..price3.. ' gp. Do we have a deal?', cid)
Topic[cid] = 3
elseif msgcontains(msg, 'yes') and Topic[cid] == 3 then
if doPlayerRemoveMoney(cid, price3) then
doPlayerBroadcastMessage(getNpcCid(), getPlayerName(cid).. " is calling all players to anihi2!")
npcHandler:say('Here we go - broadcasting live...', cid)
else
npcHandler:say('You don\'t have enough money.', cid)
end
elseif msgcontains(msg, 'no') and (Topic[cid] == 1 or Topic[cid] == 2 or Topic[cid] == 3) then
npcHandler:say('Well then.. Maybe some other time.', cid)
Topic[cid] = nil
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_FAREWELL, 'Bye.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Well goodbye to you too!')
npcHandler:addModule(FocusModule:new())