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 npcMissions = {
[1] = {name = "Rotworms",
storageMission = 43000,
windowMsg = "",
},
[2] = {name = "Cyclopes",
storageMission = 43001,
windowMsg = "",
},
[3] = {name = "Mutateds",
storageMission = 43002,
windowMsg = "",
},
[4] = {name = "Terramites",
storageMission = 43003,
windowMsg = "",
},
[5] = {name = "Dragons and Dragon Lords",
storageMission = 43004,
windowMsg = "",
},
[6] = {name = "Hydras",
storageMission = 43005,
windowMsg = "",
},
[7] = {name = "Giant Spiders",
storageMission = 43006,
windowMsg = "",
},
[8] = {name = "Nightmares",
storageMission = 43007,
windowMsg = "",
},
[9] = {name = "Wyrms and Elder Wyrms",
storageMission = 43008,
windowMsg = "",
},
[10] = {name = "Frost Dragons",
storageMission = 43009,
windowMsg = "",
},
}
local MESSAGES_GREET = {
[1] = "Hello |PLAYERNAME|. Do you want to do some {tasks} for me?",
[2] = "Hey buddy! I've got some {tasks} for you. Interested?",
[3] = "Another day another {task}, am I right?.",
}
local MESSAGES_GOODBYE = { -- This works the same as MESSAGES_GREET. Depending on how many tasks the player has done for the npc. The npc will say different things when he says goodbye to the player.
[1] = "Farewell |PLAYERNAME|.",
[2] = "See ya later.",
[3] = "Goodbye |PLAYERNAME|."
}
local arrayGreetings = {"hi", "Hi", "hello", "Hello", "hey", "Hey", "oi", "Oi", "hola", "Hola"}
local arrayFarewell = {"bye", "Bye", "goodbye", "Goodbye", "good-bye", "Good-Bye", "Good-bye", "cya", "adios", "Adios"}
local messageCompletedAllTasks = "I don't have any more tasks for you."
local taskWindowTitle = "Select an available task"
local taskWindowText = "Tasks"
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
player:setStorageValue(taskSystem)
if msgcontains(msg, "task") then
local window = ModalWindow(0x10, taskWindowTitle, taskWindowText)
local hasMissions = false
for i = 1, #npcMissions do
if player:getStorageValue(npcMissions[i].storageMission) < 2 then
window:addChoice(i, npcMissions[i].name)
hasMissions = true
end
end
if hasMissions then
window:addButton(0x00, "Exit")
window:addButton(0x01, "Select")
window:setDefaultEnterButton(0x01)
window:sendToPlayer(player)
return true
else
selfSay(messageCompletedAllTasks, cid)
return true
end
end
return true
end
function creatureFarewellCallback(cid)
local player = Player(cid)
if player then
selfSay(MESSAGES_GOODBYE[math.random(1, 3)], cid)
end
return false
end
function creatureGreetingCallback(cid)
local player = Player(cid)
if player then
selfSay(MESSAGES_GREET[math.random(1, 3)], cid)
end
return false
end
npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewellCallback)
npcHandler:setCallback(CALLBACK_GREET, creatureGreetingCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())