---------------------------- transfer --------------------
elseif msgcontains(msg, 'transfer') then
npcHandler:say('Please tell me the amount of gold you would like to transfer.', cid)
npcHandler.topic[cid] = 11
elseif npcHandler.topic[cid] == 11 then
count[cid] = getMoneyCount(msg)
if player:getBankBalance() < count[cid] then
npcHandler:say('There is not enough gold on your account.', cid)
npcHandler.topic[cid] = 0
return true
end
if isValidMoney(count[cid]) then
npcHandler:say('Who would you like transfer ' .. count[cid] .. ' gold to?', cid)
npcHandler.topic[cid] = 12
else
npcHandler:say('There is not enough gold on your account.', cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] == 12 then
transfer[cid] = msg
if player:getName() == transfer[cid] then
npcHandler:say('Fill in this field with person who receives your gold!', cid)
npcHandler.topic[cid] = 0
return true
end
if playerExists(transfer[cid]) then
npcHandler:say('So you would like to transfer ' .. count[cid] .. ' gold to ' .. transfer[cid] .. '?', cid)
npcHandler.topic[cid] = 13
else
npcHandler:say('This player does not exist.', cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] == 13 then
if msgcontains(msg, 'yes') then
if not player:transferMoneyTo(transfer[cid], count[cid]) then
npcHandler:say('You cannot transfer money to this account.', cid)
else
npcHandler:say('Very well. You have transferred ' .. count[cid] .. ' gold to ' .. transfer[cid] ..'.', cid)
transfer[cid] = nil
end
elseif msgcontains(msg, 'no') then
npcHandler:say('Alright, is there something else I can do for you?', cid)
end
npcHandler.topic[cid] = 0
---------------------------- money exchange --------------
elseif msgcontains(msg, 'change gold') then
npcHandler:say('How many platinum coins would you like to get?', cid)
npcHandler.topic[cid] = 14
elseif npcHandler.topic[cid] == 14 then
if getMoneyCount(msg) < 1 then
npcHandler:say('Sorry, you do not have enough gold coins.', cid)
npcHandler.topic[cid] = 0
else
count[cid] = getMoneyCount(msg)
npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your gold coins into ' .. count[cid] .. ' platinum coins?', cid)
npcHandler.topic[cid] = 15
end
elseif npcHandler.topic[cid] == 15 then
if msgcontains(msg, 'yes') then
if player:removeItem(2148, count[cid] * 100) then
player:addItem(2152, count[cid])
npcHandler:say('Here you are.', cid)
else
npcHandler:say('Sorry, you do not have enough gold coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, 'change platinum') then
npcHandler:say('Would you like to change your platinum coins into gold or crystal?', cid)
npcHandler.topic[cid] = 16
elseif npcHandler.topic[cid] == 16 then
if msgcontains(msg, 'gold') then
npcHandler:say('How many platinum coins would you like to change into gold?', cid)
npcHandler.topic[cid] = 17
elseif msgcontains(msg, 'crystal') then
npcHandler:say('How many crystal coins would you like to get?', cid)
npcHandler.topic[cid] = 19
else
npcHandler:say('Well, can I help you with something else?', cid)
npcHandler.topic[cid] = 0
end
elseif npcHandler.topic[cid] == 17 then
if getMoneyCount(msg) < 1 then
npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
npcHandler.topic[cid] = 0
else
count[cid] = getMoneyCount(msg)
npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your platinum coins into ' .. count[cid] * 100 .. ' gold coins for you?', cid)
npcHandler.topic[cid] = 18
end
elseif npcHandler.topic[cid] == 18 then
if msgcontains(msg, 'yes') then
if player:removeItem(2152, count[cid]) then
player:addItem(2148, count[cid] * 100)
npcHandler:say('Here you are.', cid)
else
npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
npcHandler.topic[cid] = 0
elseif npcHandler.topic[cid] == 19 then
if getMoneyCount(msg) < 1 then
npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
npcHandler.topic[cid] = 0
else
count[cid] = getMoneyCount(msg)
npcHandler:say('So you would like me to change ' .. count[cid] * 100 .. ' of your platinum coins into ' .. count[cid] .. ' crystal coins for you?', cid)
npcHandler.topic[cid] = 20
end
elseif npcHandler.topic[cid] == 20 then
if msgcontains(msg, 'yes') then
if player:removeItem(2152, count[cid] * 100) then
player:addItem(2160, count[cid])
npcHandler:say('Here you are.', cid)
else
npcHandler:say('Sorry, you do not have enough platinum coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, 'change crystal') then
npcHandler:say('How many crystal coins would you like to change into platinum?', cid)
npcHandler.topic[cid] = 21
elseif npcHandler.topic[cid] == 21 then
if getMoneyCount(msg) < 1 then
npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
npcHandler.topic[cid] = 0
else
count[cid] = getMoneyCount(msg)
npcHandler:say('So you would like me to change ' .. count[cid] .. ' of your crystal coins into ' .. count[cid] * 100 .. ' platinum coins for you?', cid)
npcHandler.topic[cid] = 22
end
elseif npcHandler.topic[cid] == 22 then
if msgcontains(msg, 'yes') then
if player:removeItem(2160, count[cid]) then
player:addItem(2152, count[cid] * 100)
npcHandler:say('Here you are.', cid)
else
npcHandler:say('Sorry, you do not have enough crystal coins.', cid)
end
else
npcHandler:say('Well, can I help you with something else?', cid)
end
npcHandler.topic[cid] = 0
end
return true
end
keywordHandler:addKeyword({'money'}, StdModule.say, {npcHandler = npcHandler, text = 'We can {change} money for you. You can also access your {bank account}.'})
keywordHandler:addKeyword({'change'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three different coin types in Tibia: 100 gold coins equal 1 platinum coin, 100 platinum coins equal 1 crystal coin. So if you\'d like to change 100 gold into 1 platinum, simply say \'{change gold}\' and then \'1 platinum\'.'})
keywordHandler:addKeyword({'bank'}, StdModule.say, {npcHandler = npcHandler, text = 'We can {change} money for you. You can also access your {bank account}.'})
keywordHandler:addKeyword({'advanced'}, StdModule.say, {npcHandler = npcHandler, text = 'Your bank account will be used automatically when you want to {rent} a house or place an offer on an item on the {market}. Let me know if you want to know about how either one works.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, text = 'You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.'})
keywordHandler:addKeyword({'functions'}, StdModule.say, {npcHandler = npcHandler, text = 'You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.'})
keywordHandler:addKeyword({'basic'}, StdModule.say, {npcHandler = npcHandler, text = 'You can check the {balance} of your bank account, {deposit} money or {withdraw} it. You can also {transfer} money to other characters, provided that they have a vocation.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I work in this bank. I can change money for you and help you with your bank account.'})
npcHandler:setMessage(MESSAGE_GREET, "Yes? What may I do for you, |PLAYERNAME|? Bank business, perhaps?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Have a nice day.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Have a nice day.")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())