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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
-- FUNCTIONS ---
local function length(t)
local count = 0
for key in pairs(t) do
count = count + 1
end
return count
end
local function selectText(list, size)
local selection = math.ceil(math.random(1, size))
return list[selection]
end
local greet = {
"Welcome to the Tar Valon Post."
}
npcHandler:setMessage(MESSAGE_GREET, selectText(greet, length(greet)))
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
news = {
"test a",
"test b",
"test c"
}
----KEYWORDS----
if msgcontains(msg, "news") then
selfSay(news[1], cid)
end
---QUEST---
if msgcontains(msg, 'quest') then
selfSay('Huh? Quest? Just a simple post office here. You looking for work?', cid)
setPlayerStorageValue(cid, 8000, 2)
end
if msgcontains(msg, 'test') and getPlayerStorageValue(cid, 8000) == 2 then
selfSay("This was a storagevalue response example!", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())