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 greet(cid) talkState[cid] = 0 return true end
function getNpcName()
return getCreatureName(getNpcId())
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, "job") then
selfSay("My job is to show the world how fashionable they can be!", cid)
elseif msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
elseif msgcontains(msg, "mission") then
if getPlayerStorageValue(cid, 45001) < 1 then
selfSay("Would you like to start mission 1?", cid)
elseif getPlayerStorageValue(cid, 45001) == 2 then
selfSay("Would you like to finish mission 2?", cid)
elseif getPlayerStorageValue(cid, 45001) == 4 then
selfSay("Would you like to finish mission 3?", cid)
elseif getPlayerStorageValue(cid, 45001) == 6 then
selfSay("You have finished all of the available missions.", cid)
talkState[talkUser] = 0
return true
else
selfSay("Say finish, to complete your mission.", cid)
talkState[talkUser] = 0
return true
end
talkState[talkUser] = 1
return true
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, 45001) < 1 then
selfSay("Great. Say finish, to complete mission 1.", cid)
setPlayerStorageValue(cid, 45001, 1)
elseif getPlayerStorageValue(cid, 45001) == 2 then
selfSay("Great. Say finish, to complete mission 2.", cid)
setPlayerStorageValue(cid, 45001, 3)
elseif getPlayerStorageValue(cid, 45001) == 4 then
selfSay("Great. Say finish, to complete mission 3.", cid)
setPlayerStorageValue(cid, 45001, 5)
end
talkState[talkUser] = 0
return true
elseif msgcontains(msg, "finish") then
if getPlayerStorageValue(cid, 45001) == 1 then
selfSay("Mission 1 complete.", cid)
setPlayerStorageValue(cid, 45001, 2)
elseif getPlayerStorageValue(cid, 45001) == 3 then
selfSay("Mission 2 complete.", cid)
setPlayerStorageValue(cid, 45001, 4)
elseif getPlayerStorageValue(cid, 45001) == 5 then
selfSay("Mission 3 complete.", cid)
setPlayerStorageValue(cid, 45001, 6)
else
selfSay("You have no active missions.", cid)
end
talkState[talkUser] = 0
return true
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())