Advertisement
Guest User

Untitled

a guest
Sep 7th, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function Player.depositMoney(self, amount)
  2. if not self:removeMoney(amount) then
  3. return false
  4. end
  5.  
  6. self:setBankBalance(self:getBankBalance() + amount)
  7. return true
  8. end
  9.  
  10. function Player.withdrawMoney(self, amount)
  11. local balance = self:getBankBalance()
  12. if amount > balance or not self:addMoney(amount) then
  13. return false
  14. end
  15.  
  16. self:setBankBalance(balance - amount)
  17. return true
  18. end
  19.  
  20. function Player.transferMoneyTo(self, target, amount)
  21. local balance = self:getBankBalance()
  22. if amount > balance then
  23. return false
  24. end
  25.  
  26. local targetPlayer = Player(target)
  27. if targetPlayer then
  28. targetPlayer:setBankBalance(targetPlayer:getBankBalance() + amount)
  29. else
  30. if not playerExists(target) then
  31. return false
  32. end
  33. db.query("UPDATE `players` SET `balance` = `balance` + '" .. amount .. "' WHERE `name` = " .. db.escapeString(target))
  34. end
  35.  
  36. self:setBankBalance(self:getBankBalance() - amount)
  37. return true
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement