Advertisement
VeryPiderast

Untitled

May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Задается при установке
  2. local shell = require("shell")
  3. local args = shell.parse(...)
  4. local authServerKey = "dffrtik-123kfdjksd-34mfng4ikj4nj&bdquery"
  5. local url = "80.211.37.43"
  6. local port = tonumber("20000")
  7. local serialization = require("serialization")
  8. local component = require("component")
  9. local event = require("event")
  10. local term = require("term")
  11. local unicode = require("unicode")
  12. local gpu = component.gpu
  13. local bg = gpu.getBackground()
  14. local fg = gpu.getForeground()
  15. local rd_from = 0.9
  16. local rd_to = 1.32
  17. local pwg = {}
  18. local base = {}
  19. local function getFromBD(post)
  20.     local result, response
  21.     local j = 0
  22.     local str =""
  23.     local i,k
  24.     while not result or str == "" do
  25.         if j>10 then os.sleep(10) end
  26.         j = j + 1
  27.         result, response = pcall(component.internet.connect, url, port)
  28.         response.write()
  29.         response.write(post .. '\n')
  30.         i = 0
  31.         k = nil
  32.         while i<10 and k == nil do
  33.             i = i + 1
  34.             k = response.read(1024)
  35.         end
  36.             i = 0
  37.             while i<100 and k ~= nil do
  38.                 i = i + 1
  39.                 str = str .. tostring(k)
  40.                 k = response.read(1024)
  41.             end
  42.     end
  43.     return serialization.unserialize(str)
  44. end
  45. function base.getAccount(nick)
  46.     return getFromBD("authkey=".. authServerKey .."&bdquery=getac&nick=" .. nick)
  47. end
  48. function base.getAccounts()
  49.     return getFromBD("authkey=".. authServerKey .."&bdquery=getacs")
  50. end
  51. function base.updAccount(nick,money)
  52.     return getFromBD("authkey=".. authServerKey .."&bdquery=updac&nick=".. nick .."&money=" .. money)
  53. end
  54. function base.getPrice(uid)
  55.     return getFromBD("authkey=".. authServerKey .."&bdquery=getpr&uid=" .. uid)
  56. end
  57. function base.getPrices()
  58.     return getFromBD("authkey=".. authServerKey .."&bdquery=getprs")
  59. end
  60. function base.updPrice(uid,label,buy,sell)
  61.     return getFromBD("authkey=".. authServerKey .."&bdquery=updpr&uid=".. uid .."&label=".. label .."&buy=".. buy .."&sell=".. sell)
  62. end
  63. --Фикс монитора
  64. function ScreenFix()
  65.     component.gpu.bind(component.screen.address,true)
  66. end
  67. event.timer(10,ScreenFix,math.huge)
  68. function drawBorder(x,y,width,height)
  69.         width = width - 1
  70.         height = height - 1
  71.         gpu.fill(x+1        ,y          ,width  ,1          ,unicode.char(10249))
  72.         gpu.fill(x          ,y          ,1      ,1          ,unicode.char(10319))
  73.         gpu.fill(x+1+width  ,y          ,1      ,1          ,unicode.char(10425))
  74.         gpu.fill(x          ,y+1        ,1      ,height     ,unicode.char(10311))
  75.         gpu.fill(x+1+width  ,y+1        ,1      ,height     ,unicode.char(10424))
  76.         gpu.fill(x+1        ,y+1+height ,width  ,1          ,unicode.char(10432))
  77.         gpu.fill(x          ,y+1+height ,1      ,1          ,unicode.char(10439))
  78.         gpu.fill(x+1+width  ,y+1+height ,1      ,1          ,unicode.char(10488))
  79. end
  80. function floor(ch)
  81.     return (ch - ch%0.01)
  82. end
  83. function starting()
  84.     while true do
  85.         pcall(io.read)
  86.         base.updAccount(100000)
  87.     end
  88. end
  89. while true do pcall(starting) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement