Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function showacc()
- cteniD()
- cteniF()
- print("David: " .. ucetD)
- print("Filip: " .. ucetF)
- print("---------------")
- print(" ")
- end
- function zapisD()
- local fileD = fs.open("ucetDf", "w")
- fileD.writeLine(ucetD)
- fileD.close()
- end
- function zapisF()
- local fileF = fs.open("ucetFf", "w")
- fileF.writeLine(ucetF)
- fileF.close()
- end
- function cteniD()
- local fileD = fs.open("ucetDf", "r")
- ucetDs = fileD.readLine()
- ucetD = tonumber(ucetDs)
- if ucetD == nil then
- ucetD = 0
- end
- fileD.close()
- end
- function cteniF()
- local fileF = fs.open("ucetFf", "r")
- ucetFs = fileF.readLine()
- ucetF = tonumber(ucetFs)
- if ucetF == nil then
- ucetF = 0
- end
- fileF.close()
- end
- --zacatek
- if fs.exists("ucetDf") then
- showacc()
- rednet.open("top")
- while true do
- local id, msgwhat, protocol = rednet.receive("ucel")
- if msgwhat == "poptavka" then
- local id, msgwho, protocol = rednet.receive("kdo")
- local id, msghowmuch, protocol = rednet.receive("kolik")
- vydelek = tonumber(msghowmuch)
- if msgwho == "David"
- then
- cteniD()
- showacc()
- ucetD = ucetD + vydelek
- zapisD()
- end
- if msgwho == "Filip"
- then
- cteniF()
- ucetF = ucetF + vydelek
- zapisF()
- end
- showacc()
- elseif msgwhat == "admin" then
- local id, msgwho, protocol = rednet.receive("kdo")
- local id, msghowmuch, protocol = rednet.receive("kolik")
- cheaty = tonumber(msghowmuch)
- if msgwho == "David" then
- cteniD()
- ucetD = ucetD + cheaty
- zapisD()
- showacc()
- elseif msgwho == "Filip" then
- cteniF()
- ucetF = ucetF + cheaty
- zapisF()
- showacc()
- end
- elseif msgwhat == "bankomat" then
- local id, msgwho, protocol = rednet.receive("kdo")
- local id, msghowmuch, protocol = rednet.receive("kolik")
- transfer = tonumber(msghowmuch)
- if msgwho == "David" then
- cteniD()
- cteniF()
- ucetF = ucetF - transfer
- ucetD = ucetD + transfer
- zapisD()
- zapisF()
- showacc()
- elseif msgwho == "Filip" then
- cteniD()
- cteniF()
- ucetD = ucetD - transfer
- ucetF = ucetF + transfer
- zapisD()
- zapisF()
- showacc()
- end
- elseif msgwhat == "requeststate" then
- local id, msgid, protocol = rednet. receive("id")
- local id, msgwho, protocol = rednet.receive("kdo")
- if msgwho == "David" then
- cteniD()
- rednet.send(msgid, ucetD)
- elseif msgwho == "Filip" then
- cteniF()
- rednet.send(msgid, ucetF)
- end
- end
- end
- else
- local ucetD = 0
- local ucetF = 0
- zapisD()
- zapisF()
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement