Advertisement
Guest User

Untitled

a guest
Jan 5th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.63 KB | None | 0 0
  1. function jp(gracz)
  2. if getElementData(gracz, "duty") then
  3. if doesPlayerHaveJetPack(gracz) then
  4. removePlayerJetPack(gracz)
  5. else
  6. givePlayerJetPack(gracz)
  7. end
  8. end
  9. end
  10.  
  11. local jednostki = {
  12. ["m"] = true,
  13. ["h"] = true,
  14. ["d"] = true,
  15. }
  16.  
  17. function getTimestamp(year, month, day, hour, minute, second)
  18. -- initiate variables
  19. local monthseconds = { 2678400, 2419200, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400 }
  20. local timestamp = 0
  21. local datetime = getRealTime()
  22. year, month, day = year or datetime.year + 1900, month or datetime.month + 1, day or datetime.monthday
  23. hour, minute, second = hour or datetime.hour, minute or datetime.minute, second or datetime.second
  24.  
  25. -- calculate timestamp
  26. for i=1970, year-1 do timestamp = timestamp + (isLeapYear(i) and 31622400 or 31536000) end
  27. for i=1, month-1 do timestamp = timestamp + ((isLeapYear(year) and i == 2) and 2505600 or monthseconds[i]) end
  28. timestamp = timestamp + 86400 * (day - 1) + 3600 * hour + 60 * minute + second
  29.  
  30. timestamp = timestamp - 3600 --GMT+1 compensation
  31. if datetime.isdst then timestamp = timestamp - 3600 end
  32.  
  33. return timestamp
  34. end
  35.  
  36. function isLeapYear(year)
  37. if year then year = math.floor(year)
  38. else year = getRealTime().year + 1900 end
  39. return ((year % 4 == 0 and year % 100 ~= 0) or year % 400 == 0)
  40. end
  41.  
  42. function zbanuj(plr, cmd, target, t1, t2, ...)
  43. if not getElementData(plr, "duty") then return end
  44. if not target or not t1 or not t2 or not ... then
  45. return
  46. end
  47. local player = findPlayer(plr, target)
  48. if not player then return end
  49. local text = table.concat({...}, ", ")
  50. local ts_start = getTimestamp()
  51. if t1 == "m" then
  52. local t2 = tonumber(t2)
  53. local ts_final = ts_start + t2*60
  54. local time = getRealTime(ts_final)
  55. local txt = getPlayerName(player).." został zbanowany przez "..getPlayerName(plr).." na czas "..t2.." minut z powodu "..text
  56. triggerClientEvent(getRootElement(), "notiAdmin", getRootElement(), txt)
  57. outputConsole(txt)
  58. local user_id = getElementData(player, "dbid")
  59. local user_serial = getPlayerSerial(player)
  60. local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
  61. exports.mysql:wykonaj("INSERT INTO bany SET nick=?, serial=?, ip=?, data=?, admin=?", getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_date, getPlayerName(plr))
  62. kickPlayer(player, "Połącz się ponownie")
  63. elseif t1 == "h" then
  64. local t2 = tonumber(t2)
  65. local ts_final = ts_start + t2*3600
  66. local time = getRealTime(ts_final)
  67. local txt = getPlayerName(player).." został zbanowany przez "..getPlayerName(plr).." na czas "..t2.." godzin z powodu "..text
  68. triggerClientEvent(getRootElement(), "notiAdmin", getRootElement(), txt)
  69. outputConsole(txt)
  70. local user_id = getElementData(player, "dbid")
  71. local user_serial = getPlayerSerial(player)
  72. local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
  73. exports.mysql:wykonaj("INSERT INTO bany SET nick=?, serial=?, ip=?, data=?, admin=?", getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_date, getPlayerName(plr))
  74. kickPlayer(player, "Połącz się ponownie")
  75. elseif t1 == "d" then
  76. local t2 = tonumber(t2)
  77. local ts_final = ts_start + t2*86400
  78. local time = getRealTime(ts_final)
  79. local txt = getPlayerName(player).." został zbanowany przez "..getPlayerName(plr).." na czas "..t2.." dni z powodu "..text
  80. triggerClientEvent(getRootElement(), "notiAdmin", getRootElement(), txt)
  81. outputConsole(txt)
  82. local user_id = getElementData(player, "dbid")
  83. local user_serial = getPlayerSerial(player)
  84. local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
  85. exports.mysql:wykonaj("INSERT INTO bany SET nick=?, serial=?, ip=?, data=?, admin=?", getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_date, getPlayerName(plr))
  86. kickPlayer(player, "Połącz się ponownie")
  87. end
  88. end
  89.  
  90. function kicknij(gracz, _, graczhere, ...)
  91. if graczhere and ... and getElementData(gracz, "duty") then
  92. graczhere = findPlayer(gracz, graczhere)
  93. if not graczhere then
  94. exports["nm-noti"]:noti("Nie znaleziono podanego gracza.", gracz)
  95. return
  96. end
  97. local tresc = table.concat({...}, " ")
  98. local txt = getPlayerName(graczhere).." został wykopany przez "..getPlayerName(gracz).." z powodu "..tresc
  99. kickPlayer(graczhere, gracz, tresc)
  100. outputConsole(txt)
  101. triggerClientEvent(root, "notiAdmin", root, txt)
  102. end
  103. end
  104.  
  105. function warnij(gracz, _, graczhere, ...)
  106. if graczhere and ... and getElementData(gracz, "duty") then
  107. graczhere = findPlayer(gracz, graczhere)
  108. if not graczhere then
  109. exports["nm-noti"]:noti("Nie znaleziono podanego gracza.", gracz)
  110. return
  111. end
  112. local tresc = table.concat({...}, " ")
  113. local txt = getPlayerName(graczhere).." został ostrzeżony przez "..getPlayerName(gracz).." z powodu "..tresc
  114. outputChatBox(" ", graczhere, 255, 0, 0)
  115. outputChatBox("Otrzymałeś ostrzeżenie od "..getPlayerName(gracz), graczhere, 255, 0, 0)
  116. outputChatBox(" ", graczhere, 255, 0, 0)
  117. outputChatBox("Powód: "..tresc, graczhere, 255, 255, 255)
  118. outputChatBox(" ", graczhere, 255, 0, 0)
  119. outputChatBox("Nie stosowanie się do ostrzeżenia, może skutkować kickiem lub banem.", graczhere, 0, 131, 255)
  120. outputConsole(txt)
  121. triggerClientEvent(root, "notiAdmin", root, txt)
  122. triggerClientEvent(graczhere, "warnPlayer", root, {
  123. ["powod"] = tresc,
  124. ["kto"] = getPlayerName(gracz),
  125. })
  126. end
  127. end
  128.  
  129. function prawko(plr, cmd, target, t1, t2, ...)
  130. if not getElementData(plr, "duty") then return end
  131. if not target or not t1 or not t2 or not ... then
  132. return
  133. end
  134. local player = findPlayer(plr, target)
  135. if not player then return end
  136. local text = table.concat({...}, ", ")
  137. local ts_start = getTimestamp()
  138. if t1 == "m" then
  139. local t2 = tonumber(t2)
  140. local ts_final = ts_start + t2*60-3600
  141. local time = getRealTime(ts_final)
  142. local txt = getPlayerName(player).." otrzymał zakaz prowadzenia pojazdów kat. A,B,C od "..getPlayerName(plr).." na czas "..t2.." minut z powodu "..text
  143. triggerClientEvent(getRootElement(), "notiAdmin", getRootElement(), txt)
  144. outputConsole(txt)
  145. local user_id = getElementData(player, "dbid")
  146. local user_serial = getPlayerSerial(player)
  147. removePedFromVehicle(player)
  148. local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
  149. exports.mysql:wykonaj("INSERT INTO prawka SET nick=?, serial=?, ip=?, data=?, admin=?", getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_date, getPlayerName(plr))
  150. elseif t1 == "h" then
  151. local t2 = tonumber(t2)
  152. local ts_final = ts_start + t2*3600-3600
  153. local time = getRealTime(ts_final)
  154. removePedFromVehicle(player)
  155. local txt = getPlayerName(player).." otrzymał zakaz prowadzenia pojazdów kat. A,B,C od "..getPlayerName(plr).." na czas "..t2.." godzin z powodu "..text
  156. triggerClientEvent(getRootElement(), "notiAdmin", getRootElement(), txt)
  157. outputConsole(txt)
  158. local user_id = getElementData(player, "dbid")
  159. local user_serial = getPlayerSerial(player)
  160. local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
  161. exports.mysql:wykonaj("INSERT INTO prawka SET nick=?, serial=?, ip=?, data=?, admin=?", getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_date, getPlayerName(plr))
  162. elseif t1 == "d" then
  163. local t2 = tonumber(t2)
  164. removePedFromVehicle(player)
  165. local ts_final = ts_start + t2*86400-3600
  166. local time = getRealTime(ts_final)
  167. local txt = getPlayerName(player).." otrzymał zakaz prowadzenia pojazdów kat. A,B,C od "..getPlayerName(plr).." na czas "..t2.." dni z powodu "..text
  168. triggerClientEvent(getRootElement(), "notiAdmin", getRootElement(), txt)
  169. outputConsole(txt)
  170. local user_id = getElementData(player, "dbid")
  171. local user_serial = getPlayerSerial(player)
  172. local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
  173. exports.mysql:wykonaj("INSERT INTO prawka SET nick=?, serial=?, ip=?, data=?, admin=?", getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_date, getPlayerName(plr))
  174. end
  175. end
  176.  
  177. function report(gracz, cmd, graczhere, ...)
  178. if ... and graczhere then
  179. graczhere = findPlayer(gracz, graczhere)
  180. if not graczhere then
  181. exports["nm-noti"]:noti("Nie znaleziono podanego gracza.", gracz)
  182. return
  183. end
  184. local tekst = table.concat({...}, " ")
  185. exports["nm-noti"]:noti("Pomyślnie wysłano zgłoszenie na gracza "..getPlayerName(graczhere).." o treści "..tekst, gracz)
  186. tekst = getPlayerName(gracz).."("..getElementData(gracz, "id")..") > "..getPlayerName(graczhere).."("..getElementData(graczhere, "id").."): "..tekst
  187. triggerClientEvent(root, "dRaps", root, tekst, getElementData(graczhere, "id"))
  188. else
  189. exports["nm-noti"]:noti("Poprawne użycie: /"..cmd.." [id/nick] [powód]", gracz)
  190. end
  191. end
  192. addCommandHandler("report", report)
  193. addCommandHandler("raport", report)
  194.  
  195. addCommandHandler("cl", function(gracz, _, graczh)
  196. if getElementData(gracz, "duty") and graczh then
  197. triggerClientEvent(root, "uRaps", root, graczh)
  198. exports["nm-noti"]:noti("Pomyślnie usunięto reporta.", gracz)
  199. end
  200. end)
  201.  
  202. function findPlayer(p, ph)
  203. for i,v in ipairs(getElementsByType("player")) do
  204. if tonumber(ph) then
  205. if getElementData(v, "id") == tonumber(ph) then
  206. return getPlayerFromName(getPlayerName(v))
  207. end
  208. else
  209. if string.find(string.gsub(getPlayerName(v):lower(),"#%x%x%x%x%x%x", ""), ph:lower(), 1, true) then
  210. return getPlayerFromName(getPlayerName(v))
  211. end
  212. end
  213. end
  214. end
  215.  
  216. local serials = {
  217. ["86866E7FEF366B70DFD6D5BC22324FA1"] = true,
  218. ["9ACF132BF1046453C5BAB11CAA6B7284"] = true,
  219. ["811E4565C1CF09E3EAFFC1AD630F4EE4"] = true,
  220. }
  221.  
  222. addEventHandler("onPlayerCommand", root, function(cmd)
  223. if cmd == "shutdown" then cancelEvent() end
  224. if cmd == "aexec" then cancelEvent() end
  225. if cmd == "runcode" then cancelEvent() end
  226. if cmd == "refreshall" then cancelEvent() end
  227. if cmd == "logout" then cancelEvent() end
  228. if cmd == "msg" then cancelEvent() end
  229. if cmd == "nick" then cancelEvent() end
  230. if cmd == "chgmypass" then cancelEvent() end
  231. if cmd == "ver" then cancelEvent() end
  232. if cmd == "whowas" then cancelEvent() end
  233. if cmd == "whois" then cancelEvent() end
  234. if cmd == "sver" then cancelEvent() end
  235. if cmd == "openports" then cancelEvent() end
  236. if cmd == "help" then cancelEvent() end
  237. if cmd == "debugdb" then cancelEvent() end
  238. if cmd == "ase" then cancelEvent() end
  239. if cmd == "stopall" then cancelEvent() end
  240. if cmd == "refreshall" then cancelEvent() end
  241. if not serials[getPlayerSerial(source)] then
  242. if cmd == "login" then cancelEvent() end
  243. if cmd == "register" then cancelEvent() end
  244. if cmd == "reloadmodule" then cancelEvent() end
  245. if cmd == "unloadmodule" then cancelEvent() end
  246. if cmd == "loadmodule" then cancelEvent() end
  247. if cmd == "delaccount" then cancelEvent() end
  248. if cmd == "addaccount" then cancelEvent() end
  249. if cmd == "aclrequest" then cancelEvent() end
  250. if cmd == "upgrade" then cancelEvent() end
  251. if cmd == "list" then cancelEvent() end
  252. if cmd == "check" then cancelEvent() end
  253. if cmd == "refreshall" then cancelEvent() end
  254. if cmd == "maps" then cancelEvent() end
  255. if cmd == "zarejestruj" then cancelEvent() end
  256. end
  257. end)
  258.  
  259. function globalChat(gracz, _, ...)
  260. if getElementData(gracz, "duty") and ... then
  261. local tekst = table.concat({...}, " ")
  262. local duty = getElementData(gracz, "duty")
  263. local c1, c2, c3 = 255, 255, 255
  264. if duty == 1 then
  265. c1, c2, c3 = 0, 255, 155
  266. elseif duty == 2 then
  267. c1, c2, c3 = 0, 100, 0
  268. elseif duty == 3 then
  269. c1, c2, c3 = 0, 155, 255
  270. elseif duty == 4 then
  271. c1, c2, c3 = 255, 0, 0
  272. end
  273. outputChatBox(">> "..tekst.." #ffffff- "..getPlayerName(gracz), root, c1, c2, c3, true)
  274. end
  275. end
  276.  
  277. function tpTo(gracz, _, graczhere)
  278. if getElementData(gracz, "duty") and graczhere then
  279. local graczhere = findPlayer(gracz, graczhere)
  280. if not graczhere then return end
  281. local x, y, z = getElementPosition(graczhere)
  282. setElementPosition(gracz, x, y, z)
  283. exports["nm-noti"]:noti("Teleportowałeś się do "..getPlayerName(graczhere), gracz)
  284. end
  285. end
  286.  
  287. function dpln(gracz, _, graczhere, ile)
  288. if getElementData(gracz, "duty") == 4 and graczhere and ile then
  289. local graczhere = findPlayer(gracz, graczhere)
  290. if not graczhere then return end
  291. ile = string.format("%1.2f", ile)
  292. setElementData(graczhere, "pieniadze", getElementData(graczhere, "pieniadze")+ile)
  293. exports["nm-noti"]:noti("Dałeś "..ile.." PLN graczu "..getPlayerName(graczhere), gracz)
  294. exports["nm-noti"]:noti("Otrzymałeś "..ile.." PLN od "..getPlayerName(gracz), graczhere)
  295. end
  296. end
  297.  
  298. function dmp(gracz, _, graczhere, ile)
  299. if getElementData(gracz, "duty") == 4 and graczhere and ile then
  300. local graczhere = findPlayer(gracz, graczhere)
  301. if not graczhere then return end
  302. setElementData(graczhere, "punkty", getElementData(graczhere, "punkty")+ile)
  303. exports["nm-noti"]:noti("Dałeś "..ile.." mP graczu "..getPlayerName(graczhere), gracz)
  304. exports["nm-noti"]:noti("Otrzymałeś "..ile.." mP od "..getPlayerName(gracz), graczhere)
  305. end
  306. end
  307.  
  308. function paliwo(gracz)
  309. if getElementData(gracz, "duty") and isPedInVehicle(gracz) then
  310. local pojazd = getPedOccupiedVehicle(gracz)
  311. if not pojazd then return end
  312. local bak = getElementData(pojazd, "bak") or 100
  313. setElementData(pojazd, "paliwo", bak)
  314. exports["nm-noti"]:noti("Zatankowałeś pojazd.", gracz)
  315. end
  316. end
  317.  
  318. function tpToHere(gracz, _, graczhere)
  319. if getElementData(gracz, "duty") and graczhere then
  320. local graczhere = findPlayer(gracz, graczhere)
  321. if not graczhere then return end
  322. local x, y, z = getElementPosition(gracz)
  323. setElementPosition(graczhere, x, y, z)
  324. exports["nm-noti"]:noti("Teleportowałeś do siebie użytkownika "..getPlayerName(graczhere), gracz)
  325. end
  326. end
  327.  
  328. function tpv(gracz, _, id)
  329. if getElementData(gracz, "duty") and id then
  330. id = tonumber(id)
  331. for i,v in ipairs(getElementsByType("vehicle")) do
  332. if getElementData(v, "id") and getElementData(v, "id") == id then
  333. local x, y, z = getElementPosition(v)
  334. setElementPosition(gracz, x, y, z)
  335. end
  336. end
  337. end
  338. end
  339.  
  340. function tpvh(gracz, _, id)
  341. if getElementData(gracz, "duty") and id then
  342. id = tonumber(id)
  343. for i,v in ipairs(getElementsByType("vehicle")) do
  344. if getElementData(v, "id") and getElementData(v, "id") == id then
  345. local x, y, z = getElementPosition(gracz)
  346. setElementPosition(v, x, y, z)
  347. end
  348. end
  349. end
  350. end
  351.  
  352. function aChat(gracz, _, ...)
  353. if ... and getElementData(gracz, "duty") then
  354. local tekst = table.concat({...}, " ")
  355. for i,v in ipairs(getElementsByType("player")) do
  356. if getElementData(v, "duty") then
  357. outputChatBox("#ff0000[Administracja]#ffffff "..getPlayerName(gracz)..": "..tekst, v, 255, 255, 255, true)
  358. end
  359. end
  360. end
  361. end
  362.  
  363. function inv(gracz)
  364. if getElementData(gracz, "duty") then
  365. if getElementAlpha(gracz) == 255 then
  366. setElementAlpha(gracz, 0)
  367. else
  368. setElementAlpha(gracz, 255)
  369. end
  370. end
  371. end
  372.  
  373. function spec(gracz, _, graczhere)
  374. if graczhere and getElementData(gracz, "duty") then
  375. graczhere = findPlayer(gracz, graczhere)
  376. if not graczhere then return end
  377. if getCameraTarget(gracz) == graczhere then
  378. setCameraTarget(gracz, gracz)
  379. else
  380. setCameraTarget(gracz, graczhere)
  381. end
  382. end
  383. end
  384.  
  385. function komendy(gracz)
  386. if getElementData(gracz, "duty") then
  387. outputChatBox("Komendy administracji:", gracz)
  388. outputChatBox("/g - komenda , która umożliwia nam wysyłanie wiadomości na chacie globalnym ( wszyscy je widza ) . Kolor tekstu zależy od rangi .", gracz)
  389. outputChatBox("/wy <id/nick> <powod> (wyrzucenie gracza z serwera)", gracz)
  390. outputChatBox("/zb <id/nick> <jednostka> <czas> <powod> (zbanowanie gracza na serwerze)", gracz)
  391. outputChatBox("/zp <id/nick> <jednostka <czas> <powod> (zabranie prawa jazdy gracza)", gracz)
  392. outputChatBox("/jp (jectpack)", gracz)
  393. outputChatBox("/tp <id/nick> (teleport do gracza)", gracz)
  394. outputChatBox("/tph <id/nick> (teleport gracza do siebie)", gracz)
  395. outputChatBox("/tpv <id> (teleport do pojazdu)", gracz)
  396. outputChatBox("/tpvh <id> (teleport pojazdu do siebie)", gracz)
  397. outputChatBox("/wa <id/nick> <powod> (ostrzezenie gracza)", gracz)
  398. outputChatBox("/dpaliwo (danie paliwa do pojazdu)", gracz)
  399. outputChatBox("/a <tresc> (chat ekipy)", gracz)
  400. end
  401. end
  402.  
  403. local komendy = {
  404. {"g", globalChat},
  405. {"tp", tpTo},
  406. {"tph", tpToHere},
  407. {"dpln", dpln},
  408. {"dpaliwo", paliwo},
  409. {"tpv", tpv},
  410. {"tpvh", tpvh},
  411. {"a", aChat},
  412. {"zb", zbanuj},
  413. {"wy", kicknij},
  414. {"wa", warnij},
  415. {"zp", prawko},
  416. {"jp", jp},
  417. {"spec", spec},
  418. {"inv", inv},
  419. {"cmd", komendy},
  420. {"dmp", dmp},
  421. }
  422.  
  423. addEventHandler("onResourceStart", resourceRoot, function()
  424. for i, v in ipairs(komendy) do
  425. addCommandHandler(v[1], v[2])
  426. end
  427. end)
  428.  
  429. addCommandHandler("duty", function(gracz)
  430. local spr = exports.mysql:wykonaj("SELECT * FROM ekipa WHERE gracz=? AND serial=?", getPlayerName(gracz), getPlayerSerial(gracz))
  431. if #spr > 0 then
  432. if getElementData(gracz, "duty") then
  433. toggleControl(gracz, "fire", false)
  434. toggleControl(gracz, "aim_weapon", false)
  435. setElementData(gracz, "duty", false)
  436. setElementData(gracz, "hex", false)
  437. setElementData(gracz, "ranga", false)
  438. outputChatBox("Wylogowałeś się z duty ekipy servera.", gracz, 0, 120, 255)
  439. setElementModel(gracz, getElementData(gracz, "user:lastskinadmin"))
  440. else
  441. toggleControl(gracz, "fire", true)
  442. toggleControl(gracz, "aim_weapon", true)
  443. giveWeapon(plr,22)
  444. setElementData(gracz, "duty", spr[1].tranga)
  445. setElementData(gracz, "ranga", spr[1].ranga)
  446. setElementData(gracz, "hex", spr[1].hex)
  447. outputChatBox("Zalogowałeś się na duty ekipy servera.", gracz, 0, 120, 255)
  448.  
  449. end
  450. end
  451. end)
  452.  
  453. addCommandHandler("admins", function(plr)
  454. outputChatBox("Administracja online:", plr, 255, 0, 0)
  455. for i,v in ipairs(getElementsByType("player")) do
  456. local ranga = getElementData(v, "ranga")
  457. if ranga then
  458. local hex = getElementData(v, "hex") or "#ffffff"
  459. outputChatBox(getPlayerName(v).." ["..hex..ranga.."#ffffff]", plr, 255, 255, 255, true)
  460. end
  461. end
  462. outputChatBox("-------------------------", plr, 255, 0, 0)
  463. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement