• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Bank System fix script bug

ToloXXX

New Member
Joined
Dec 14, 2014
Messages
93
Reaction score
4
Hi, I have a bank system runned by command, but it gets bug after a certain amount when you deposit or withdraw, can anyone add a max cap on it like how can i add it to the script I have, if its possible, a cap max on the storage, deposting and withdrawing. Any help would be great. running 0.3.6 client 8.6 Here are my scripts:


Deposit:
Lua:
function onSay(cid, words, param)

local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}

if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then

if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end

local m = tonumber(param)

if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
return TRUE
end

m = math.abs(m)
if m <= getPlayerMoney(cid) then
doPlayerDepositMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Alright, you have added the amount of " .. m .. " gold to your balance. You can withdraw your money anytime you want to. Your account balance is " .. getPlayerBalance(cid) .. ".")

else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You do not have enough money.")
end
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end

Depositall:
Lua:
function onSay(cid, words, param)

local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}

if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Alright, you have added the amount of " .. getPlayerMoney(cid) .. " gold to your balance. You can withdraw your money anytime you want to.")
doPlayerDepositAllMoney(cid)
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end


Withdraw:
Lua:
function onSay(cid, words, param)

local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}

if config.bankSystemEnabled == TRUE then

local m = tonumber(param)
  
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
return TRUE
end

if(not m) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
return TRUE
end

 if m > 0 then 
          
        return false
       end
      
m = math.abs(m)
if m <= getPlayerBalance(cid) then
doPlayerWithdrawMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Here you are, " .. m .. " gold. Your account balance is " .. getPlayerBalance(cid) .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There is not enough gold on your account.")
end
return TRUE

else
return FALSE
end
end

Balance:
Lua:
function onSay(cid, words, param)

local config = {
bankSystemEnabled = getBooleanFromString(getConfigInfo('bankSystem')),
playerIsFighting = hasCondition(cid, CONDITION_INFIGHT)
}

if config.bankSystemEnabled == TRUE then
if config.playerIsFighting == FALSE then

doPlayerPopupFYI(cid, "Your account balance is " .. getPlayerBalance(cid) .. ".")
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
return TRUE
end
else
return FALSE
end
end
 
Last edited:
Solution
Let's start with the scripts, you can do something like this:
Lua:
function onSay(cid, words, param)
    if getBooleanFromString(getConfigInfo('bankSystem')) then
        if not hasCondition(cid, CONDITION_INFIGHT) then
            if param == "" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
                return true
            end

            local amount = tonumber(param)
            if not amount then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
                return true
            end

            amount = math.abs(amount)
            if amount >= MOBILE_BANK_DEPOSIT_LIMIT then...
Please read the rules; Rules for the Support board
#5

Not really sure if I understood you, but you want a max limit for withdraw and deposit?
But what do you mean with the storage, should players have diffrent limits?
And if the client crashes, what amount was used?
 
Please read the rules; Rules for the Support board
#5

Not really sure if I understood you, but you want a max limit for withdraw and deposit?
But what do you mean with the storage, should players have diffrent limits?
And if the client crashes, what amount was used?

yea just a max limit, and by storage i meant like is there a way to make a max limit on what players could hold on each account, and my bad forgot running 0.3.6 client 8.6
 
Let's start with the scripts, you can do something like this:
Lua:
function onSay(cid, words, param)
    if getBooleanFromString(getConfigInfo('bankSystem')) then
        if not hasCondition(cid, CONDITION_INFIGHT) then
            if param == "" then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires param.")
                return true
            end

            local amount = tonumber(param)
            if not amount then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires numeric param.")
                return true
            end

            amount = math.abs(amount)
            if amount >= MOBILE_BANK_DEPOSIT_LIMIT then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("You can't deposit more then %i gold at a time.", MOBILE_BANK_DEPOSIT_LIMIT))
                return true
            end

            local playerMoney = getPlayerMoney(cid)
            if amount + playerMoney >= MOBILE_BANK_MAX_BALANCE_LIMIT then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("You have reached the max balance allowed, %i gold.", MOBILE_BANK_DEPOSIT_LIMIT))
                return true
            end

            if amount <= playerMoney then
                doPlayerDepositMoney(cid, amount)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Alright, you have added the amount of " .. amount .. " gold to your balance. You can withdraw your money anytime you want to. Your account balance is " .. getPlayerBalance(cid) .. ".")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You do not have enough money.")
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Bank can not be used in fight.")
        end
        return true
    end

    return false
end

Add this to some lib file
Lua:
MOBILE_BANK_DEPOSIT_LIMIT = 50000
MOBILE_BANK_MAX_BALANCE_LIMIT = 500000

That will check if the player is trying to deposit more then x gold and if the amount the player is trying to deposit + the balance is over the max limit.

If you want it to be the same for all chars on the account you have to modify the account table in your database and then add a check for that aswell and with that I would create a new function to avoid making the script a huge if statment nest.

Another thing I would recommend you to do is to write all the scripts in one script, insted of having 5 diffrent ones for deposit, withdraw etc
 
Solution
Back
Top