• 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!

Lua [TFS 1.0] Global.lua (Function NPC)

Sentinel3

New Member
Joined
Oct 16, 2014
Messages
180
Reaction score
0
Hey!

Well, it's very simple I have TFS 1.0, but I can't find the function 'doPlayerWithdrawMoney' for Banker NPC like Naji.
Can someone pass me the function or tell me where can I find it?

By the way I have tryed one and it gives this error.

Thank you so much in advice!!

Error:
HTML:
Lua Script Error: [Npc interface]
data/npc/scripts/bank.lua:onCreatureSay
data/global.lua:830: attempt to call global 'getBooleanFromString' (a nil value)
stack traceback:
        [C]: in function 'getBooleanFromString'
        data/global.lua:830: in function 'doPlayerWithdrawMoney'
        data/npc/scripts/bank.lua:170: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:403: in function 'onCreatureSay'
        data/npc/scripts/bank.lua:14: in function <data/npc/scripts/bank.lua:14>

The function I have:
HTML:
function doPlayerWithdrawMoney(cid, amount)
        if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
    return false
end
        local balance = getPlayerBalance(cid)
          if(amount > balance or not doPlayerAddMoney(cid, amount)) then
    return false
end
        doPlayerSetBalance(cid, balance - amount)
    return true
end
 
Last edited:
Its from 0.4.
Code:
string.boolean = function (input)
    local tmp = type(input)
    if(tmp == 'boolean') then
        return input
    end

    if(tmp == 'number') then
        return input > 0
    end

    local str = string.lower(tostring(input))
    return (str == "yes" or str == "true" or (tonumber(str) ~= nil and tonumber(str) > 0))
end
getBooleanFromString = string.boolean
 
Its from 0.4.
Code:
string.boolean = function (input)
    local tmp = type(input)
    if(tmp == 'boolean') then
        return input
    end

    if(tmp == 'number') then
        return input > 0
    end

    local str = string.lower(tostring(input))
    return (str == "yes" or str == "true" or (tonumber(str) ~= nil and tonumber(str) > 0))
end
getBooleanFromString = string.boolean

This code where should goes? global.lua?
 
Sorry guys but dont work this functions, look I have this for 'doPlayerDepositMoney'

HTML:
function doPlayerDepositMoney(cid, amount)
 
   if(not doPlayerRemoveMoney(cid, amount)) then
  return false
  end
   
   doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
 
  return true
end

Can we change this function for 'doPlayerWithdrawMoney'?
 
sorry to bump old thread.
fixed the deposit ammount with this code in global.lua
Lua:
function doPlayerDepositMoney(cid, amount)
    if not doPlayerRemoveMoney(cid, amount) then
        return false
    end
     
    doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
    return true
end
after that when player try to withdarw the server console display an error related to doplayerwithdrawmomey function
then i added this
Code:
function doPlayerWithdrawMoney(cid, amount)
        if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
    return false
end
        local balance = getPlayerBalance(cid)
          if(amount > balance or not doPlayerAddMoney(cid, amount)) then
    return false
end
        doPlayerSetBalance(cid, balance - amount)
    return true
end

now the npc asys that i have no cash in bank and when i ask for balance it displays the ammount, now have no errors in console
Code:
04:10 GOD akak: hi
04:10 bank: Welcome GOD akak! What can I do for you?
04:10 GOD akak: withdraw 500
04:10 bank: Would you like to withdraw 500 gold?
04:10 GOD akak: yes
04:11 bank: You don't have that money amount on your bank account!
04:11 GOD akak: balance
04:11 bank: Your account balance is 1000020 gold.
04:12 bank: Good bye.
 
Back
Top