local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local Topic = {}
local storage = 20000
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
if msgcontains(msg, "hi") or msgcontains(msg, "hello") then
if getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say("Have you brought the loot?", cid)
Topic[talkUser] = 1
end
npcHandler:addFocus(cid)
return true
end
if(not npcHandler:isFocused(cid)) then
return false
end
end
if msgcontains(msg, "mission") or msgcontains(msg, "guard") and getPlayerStorageValue(cid, storage) > 0 then
if getPlayerStorageValue(cid, storage) < 1 then
npcHandler:say("You wish to become a guard? Are you sure you want to become a guard?", cid)
Topic[talkUser] = 1
doSetPlayerStorageValue(cid, storage, 3)
elseif getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say("Have you brought the loot yet?", cid)
Topic[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 2 then
npcHandler:say("WIP.", cid)
Topic[talkUser] = 0
end
end
if msgcontains(msg, "yes") then
if getPlayerStorageValue(cid, storage) == 3 then
npcHandler:say("Alright, first, to become a guard, you have to prove your strength. Listen, lately, there have been some bandits lurking around the city, stealing stuff. I want you to take back the loot from them. Do you understand?", cid)
Topic[talkUser] = 1
doSetPlayerStorageValue(cid, storage, 4)
end
if msgcontains(msg, "yes") then
if getPlayerStorageValue(cid, storage) == 4 then
npcHandler:say("Good, go west from this hall, and you'll reach the west gate. Walk out of the city, and follow the sign warning of bandits. Good luck!", cid)
doSetPlayerStorageValue(cid, storage, 1)
npcHandler:releaseFocus(cid)
Topic[talkUser] = 0
end
elseif Topic[talkUser] == 1 then
if msgcontains(msg, "yes") then
if getPlayerItemCount(cid, 13537) >= 1 then
doPlayerRemoveItem(cid, 13537, 1)
npcHandler:say("You acutally did it! You've now become a guard, congratulations!", cid)
doPlayerAddExperience(cid, 5000)
doPlayerSetVocation(cid, 4)
setPlayerStorageValue(cid, storage, 2)
else
npcHandler:say("You dont have the items? Well, go and get them!", cid)
end
else
npcHandler:say("Hey, go and get them already!", cid)
end
Topic[talkUser] = 0
end
return TRUE
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)