local fight = createConditionObject(CONDITION_INFIGHT)
setConditionParam(fight, CONDITION_PARAM_TICKS, 90000) --time in seconds x1000
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 function greetCallback(cid)
if isPlayer(cid) then
doAddCondition(cid, fight)
end
return true
end
local function farewellCallBack(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
if (getCreatureCondition(cid, CONDITION_INFIGHT)) then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
doTeleportThing(cid, {x=37,y=117,z=7})
return true
end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'yes')) then
doTeleportThing(cid, {x = 37, y = 117, z = 7})
npcHandler:say("Good luck in there!", cid)
elseif(msgcontains(msg, 'no')) then
doTeleportThing(cid, {x = 37, y = 117, z = 7})
npcHandler:say("Too bad, you are going in anyway.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_FAREWELL, farewellCallBack)
npcHandler:setCallback(CALLBACK_CREATURE_DISAPPEAR, farewellCallBack)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())