local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
local TELEPORT_TABLE = {
["bank"] = {45000, 10000},
["depot"] = {45001, 20000},
}
local teleTable = {}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
teleTable[talkUser] = TELEPORT_TABLE[msg]
if msgcontains(msg, "bank") then
talkState[talkUser] = 1
teleTable[talkUser] = TELEPORT_TABLE["bank"]
selfSay("Do you want to buy bank access for " .. teleTable[talkUser][2] .. "?",cid)
elseif msgcontains(msg, "depot") then
talkState[talkUser] = 1
teleTable[talkUser] = TELEPORT_TABLE["depot"]
selfSay("Do you want to buy depot access for " .. teleTable[talkUser][2] .. "?",cid)
elseif talkState[talkUser] = 1 then
if msgcontains(msg, "yes")
if pay(cid, teleTable[talkUser][2] then
setPlayerStorageValue(cid, teleTable[talkUser][1], 1)
selfSay("All done", cid)
else
selfSay("You don't have enough money!",cid)
end
else
selfSay("What do you want then?", cid)
end
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())