local config = {
actionId = 45000, -- place on each statue
missionStorage = 45000, -- storage of this mission
missionStorageValueStart = 1, -- value given to start mission by npc
missionStorageValueEnd = 2, -- value to check at npc for completed mission (which you then update to 3, to fully complete the mission)
statues = {
{45001, Position(245, 246, 7)}, -- {storage, positionOfStatue}
{45002, Position(247, 246, 7)},
{45003, Position(249, 246, 7)}
}
}
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)
npcHandler.topic[cid] = 0
return true
end
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msgcontains(msg, "mission") then
local storageValue = player:getStorageValue(config.missionStorage)
if storageValue < config.missionStorageValueStart then
npcHandler:say("Would you like to do mission 3?", cid)
npcHandler.topic[cid] = 1
elseif storageValue == config.missionStorageValueStart then
npcHandler:say("You haven't touched all of the statues yet.", cid)
npcHandler.topic[cid] = 0
elseif storageValue == config.missionStorageValueEnd then
npcHandler:say("Great work! Thanks for fondling all those statues.", cid)
player:setStorageValue(config.missionStorage, config.missionStorageValueEnd + 1)
npcHandler.topic[cid] = 0
else
npcHandler:say("I have no more missions for you.", cid)
npcHandler.topic[cid] = 0
end
return true
elseif npcHandler.topic[cid] == 1 then
if not msgcontains(msg, "yes") then
npcHandler:say("Another time then.", cid)
npcHandler.topic[cid] = 0
return true
end
npcHandler:say("Great. Go touch 3 statues.", cid)
player:setStorageValue(config.missionStorage, config.missionStorageValueStart)
npcHandler.topic[cid] = 0
return true
end
return true
end
local function onAddFocus(cid)
npcHandler.topic[cid] = 0
end
local function onReleaseFocus(cid)
npcHandler.topic[cid] = 0
end
npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
--npcHandler:setMessage(MESSAGE_GREET, "Welcome. Are you looking to get a {promotion}?")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())