Advertisement
apolo12

50 functions sem o script

Apr 10th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. function getAccountNumberByPlayerName(name)
  2. local player = Player(name)
  3. if player ~= nil then
  4. return player:getAccountId()
  5. end
  6.  
  7. local resultId = db.storeQuery("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(name))
  8. if resultId ~= false then
  9. local accountId = result.getNumber(resultId, "account_id")
  10. result.free(resultId)
  11. return accountId
  12. end
  13. return 0
  14. end
  15.  
  16. function getMoneyCount(string)
  17. local b, e = string:find("%d+")
  18. local money = b and e and tonumber(string:sub(b, e)) or -1
  19. if isValidMoney(money) then
  20. return money
  21. end
  22. return -1
  23. end
  24.  
  25. function getMoneyWeight(money)
  26. local gold = money
  27. local crystal = math.floor(gold / 10000)
  28. gold = gold - crystal * 10000
  29. local platinum = math.floor(gold / 100)
  30. gold = gold - platinum * 100
  31. return (ItemType(2160):getWeight() * crystal) + (ItemType(2152):getWeight() * platinum) + (ItemType(2148):getWeight() * gold)
  32. end
  33.  
  34. function getRealDate()
  35. local month = tonumber(os.date("%m", os.time()))
  36. local day = tonumber(os.date("%d", os.time()))
  37.  
  38. if month < 10 then
  39. month = '0' .. month
  40. end
  41. if day < 10 then
  42. day = '0' .. day
  43. end
  44. return day .. '/' .. month
  45. end
  46.  
  47. function getRealTime()
  48. local hours = tonumber(os.date("%H", os.time()))
  49. local minutes = tonumber(os.date("%M", os.time()))
  50.  
  51. if hours < 10 then
  52. hours = '0' .. hours
  53. end
  54. if minutes < 10 then
  55. minutes = '0' .. minutes
  56. end
  57. return hours .. ':' .. minutes
  58. end
  59.  
  60. function isValidMoney(money)
  61. return isNumber(money) and money > 0 and money < 4294967296
  62. end
  63.  
  64. function iterateArea(func, from, to)
  65. for z = from.z, to.z do
  66. for y = from.y, to.y do
  67. for x = from.x, to.x do
  68. func(Position(x, y, z))
  69. end
  70. end
  71. end
  72. end
  73.  
  74. function playerExists(name)
  75. local resultId = db.storeQuery('SELECT `name` FROM `players` WHERE `name` = ' .. db.escapeString(name))
  76. if resultId then
  77. result.free(resultId)
  78. return true
  79. end
  80. return false
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement