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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
--[[
REMEMBER TO SET YOUR STORAGE
]]--
local storage = 2097
local teleport = {x=1000, y=1000, z=7}
if(msgcontains(msg, 'travel') or msgcontains(msg, 'teleport')) then
if(getPlayerStorageValue(cid, storage) == -1) then
npcHandler:say("Bring me these three items...ITEMS HERE.", cid)
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("Did you bring me...THREE ITEMS HERE", cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
npcHandler:say("Let me teleport you!", cid)
doTeleportThing(cid, teleport, true)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, XXXX, 100) and doPlayerRemoveItem(cid, XXXX, 1) and doPlayerRemoveItem(cid, XXXX, 1) == TRUE) then
npcHandler:say("Thankyou, as promised here is your reward. I will teleport you.", cid)
doTeleportThing(cid, teleport, true)
setPlayerStorageValue(cid, storage, 2)
talkState[talkUser] = 0
else
npcHandler:say("Sorry, you do not have all the items, dont try scam me! Dont make me call the guards!", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Then not.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())