SHOW:
|
|
- or go back to the newest paste.
1 | --[[ | |
2 | ||
3 | Bancomat | |
4 | ||
5 | ]]-- | |
6 | local component = require("component") | |
7 | local computer=require("computer") | |
8 | local event = require("event") | |
9 | local term = require("term") | |
10 | local shell = require("shell") | |
11 | local fs = require("filesystem") | |
12 | local unicode=require("unicode") | |
13 | local serial = require("serialization") | |
14 | -- Настройка пасхалки | |
15 | local pashalka = false | |
16 | local cheat_code = "gift_code_for_pastebin" | |
17 | local pas_summ = 77.7 | |
18 | -- ============ | |
19 | if not fs.exists("/lib/Sky.lua") then | |
20 | shell.execute("wget https://www.dropbox.com/s/1xbv3nrfpkm6mg0/Sky%28lib%29.lua?dl=1 /lib/Sky.lua") | |
21 | end | |
22 | if not fs.exists("/home/BankLogs.lua") then | |
23 | shell.execute("wget https://www.dropbox.com/s/x5mf2aiacacbj21/BankLogs.lua?dl=1 /home/BankLogs.lua") | |
24 | end | |
25 | ||
26 | local Sky = require("Sky") | |
27 | local g = component.gpu | |
28 | local chatbox = component.chat_box | |
29 | chatbox.setDistance(10) | |
30 | event.shouldInterrupt = function () return false end | |
31 | --------------------Настройки-------------------- | |
32 | local WIGHT, HEIGHT = 54, 29 --Разрешение моника | |
33 | local AUTOEXIT = 30 --Автовыход через n сек. | |
34 | local PRICE = 1 --Цена одной банкноты | |
35 | local BUY_PRICE = 1 --Цена перевода банкнот в эмы | |
36 | local COLOR1 = 0x00ff00 --Рамка | |
37 | local COLOR2 = 0x24b3a7 --Цвет кнопок | |
38 | local TONE = 600 --Тональность звука | |
39 | local CHAT_NAME = "§2[§3Банкомат§2]: " --Ник чатбокса | |
40 | local SUMMA_OP = 5 | |
41 | local money = 5254 -- ID денег | |
42 | local imput_limit = 2000 -- Лимит на ввод средств в сутки | |
43 | ------------------------------------------------- | |
44 | ||
45 | print("\nИнициализация...") | |
46 | os.sleep(2) | |
47 | print("Запуск программы...") | |
48 | os.sleep(2) | |
49 | ||
50 | local mid = WIGHT/2 | |
51 | local login = false | |
52 | local timer = 0 | |
53 | ||
54 | WIGHT, HEIGHT = Sky.Resolution(WIGHT,HEIGHT) | |
55 | Sky.Ram2("Банкомат", COLOR1,COLOR2,WIGHT,HEIGHT, false) | |
56 | ||
57 | function Login(w,h,nick) | |
58 | if w>=(WIGHT/2)-10 and w<=(WIGHT/2)+10 and h>=25 and h<=27 then | |
59 | if login == false then | |
60 | computer.addUser(nick) | |
61 | login = true | |
62 | Sky.Clear(WIGHT,HEIGHT) | |
63 | g.setForeground(COLOR2) | |
64 | Sky.Mid(WIGHT,3,"Добро пожаловать") | |
65 | Sky.Mid(WIGHT,6,"Ваш баланс:") | |
66 | g.setForeground(COLOR1) | |
67 | Sky.Mid(WIGHT,4,nick) | |
68 | Sky.Mid(WIGHT,7, " [ " .. Sky.Money(nick) .. " ] ") | |
69 | Sky.Mid(WIGHT,12, " Сумма " .. SUMMA_OP .. "$ ") | |
70 | Sky.Button((WIGHT/2)-10,25,20,3,COLOR1,COLOR2," Выход ") | |
71 | computer.beep(TONE, 0.05) | |
72 | Operacia() | |
73 | else | |
74 | Exit() | |
75 | end | |
76 | end | |
77 | end | |
78 | ||
79 | --[[function Logirovanie(nick, SUMMA_OP, Obnal) | |
80 | file = io.open("/home/BankLogs.lua", "w") | |
81 | local data, time = HostTime() | |
82 | local text = "" | |
83 | if Obnal == true then | |
84 | text = text .. data .. " " .. time .. " " .. nick .. " снял со счёта " .. SUMMA_OP .. " эмов." .."\n" | |
85 | else | |
86 | text = text .. data .. " " .. time .. " " .. nick .. " зачислил на счёт " .. SUMMA_OP .. " эмов." .."\n" | |
87 | end | |
88 | file:write(text) | |
89 | file:close() | |
90 | end]]-- | |
91 | --==================== Пасхалка ================== | |
92 | function file_exists(file) | |
93 | local f = io.open(file, "rb") | |
94 | if f then f:close() end | |
95 | return f ~= nil | |
96 | end | |
97 | ||
98 | function lines_from(file) | |
99 | if not file_exists(file) then return {} end | |
100 | lines = {} | |
101 | for line in io.lines(file) do | |
102 | lines[#lines + 1] = line | |
103 | end | |
104 | return lines | |
105 | end | |
106 | function check_cheater(nick) | |
107 | local lines = lines_from("/home/Cheaters.bd") | |
108 | for k,v in pairs(lines) do | |
109 | if (string.find(v, nick)) then | |
110 | return true | |
111 | end | |
112 | end | |
113 | return false | |
114 | end | |
115 | function add_cheater(nick) | |
116 | file = io.open("/home/Cheaters.bd", "a") | |
117 | file:write(nick.."\n") | |
118 | file:close() | |
119 | end | |
120 | function run_cheat(nick) | |
121 | ||
122 | computer.beep(TONE , 0.05) | |
123 | os.sleep(0,1) | |
124 | computer.beep(TONE + 100 , 0.05) | |
125 | os.sleep(0,1) | |
126 | computer.beep(TONE + 200 , 0.2) | |
127 | Sky.Com("money give " .. nick .. " " .. pas_summ) | |
128 | Sky.Com("msg " .. nick .. " " .. "You hacked this Bankomat. Check you balance. &4!!!Cheating reported!!!") | |
129 | add_cheater(nick) | |
130 | end | |
131 | --============== Конец пасхалки ================ | |
132 | function Exit() | |
133 | login = false | |
134 | Sky.Clear(WIGHT,HEIGHT) | |
135 | Info() | |
136 | SUMMA_OP = 5 | |
137 | local users={computer.users()} | |
138 | for i=1, #users do | |
139 | computer.removeUser(users[i]) | |
140 | end | |
141 | end | |
142 | ||
143 | function Operacia() | |
144 | Sky.Button(mid-17,19,6,3,COLOR1,COLOR2, "-50$") | |
145 | Sky.Button(mid-17,15,6,3,COLOR1,COLOR2, "-10$") | |
146 | Sky.Button(mid-17,11,6,3,COLOR1,COLOR2, "-1$ ") | |
147 | --Sky.Button(mid-10,14,20,3,COLOR1,COLOR2, "Сумма " .. SUMMA_OP .. "$") | |
148 | Sky.Button(mid+11,11,6,3,COLOR1,COLOR2, "+1$ ") | |
149 | Sky.Button(mid+11,15,6,3,COLOR1,COLOR2, "+10$") | |
150 | Sky.Button(mid+11,19,6,3,COLOR1,COLOR2, "+50$") | |
151 | Sky.Button(mid-7,15,14,3,COLOR1,COLOR2, " Обналичить ") | |
152 | Sky.Button(mid-7,19,14,3,COLOR1,COLOR2, " Положить ") | |
153 | end | |
154 | ||
155 | function autoExit() | |
156 | timer = timer - 1 | |
157 | g.setForeground(COLOR2) | |
158 | Sky.Mid(WIGHT,23, "Авто выход через: ") | |
159 | g.setForeground(COLOR1) | |
160 | g.set((WIGHT/2)+9, 23, timer .. " ") | |
161 | --[[if (smile) then | |
162 | Sky.Mid(WIGHT,26, "__(^o^)__") | |
163 | smile = false | |
164 | else | |
165 | Sky.Mid(WIGHT,26, " \\(^o^)/ ") | |
166 | smile = true | |
167 | end]]-- | |
168 | end | |
169 | ||
170 | function Obnal(w,h,nick,SUMMA_OP) | |
171 | if(Sky.Check_money(nick,SUMMA_OP)) then | |
172 | computer.beep(TONE, 0.05) | |
173 | Sky.Com("give ".. nick .. " " .. money .. " ".. SUMMA_OP) | |
174 | Sky.Com("bankomat ".. nick .. " " .. (SUMMA_OP * -1).. " false") | |
175 | Sky.Mid(WIGHT,7, " [ " .. Sky.Money(nick) .. " ] ") | |
176 | --Logirovanie(nick, SUMMA_OP, true) | |
177 | else | |
178 | Sky.Mid(WIGHT,9, "&4 Недостаточно средств!!! ") | |
179 | end | |
180 | end | |
181 | function check_limit(nick, SUMMA_OP, simulate) | |
182 | if (string.find(Sky.Com("bankomat " .. nick .. " " .. SUMMA_OP.. " " .. simulate), "true"))then | |
183 | return true | |
184 | else | |
185 | return false | |
186 | end | |
187 | end | |
188 | function Zachislen(w,h,nick,SUMMA_OP) | |
189 | ||
190 | if (check_limit(nick, SUMMA_OP, "true") ~= true) then | |
191 | Sky.Mid(WIGHT,9, "&4 Итоговая сумма привышает суточный лимит!") | |
192 | else | |
193 | if(Sky.TakeItem(nick, money, SUMMA_OP) and check_limit(nick, SUMMA_OP, "false") == true) then | |
194 | computer.beep(TONE, 0.05) | |
195 | Sky.Com("money give " .. nick .. " " .. SUMMA_OP) | |
196 | Sky.Mid(WIGHT,7, " [ " .. Sky.Money(nick) .. " ] ") | |
197 | --Logirovanie(nick, SUMMA_OP, false) | |
198 | else | |
199 | Sky.Mid(WIGHT,9, "&4 Недостаточно средств!!! ") | |
200 | end | |
201 | end | |
202 | ||
203 | end | |
204 | ||
205 | function getSumma(w,h) | |
206 | if w>= mid-17 and w<=mid-11 and h>=19 and h<=21 then -- -50$ | |
207 | SUMMA_OP = SUMMA_OP - 50 | |
208 | elseif w>= mid-17 and w<=mid-11 and h>=15 and h<=17 then -- -10$ | |
209 | SUMMA_OP = SUMMA_OP - 10 | |
210 | elseif w>= mid-17 and w<=mid-11 and h>=11 and h<=13 then -- -1$ | |
211 | SUMMA_OP = SUMMA_OP - 1 | |
212 | elseif w>= mid+11 and w<=mid+16 and h>=11 and h<=13 then -- +1$ | |
213 | SUMMA_OP = SUMMA_OP + 1 | |
214 | elseif w>= mid+11 and w<=mid+16 and h>=15 and h<=17 then -- +10$ | |
215 | SUMMA_OP = SUMMA_OP + 10 | |
216 | elseif w>= mid+11 and w<=mid+16 and h>=19 and h<=21 then -- +50$ | |
217 | SUMMA_OP = SUMMA_OP + 50 | |
218 | else | |
219 | return | |
220 | end | |
221 | if SUMMA_OP < 1 then | |
222 | SUMMA_OP = 1 | |
223 | end | |
224 | g.setForeground(COLOR1) | |
225 | Sky.Mid(WIGHT,12, " Сумма " .. SUMMA_OP .. "$ ") | |
226 | Sky.Mid(WIGHT,9, " ") | |
227 | end | |
228 | ||
229 | function Info() | |
230 | Sky.Symbol(mid-12,4,"b",0x000000) | |
231 | Sky.Symbol(mid-6,4,"a",0x000000) | |
232 | Sky.Symbol(mid,4,"n",0x000000) | |
233 | Sky.Symbol(mid+6,4,"k",0x000000) | |
234 | --[[Sky.Mid(WIGHT,10,"&3Здесь вы можете &2обналичить") | |
235 | Sky.Mid(WIGHT,11,"&3или &2зачислить&3 на свой счёт") | |
236 | Sky.Mid(WIGHT,12,"&2эмеральды&3.")]]-- | |
237 | Sky.Mid(WIGHT,14,"&4 Внимание!!! ") | |
238 | Sky.Mid(WIGHT,15,"&6Перед тем как снять деньги,") | |
239 | Sky.Mid(WIGHT,16,"&6убедитесь, что в инвентаре ") | |
240 | Sky.Mid(WIGHT,17,"&6достаточно места. ") | |
241 | Sky.Button((WIGHT/2)-10,25,20,3,COLOR1,COLOR2,"Залогиниться") | |
242 | end | |
243 | ||
244 | Exit() | |
245 | ||
246 | while true do | |
247 | local e,_,w,h,_,nick = event.pull(1, "touch") | |
248 | if (pashalka) then | |
249 | local chat = { event.pull(1, "chat_message") } | |
250 | if (chat[3] ~= nill and chat[4] ~= nill and string.find(chat[4], cheat_code) and check_cheater(chat[3]) ~= true) then | |
251 | run_cheat(chat[3]) | |
252 | end | |
253 | end | |
254 | ||
255 | if e == "touch" then | |
256 | Login(w,h,nick) | |
257 | if login then | |
258 | getSumma(w, h) | |
259 | if w>= mid-7 and w<=mid+5 and h>=15 and h<=17 then | |
260 | Obnal(w,h,nick,SUMMA_OP) | |
261 | elseif w>= mid-7 and w<=mid+5 and h>=19 and h<=21 then | |
262 | Zachislen(w,h,nick,SUMMA_OP) | |
263 | end | |
264 | end | |
265 | timer = AUTOEXIT | |
266 | end | |
267 | if (login) then | |
268 | autoExit() | |
269 | if timer == 0 then | |
270 | Exit() | |
271 | end | |
272 | end | |
273 | end |