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
local item_required_for_teleport = 9999
local item_count_required_for_teleport = 1
local timer = 5 -- minutes
local temp_storage = 45001
local nextPosition = {x = 0, y = 0, z = 0}
local returnPosition = {x = 0, y = 0, z = 0}
-- Teleport Player with Simple Storage Assign/Deassign
local function TPwSSAD(cid, position, storage)
if isPlayer(cid) then
if getPlayerStorageValue(cid, storage) == 1 then
setPlayerStorageValue(cid, storage, 0)
else
setPlayerStorageValue(cid, storage, 1)
end
doTeleportThing(cid, position)
doSendMagicEffect(position, CONST_ME_TELEPORT)
end
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, "mission") then
selfSay("Do you want to start the mission?", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if msgcontains(msg, "yes") then
if getPlayerItemCount(cid, item_required_for_teleport) >= item_count_required_for_teleport then
doPlayerRemoveItem(cid, item_required_for_teleport, item_count_required_for_teleport)
addEvent(TPwSSAD, 0, cid, nextPosition, temp_storage)
setPlayerStorageValue(cid, storage, 1)
addEvent(TPwSSAD, 1000 * 60 * timer, cid, returnPosition, temp_storage)
selfSay("After " .. timer .. " minutes we see each other again!", cid)
else
talkState[talkUser] = 0
selfSay("Come back later when you have the required item.", cid)
end
else
talkState[talkUser] = 0
selfSay("Come back later if you want a mission.", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())