local config = {
["cold area"] = {level = 2000, vocationid = {6, 10, 14, 18}, vocationname = "Elder Druid", "Natural Priest", "Priest", "Guardian Angel", amount = 20, itemid = 2157, location = {x = 1043, y = 621, z = 10}},
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
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 creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local tm = config[msg:lower()]
if msgcontains(msg, "bring me to") then
for mes, t in pairs(config) do
if msgcontains(msg, mes) then
if isPlayerPzLocked(cid) == true then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
return false
end
if doPlayerRemoveItem(cid, t.itemid, t.amount) and getPlayerVocation(cid) == t.vocationid and getPlayerLevel(cid) <= t.level then
npcHandler:say("You are a level ".. t.level .. " ".. t.vocationname .." and you paid ".. t.amount .." ".. getItemNameById(t.itemid) .." to travel and you have ".. getPlayerItemCount(cid, t.itemid) .." ".. getItemNameById(t.itemid) .." left in your backpack", cid)
doTeleportThing(cid, t.location)
else
npcHandler:say("I am sorry you are not a level ".. t.level .. " ".. t.vocationname .." or you don't have ".. getPlayerItemCount(cid, t.itemid) .." ".. getItemNameById(t.itemid) .." and it costs ".. t.amount .." ".. getItemNameById(t.itemid) .." to travel.", cid)
end
end
end
elseif tm then
if getPlayerItemCount(cid, tm.itemid) >= tm.amount and getPlayerVocation(cid) == tm.vocationid and getPlayerLevel(cid) >= tm.level then
npcHandler:say("Do you want to go to ".. msg .." for ".. tm.amount .." ".. getItemNameById(tm.itemid) .."? ... you do have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .."! You also need to be a level ".. tm.level .. " ".. tm.vocationname ..".", cid)
talkState[talkUser] = 1
xmsg[cid] = msg
else
npcHandler:say("I am sorry you are either not a level ".. tm.level .. " ".. tm.vocationname .." or you don't have ".. tm.amount .." ".. getItemNameById(tm.itemid) .." and it costs ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel.", cid)
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
local tm = config[xmsg[cid]:lower()]
if isPlayerPzLocked(cid) == true then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
return false
end
if doPlayerRemoveItem(cid, tm.itemid, tm.amount) and getPlayerVocation(cid) == tm.vocationid and getPlayerLevel(cid) >= tm.level then
npcHandler:say("You are a level ".. tm.level .. " ".. tm.vocationname .." and you paid ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel and you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." left in your backpack", cid)
doTeleportThing(cid, tm.location)
else
npcHandler:say("I am sorry you are either not a level ".. tm.level .. " ".. tm.vocationname .." or you don't have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." and it costs ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel.", cid)
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
npcHandler:releaseFocus(cid)
selfSay("Oh well, I guess not then.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())