mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-12-17 01:17:12 +01:00
Updated to OTCv8 3.1 rev 118
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
CaveBot.Extensions.Bank = {}
|
||||
|
||||
local balance = 0
|
||||
|
||||
CaveBot.Extensions.Bank.setup = function()
|
||||
CaveBot.registerAction("bank", "#db5a5a", function(value, retries)
|
||||
local data = string.split(value, ",")
|
||||
@@ -7,7 +9,9 @@ CaveBot.Extensions.Bank.setup = function()
|
||||
local amount = 0
|
||||
local actionType
|
||||
local npcName
|
||||
if #data ~= 3 and #data ~= 2 then
|
||||
local transferName
|
||||
local balanceLeft
|
||||
if #data ~= 3 and #data ~= 2 and #data ~= 4 then
|
||||
warn("CaveBot[Bank]: incorrect value!")
|
||||
return false
|
||||
else
|
||||
@@ -16,10 +20,14 @@ CaveBot.Extensions.Bank.setup = function()
|
||||
if #data == 3 then
|
||||
amount = tonumber(data[3]:trim())
|
||||
end
|
||||
if #data == 4 then
|
||||
transferName = data[3]:trim()
|
||||
balanceLeft = tonumber(data[4]:trim())
|
||||
end
|
||||
end
|
||||
|
||||
if actionType ~= "withdraw" and actionType ~= "deposit" then
|
||||
warn("CaveBot[Bank]: incorrect action type! should be withdraw/deposit, is: " .. actionType)
|
||||
if actionType ~= "withdraw" and actionType ~= "deposit" and actionType ~= "transfer" then
|
||||
warn("CaveBot[Bank]: incorrect action type! should be withdraw/deposit/transfer, is: " .. actionType)
|
||||
return false
|
||||
elseif actionType == "withdraw" then
|
||||
local value = tonumber(amount)
|
||||
@@ -48,16 +56,37 @@ CaveBot.Extensions.Bank.setup = function()
|
||||
CaveBot.Conversation("hi", "deposit all", "yes")
|
||||
CaveBot.delay(storage.extras.talkDelay*3)
|
||||
return true
|
||||
else
|
||||
elseif actionType == "withdraw" then
|
||||
CaveBot.Conversation("hi", "withdraw", value, "yes")
|
||||
CaveBot.delay(storage.extras.talkDelay*4)
|
||||
return true
|
||||
else
|
||||
-- first check balance
|
||||
CaveBot.Conversation("hi", "balance")
|
||||
schedule(5000, function()
|
||||
local amountToTransfer = balance - balanceLeft
|
||||
if amountToTransfer <= 0 then
|
||||
warn("CaveBot[Bank] Not enough gold to transfer! proceeding")
|
||||
return false
|
||||
end
|
||||
CaveBot.Conversation("hi", "transfer", amountToTransfer, transferName, "yes")
|
||||
warn("CaveBot[Bank] transferred "..amountToTransfer.." gold to: "..transferName)
|
||||
end)
|
||||
CaveBot.delay(storage.extras.talkDelay*11)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
CaveBot.Editor.registerAction("bank", "bank", {
|
||||
value="action, NPC name",
|
||||
title="Banker",
|
||||
description="action type(withdraw/deposit), NPC name, if withdraw: amount",
|
||||
description="action type(withdraw/deposit/transfer), NPC name, (if withdraw: amount|if transfer: name, balance left)",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
onTalk(function(name, level, mode, text, channelId, pos)
|
||||
if mode == 51 and text:find("Your account balance is") then
|
||||
balance = getFirstNumberInText(text)
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user