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
function creatureSayCallback(cid, type, msg)
local player = Player(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
if msgcontains(msg, "hi") or msgcontains(msg, "hello") and not npcHandler:isFocused(cid) then
if player:isPremium() then
npcHandler:say("Hello, "..getCreatureName(cid).."!", cid)
npcHandler:addFocus(cid)
talkState[talkUser] = 0
else
npcHandler:say("Only premium players can talk to me...", cid)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
end
return true
end
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("Goodbye!", cid, TRUE)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)