Venho observado que a maioria dos bankers são feitos usando as funções io.open e etc, não gostei muito disso, por isso, resolvi fazer um sistema diferente. Eis as funções:
function balance(cid) local storage = 666 local value = getPlayerStorageValue(cid, storage) if value > 0 then selfSay('Your account balance is '..value..' gold.') else selfSay('You don\'t have money in your bank account.') end end function withdraw(cid, value) -- value pode ser %a para assim pegar a mensagem do player... local storage = 666 local balance = getPlayerStorageValue(cid, storage) if value < 0 then selfSay('You cannot withdraw negative values.') elseif balance < value then selfSay('There is not enough gold on your account.') else selfSay('Here you are, '..value..' gold. Please let me know if there is something else I can do for you.') setPlayerStorageValue(cid, storage, balance-value) doPlayerAddMoney(cid,value) end end function deposit(cid, value) -- value pode ser %a para assim pegar a mensagem do player... local storage = 666 local balance = getPlayerStorageValue(cid, storage) if value < 0 then selfSay('You cannot deposit negative values.') elseif doPlayerGetMoney(cid) < value then selfSay('You do not have enough gold.') elseif balance >= 0 and doPlayerGetMoney(cid) >= value then selfSay('Alright, we have added the amount of '..value..' gold to your balance. You can withdraw your money anytime you want to.') setPlayerStorageValue(cid, storage, balance + value) pay(cid,value) elseif balance < 0 and doPlayerGetMoney(cid) >= value then selfSay('Alright, we have added the amount of '..value..' gold to your balance. You can withdraw your money anytime you want to.') setPlayerStorageValue(cid, storage, balance + value+1) pay(cid,value) end end
Tenham bom proveito dessas funções.
Observações
Para usar a mesma, vocês devem ter a função doPlayerGetMoney, para quem não ter ela, vocês podem pegar aqui:
function doPlayerGetMoney(cid) local gold = getPlayerItemCount(cid,2148) local platinum = getPlayerItemCount(cid,2152) local crystal = getPlayerItemCount(cid,2160) local total = gold + (platinum*100) + (crystal*10000) return total end