SHOW:
|
|
- or go back to the newest paste.
1 | function statsreq(jmeno) | |
2 | local myID = os.getComputerID() | |
3 | rednet.broadcast("requeststate", "ucel") | |
4 | rednet.broadcast(myID, "id") | |
5 | rednet.broadcast(jmeno, "kdo") | |
6 | local id, msgucet = rednet.receive() | |
7 | ucet = tonumber(msgucet) | |
8 | end | |
9 | ||
10 | function adminact() | |
11 | local pokracuj = true | |
12 | - | rednet.open("right") |
12 | + | while pokracuj do |
13 | term.clear() | |
14 | term.setCursorPos(1, 1) | |
15 | - | |
15 | + | statsreq("David") |
16 | ucetD = ucet | |
17 | statsreq("Filip") | |
18 | ucetF = ucet | |
19 | print("David: " .. ucetD) | |
20 | print("Filip: " .. ucetF) | |
21 | print("Pro pridani kreditu zadejte D pro Davida, F pro Filipa. Pro odhlaseni zadejte E.") | |
22 | local prikaz = read() | |
23 | - | statsreq("David") |
23 | + | if prikaz == "E" then |
24 | - | print("Stav uctu: " .. ucet) |
24 | + | pokracuj = false |
25 | - | print("done") |
25 | + | os.reboot() |
26 | ||
27 | elseif prikaz == "D" then | |
28 | pokracuj = false | |
29 | print("Kolik mam pridat kreditu?") | |
30 | - | statsreq("Filip") |
30 | + | local kolik = read() |
31 | - | print("Stav uctu: " .. ucet) |
31 | + | rednet.broadcast("admin", "ucel") |
32 | - | print("done") |
32 | + | rednet.broadcast("David", "kdo") |
33 | rednet.broadcast(kolik, "kolik") | |
34 | pokracuj = true | |
35 | ||
36 | elseif prikaz == "F" then | |
37 | pokracuj = false | |
38 | print("Kolik mam pridat kreditu?") | |
39 | local kolik = read() | |
40 | rednet.broadcast("admin", "ucel") | |
41 | rednet.broadcast("Filip", "kdo") | |
42 | rednet.broadcast(kolik, "kolik") | |
43 | pokracuj = true | |
44 | end | |
45 | end | |
46 | end | |
47 | ||
48 | --core | |
49 | rednet.open("top") | |
50 | passwordD = "david" | |
51 | passwordF = "filip" | |
52 | passwordA = "admin" | |
53 | ||
54 | local heslonerozpoznano = true | |
55 | while heslonerozpoznano do | |
56 | write("Heslo: ") | |
57 | local input = read("*") | |
58 | if input == passwordD then | |
59 | heslonerozpoznano = false | |
60 | print ("Prihlasen jako uzivatel David.") | |
61 | sleep(1,5) | |
62 | local pokracuj = true | |
63 | while pokracuj do | |
64 | statsreq("David") | |
65 | term.clear() | |
66 | term.setCursorPos(1, 1) | |
67 | print("Stav uctu: " .. ucet) | |
68 | print("Pro zaplaceni Filipovi zadejte F. Pro odhlaseni zadejte E.") | |
69 | local prikaz = read() | |
70 | if prikaz == "E" then | |
71 | pokracuj = false | |
72 | os.reboot() | |
73 | ||
74 | elseif prikaz == "F" then | |
75 | pokracuj = false | |
76 | print("Kolik mu mam zaplatit?") | |
77 | local koliko = read() | |
78 | local kolik = tonumber(koliko) | |
79 | if ucet >= kolik then | |
80 | rednet.broadcast("bankomat", "ucel") | |
81 | rednet.broadcast("Filip", "kdo") | |
82 | rednet.broadcast(kolik, "kolik") | |
83 | print("Na Filipuv ucet bylo odeslano " .. kolik .." kreditu.") | |
84 | sleep(2,5) | |
85 | pokracuj = true | |
86 | else print("Nedostatek financi!") | |
87 | sleep(2) | |
88 | pokracuj = true | |
89 | end | |
90 | end | |
91 | end | |
92 | elseif input == passwordF then | |
93 | heslonerozpoznano = false | |
94 | print ("Prihlasen jako uzivatel Filip.") | |
95 | sleep(1,5) | |
96 | local pokracuj = true | |
97 | while pokracuj do | |
98 | statsreq("Filip") | |
99 | term.clear() | |
100 | term.setCursorPos(1, 1) | |
101 | print("Stav uctu: " .. ucet) | |
102 | print("Pro zaplaceni Davidovi zadejte D. Pro odhlaseni zadejte E.") | |
103 | local prikaz = read() | |
104 | if prikaz == "E" then | |
105 | pokracuj = false | |
106 | os.reboot() | |
107 | ||
108 | elseif prikaz == "D" then | |
109 | pokracuj = false | |
110 | print("Kolik mu mam zaplatit?") | |
111 | local koliko = read() | |
112 | local kolik = tonumber(koliko) | |
113 | if ucet >= kolik then | |
114 | rednet.broadcast("bankomat", "ucel") | |
115 | rednet.broadcast("David", "kdo") | |
116 | rednet.broadcast(kolik, "kolik") | |
117 | print("Na Daviduv ucet bylo odeslano " .. kolik .." kreditu.") | |
118 | sleep(2,5) | |
119 | pokracuj = true | |
120 | else print("Nedostatek financi!") | |
121 | sleep(2) | |
122 | pokracuj = true | |
123 | end | |
124 | end | |
125 | end | |
126 | ||
127 | elseif input == passwordA then | |
128 | heslonerozpoznano = false | |
129 | print ("Gratuluji. Brutalne jsi se nahackoval do systemu.") | |
130 | sleep(2,5) | |
131 | adminact() | |
132 | ||
133 | else print ("Heslo nerozpoznano") | |
134 | sleep(1) | |
135 | end | |
136 | end |