Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Задается при установке
- local shell = require("shell")
- local args = shell.parse(...)
- local authServerKey = "dffrtik-123kfdjksd-34mfng4ikj4nj&bdquery"
- local url = "80.211.37.43"
- local port = tonumber("20000")
- local serialization = require("serialization")
- local component = require("component")
- local event = require("event")
- local term = require("term")
- local unicode = require("unicode")
- local gpu = component.gpu
- local bg = gpu.getBackground()
- local fg = gpu.getForeground()
- local rd_from = 0.9
- local rd_to = 1.32
- local pwg = {}
- local base = {}
- local function getFromBD(post)
- local result, response
- local j = 0
- local str =""
- local i,k
- while not result or str == "" do
- if j>10 then os.sleep(10) end
- j = j + 1
- result, response = pcall(component.internet.connect, url, port)
- response.write()
- response.write(post .. '\n')
- i = 0
- k = nil
- while i<10 and k == nil do
- i = i + 1
- k = response.read(1024)
- end
- i = 0
- while i<100 and k ~= nil do
- i = i + 1
- str = str .. tostring(k)
- k = response.read(1024)
- end
- end
- return serialization.unserialize(str)
- end
- function base.getAccount(nick)
- return getFromBD("authkey=".. authServerKey .."&bdquery=getac&nick=" .. nick)
- end
- function base.getAccounts()
- return getFromBD("authkey=".. authServerKey .."&bdquery=getacs")
- end
- function base.updAccount(nick,money)
- return getFromBD("authkey=".. authServerKey .."&bdquery=updac&nick=".. nick .."&money=" .. money)
- end
- function base.getPrice(uid)
- return getFromBD("authkey=".. authServerKey .."&bdquery=getpr&uid=" .. uid)
- end
- function base.getPrices()
- return getFromBD("authkey=".. authServerKey .."&bdquery=getprs")
- end
- function base.updPrice(uid,label,buy,sell)
- return getFromBD("authkey=".. authServerKey .."&bdquery=updpr&uid=".. uid .."&label=".. label .."&buy=".. buy .."&sell=".. sell)
- end
- --Фикс монитора
- function ScreenFix()
- component.gpu.bind(component.screen.address,true)
- end
- event.timer(10,ScreenFix,math.huge)
- function drawBorder(x,y,width,height)
- width = width - 1
- height = height - 1
- gpu.fill(x+1 ,y ,width ,1 ,unicode.char(10249))
- gpu.fill(x ,y ,1 ,1 ,unicode.char(10319))
- gpu.fill(x+1+width ,y ,1 ,1 ,unicode.char(10425))
- gpu.fill(x ,y+1 ,1 ,height ,unicode.char(10311))
- gpu.fill(x+1+width ,y+1 ,1 ,height ,unicode.char(10424))
- gpu.fill(x+1 ,y+1+height ,width ,1 ,unicode.char(10432))
- gpu.fill(x ,y+1+height ,1 ,1 ,unicode.char(10439))
- gpu.fill(x+1+width ,y+1+height ,1 ,1 ,unicode.char(10488))
- end
- function floor(ch)
- return (ch - ch%0.01)
- end
- function starting()
- while true do
- pcall(io.read)
- base.updAccount(100000)
- end
- end
- while true do pcall(starting) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement