function withdraw(player,cmd,number)
local number = tonumber(number)
local bankbalance = tonumber(getElementData(player, "account:bankbalance")) or 0
if not tonumber(number) then
outputChatBox("#27B86C[USE]: #ffffff/" .. cmd .. " [Ammount]", player, 38, 194, 129, true)
else
if tonumber(bankbalance) <= 0 then
outputChatBox("#B1092D[Error]: #ffffffYour bank balance is 0.", player, 177,9,45, true)
elseif bankbalance >= tonumber(number) then
givePlayerMoney(player,tonumber(number))
setElementData(player, "account:bankbalance", bankbalance - number)
else
outputChatBox("#B1092D[Error] #ffffffYou dont have enough money.", player, 177,9,45, true)
end
end
end
addCommandHandler("withdraw",withdraw)
The problem is, when i depositing some money, like $500, and when i withdrawing like this: /withdraw -555555555555 the server give me thats money. But when the account balance is 0, i can't withdraw negative amount. How can i stop that, when player wihtdrawing -$500000000000 when the balance is in negavite ?
I want thats, player ONLY can withdraw thats money, what they have on the account.