Advertisement
demongts1998

admin panel

May 10th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.44 KB | None | 0 0
  1. --|============================|
  2. --| OpenAdmins. |
  3. --| Автор: SkyDrive_ |
  4. --| Проект McSkill, cервер HTC |
  5. --| 14.05.2017 |
  6. --| Version: 1.02 |
  7. --|============================|
  8. local component = require("component")
  9. local computer=require("computer")
  10. local event = require("event")
  11. local term = require("term")
  12. local shell = require("shell")
  13. local fs = require("filesystem")
  14. local unicode=require("unicode")
  15. local serial = require("serialization")
  16. if not fs.exists("/lib/sky.lua") then
  17. shell.execute("wget https://www.dropbox.com/s/dhgifu198hjyzoy/sky.lua?dl=1 /lib/sky.lua")
  18. end
  19. local sky = require("sky")
  20. local g = component.gpu
  21. event.shouldInterrupt = function () return false end
  22. --------------------Настройки--------------------
  23. local WIDTH, HEIGHT = 146, 42 --Разрешение моника 146/112 x 42
  24. local COLOR1 = 0x00ffff --Рамка
  25. local COLOR2 = 0x333333 --Цвет кнопок
  26. local UPDATE = 300 --Апдейт отображения информации в сек.
  27. local SCOREBOARDS = {"Admin", "TAdmin", "Global", "GD", "GM", "STMod", "Dev", "Builder", "Modn",
  28. "Helper2", "Helper1"} --Названия Скорбордов (Создать такие же на серве, либо поменять тут)
  29. local MOD_CHAT_COLOR = {"&8", "&8", "&8", "&9", "&9", "&3", "&5", "&5", "&6", "&2", "&a"} --Изменение цвета ника в Мод.Чате
  30. -------------------------------------------------
  31. if not (fs.exists(shell.getWorkingDirectory() .. "/AdminsBD.lua")) then
  32. shell.execute("wget https://www.dropbox.com/s/ev2fuxc43m9v97o/AdminsBD.lua?dl=1")
  33. end
  34.  
  35. local mid = WIDTH / 2
  36. local sel = nil
  37. local admins
  38. local timer = 0
  39. local stat = {"&0[&4Админ&0] - &0", "&0[&4Тех.Админ&0] - &0", "&0[&4Глобал Мод&0] - &0", "&0[&9Дизайнер&0] - &3","&0[&9Гл.Модератор&0] - &3",
  40. "&0[&3Ст.Модератор&0] - &3", "&0[&5Разработчик&0] - &d", "&0[&5Строитель&0] - &d", "&0[&4Модератор&0] - &6","&0[&2Помощник&0] - &2", "&0[&aСтажёр&0] - &2"}
  41.  
  42. file = io.open(shell.getWorkingDirectory() .. "/AdminsBD.lua", "r")
  43. local reads = file:read(9999999)
  44. if reads ~= nil then
  45. admins = serial.unserialize("{" .. reads .. "}")
  46. else
  47. admins = {}
  48. end
  49. file:close()
  50.  
  51. g.setResolution(WIDTH, HEIGHT)
  52. sky.logo("OpenAdmins", COLOR1, COLOR2, WIDTH, HEIGHT)
  53.  
  54. function isOnline(nick)
  55. result,reason=computer.addUser(nick)
  56. computer.removeUser(nick)
  57. if result==true then
  58. return "&aонлайн"
  59. else
  60. return "&4оффлайн"
  61. end
  62. end
  63.  
  64. function Save()
  65. file = io.open(shell.getWorkingDirectory() .. "/AdminsBD.lua", "w")
  66. local text = ""
  67. for i = 1, #admins do
  68. text = text .. "{'"..admins[i][1].."','"..admins[i][2].."','"..admins[i][3].."'},\n"
  69. end
  70. file:write(text)
  71. file:close()
  72. end
  73.  
  74. function Seen(nick)
  75. local status=isOnline(nick)
  76. return status, 0, 0, 0, 0, 0
  77. end
  78.  
  79. function Update()
  80. for i = 1, #admins do
  81. g.set(mid-45,i+13," ")
  82. sky.text(mid-45, i+13, admins[i][1] .. admins[i][2])
  83. sky.text(mid-8, i+13, admins[i][3] .. " ")
  84.  
  85. sky.text(mid+4, i+13, "&6" .. sky.playtime(admins[i][2]) .. " ")
  86.  
  87. local status, year, month, day, hour, minute = Seen(admins[i][2])
  88. g.set(mid+20,i+13," ")
  89. if status == "&4error" then
  90. sky.text(mid+20,i+13, status)
  91. elseif year ~= 0 then
  92. sky.text(mid+20,i+13, status)
  93. elseif month ~= 0 then
  94. sky.text(mid+20,i+13, status)
  95. elseif day ~= 0 then
  96. sky.text(mid+20,i+13, status)
  97. else
  98. sky.text(mid+20,i+13, status)
  99. end
  100. end
  101. end
  102.  
  103. function Sort()
  104. local buffer = {}
  105. for i = 1, #stat do
  106. for j = 1, #admins do
  107. if stat[i] == admins[j][1] then
  108. table.insert(buffer, admins[j])
  109. end
  110. end
  111. end
  112. admins = buffer
  113. end
  114.  
  115. function Sel()
  116. for i = 1, #admins do
  117. sky.text(mid-51,i+13, " ")
  118. sky.text(mid+45,i+13, " ")
  119. if sel~= nil then
  120. if sel == admins[i][2] then
  121. sky.text(mid-51,i+13, "&b>>>")
  122. sky.text(mid+45,i+13, "&b<<<")
  123. end
  124. end
  125. end
  126. end
  127.  
  128. function Draw()
  129. if sel ~= nil then
  130. sky.button(mid-44,HEIGHT-4,20,3,COLOR1,COLOR2,"Повысить")
  131. sky.button(mid-22,HEIGHT-4,20,3,COLOR1,COLOR2,"Понизить")
  132. sky.button(mid+6,HEIGHT-4,20,3,COLOR1,COLOR2,"Male/Female")
  133. sky.button(mid+28,HEIGHT-4,20,3,COLOR1,COLOR2,"Удалить")
  134. else
  135. g.fill(3,HEIGHT-6, WIDTH-11, 5, " ")
  136. end
  137. end
  138.  
  139. function Index(array, value)
  140. for i = 1, #array do
  141. if value == array[i] then
  142. return i
  143. end
  144. end
  145. end
  146.  
  147. function Click(w,h)
  148. if sel~= nil then
  149. local sel_id
  150. for i = 1, #admins do
  151. if sel == admins[i][2] then
  152. sel_id = i
  153. break
  154. end
  155. end
  156. if w>=mid-44 and w<=mid-25 and h>=HEIGHT-4 and h<=HEIGHT-2 then
  157. index = Index(stat,admins[sel_id][1]) - 1
  158. if index == 0 then index = 1 end
  159. admins[sel_id][1] = stat[index]
  160. Sort()
  161. elseif w>=mid-22 and w<=mid-3 and h>=HEIGHT-4 and h<=HEIGHT-2 then
  162. index = Index(stat,admins[sel_id][1]) + 1
  163. if index == #stat + 1 then index = #stat end
  164. admins[sel_id][1] = stat[index]
  165. Sort()
  166. elseif w>=mid+6 and w<=mid+25 and h>=HEIGHT-4 and h<=HEIGHT-2 then
  167. if admins[sel_id][3] == "&bMale" then
  168. admins[sel_id][3] = "&dFemale"
  169. else
  170. admins[sel_id][3] = "&bMale"
  171. end
  172. elseif w>=mid+28 and w<=mid+47 and h>=HEIGHT-4 and h<=HEIGHT-2 then
  173. table.remove(admins, sel_id)
  174. g.fill(3,13,WIDTH-4,25, " ")
  175. end
  176. Update()
  177. Save()
  178. end
  179.  
  180. if w>=WIDTH-8 and w<=WIDTH-4 and h>=HEIGHT-4 and h<=HEIGHT-2 then
  181. sky.text(mid-44, HEIGHT-6,"&bВведите ник:")
  182. term.setCursor(mid-30, HEIGHT-6)
  183. local n = io.read()
  184. table.insert(admins, {stat[#stat], n, "&bMale"})
  185. g.set(mid-44, HEIGHT-6," ")
  186. Update()
  187. Save()
  188. end
  189.  
  190. if h-13 >= 1 and h-13 <= #admins then
  191. sel = admins[h-13][2]
  192. Sel()
  193. else
  194. sel = nil
  195. Sel()
  196. end
  197.  
  198. Draw()
  199. end
  200.  
  201. sky.button(WIDTH - 8,HEIGHT-4,5,3,COLOR1,COLOR2,"+")
  202. Update()
  203.  
  204. while true do
  205. local e,_,w,h,_,nick = event.pull(UPDATE, "touch")
  206. if e == "touch" then
  207. Click(w,h)
  208. end
  209. if sel == nil then
  210. Update()
  211. end
  212. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement