--[[ autor: Kacper (Asper) Ch. (©) kontakt: nezymr69@gmail.com dla: Advice | 2018 (MTA: SA) licencja: Art. 67 - 1. Twórca może udzielić upoważnienia do korzystania z utworu na wymienionych w umowie polach eksploatacji z określeniem zakresu, miejsca i czasu tego korzystania. - 2. Jeżeli umowa nie zastrzega wyłączności korzystania z utworu w określony sposób (licencja wyłączna), udzielenie licencji nie ogranicza udzielenia przez twórcę upoważnienia innym osobom do korzystania z utworu na tym samym polu eksploatacji (licencja niewyłączna). - 3. Jeżeli umowa nie stanowi inaczej, licencjobiorca nie może upoważnić innej osoby do korzystania z utworu w zakresie uzyskanej licencji. - 4. Jeżeli umowa nie stanowi inaczej, uprawniony z licencji wyłącznej może dochodzić roszczeń z tytułu naruszenia autorskich praw majątkowych, w zakresie objętym umową licencyjną. - 5. Umowa licencyjna wyłączna wymaga zachowania formy pisemnej pod rygorem nieważności. ]] local anims, builtins = {}, {"Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce", "SineCurve", "CosineCurve"} function table.find(t, v) for k, a in ipairs(t) do if a == v then return k end end return false end function animate(f, t, easing, duration, onChange, onEnd) assert(type(f) == "number", "Bad argument @ 'animate' [expected number at argument 1, got "..type(f).."]") assert(type(t) == "number", "Bad argument @ 'animate' [expected number at argument 2, got "..type(t).."]") assert(type(easing) == "string" or (type(easing) == "number" and (easing >= 1 or easing <= #builtins)), "Bad argument @ 'animate' [Invalid easing at argument 3]") assert(type(duration) == "number", "Bad argument @ 'animate' [expected function at argument 4, got "..type(duration).."]") assert(type(onChange) == "function", "Bad argument @ 'animate' [expected function at argument 5, got "..type(onChange).."]") table.insert(anims, {from = f, to = t, easing = table.find(builtins, easing) and easing or builtins[easing], duration = duration, start = getTickCount( ), onChange = onChange, onEnd = onEnd}) return #anims end function destroyAnimation(a) if anims[a] then table.remove(anims, a) end end addEventHandler("onClientRender", root, function( ) local now = getTickCount( ) for k,v in ipairs(anims) do v.onChange(interpolateBetween(v.from, 0, 0, v.to, 0, 0, (now - v.start) / v.duration, v.easing)) if now >= v.start+v.duration then if type(v.onEnd) == "function" then v.onEnd( ) end table.remove(anims, k) end end end) -- animation function :D local dx = exports.im_dx; local scroll = exports.im_scroll; local f1 = dx:getFont("rbt-r", 2); local f2 = dx:getFont("rbt-r", 5); local f3 = dx:getFont("rbt-r", 2); local f4 = dx:getFont("rbt-l", 10); local f5 = dx:getFont("rbt-r", -1); local sw,sh = guiGetScreenSize() local baseX = 1920 local zoom = 1 local minzoom = 2 if sw < baseX then zoom = math.min(minzoom, baseX/sw) end local scoreboard = {} function isMouseIn(x, y, w, h) if not isCursorShowing() then return end local pos = {getCursorPosition()} pos[1],pos[2] = (pos[1]*sw),(pos[2]*sh) if pos[1] >= x and pos[1] <= (x+w) and pos[2] >= y and pos[2] <= (y+h) then return true end return false end function isEventHandlerAdded(eventName, rootName, fnc) if type(eventName) == "string" and isElement(rootName) and type(fnc) == "function" then local eventHandlers = getEventHandlers(eventName, rootName) if type(eventHandlers) == "table" and #eventHandlers > 0 then for i,v in pairs(eventHandlers) do if v == fnc then return true end end end end return false end local alpha = 0; function scoreboard:Construction() self.textures = { "i/scoreboard.png", "i/edit.png", "i/logo2.png", "i/icons/all.png", "i/icons/premium.png", "i/icons/admins.png", }; self.img = {}; for i,v in pairs(self.textures) do self.img[i] = dxCreateTexture(v, "argb", false, "clamp"); end; self.min_row = 1 self.players = {} self.index = 0 self.update_player_data = 2500 self.update_tick = getTickCount() self.page = 1; self.mouse_showed = false self.edit_text = "" self.render_fnc = function() self:Render() end self.scroll_fnc = function(key, state) self:Scroll(key, state) end self.toggle_fnc = function(key, state) self:Toggle(key, state) end self.mouse_fnc = function(key, state) self:Mouse(key, state) end self.load_players_fnc = function() self:LoadPlayers() end self.click = function(...) self:Click(...) end bindKey("tab", "both", self.toggle_fnc) addEventHandler("onPlayerJoin", root, self.load_players_fnc) addEventHandler("onPlayerQuit", root, self.load_players_fnc) addEventHandler("onClientClick", root, self.click) end function scoreboard:GetPlayerHEX(v) if getElementData(v, "user:premium") then return "#ffff00" else return "#c8c8c8" end end function scoreboard:LoadPlayers() self["players"] = {} for i,v in pairs(getElementsByType("player")) do if((self.page == 2 and getElementData(v, "player:premium")) or self.page == 1)then if string.len(self["edit_text"]) > 0 then if(string.find(string.gsub(getPlayerName(v):lower(),"#%x%x%x%x%x%x", ""), self["edit_text"]:lower(), 1, true) or string.find(getElementData(v, "user:id"), self["edit_text"], 1, true))then table.insert(self["players"], { id=(getElementData(v, "id") or 0), name=(getElementData(v, "player:sid") and getPlayerName(v) or "Niezalogowany"), organization=(getElementData(v, "player:organization") or "brak"), faction=(getElementData(v, "player:duty") or "brak"), ping=getPlayerPing(v), hex=self:GetPlayerHEX(v), rp=(getElementData(v, "player:srp") or "0"), }) end else table.insert(self["players"], { id=(getElementData(v, "id") or 0), name=(getElementData(v, "player:sid") and getPlayerName(v) or "Niezalogowany"), organization=(getElementData(v, "player:organization") or "brak"), faction=(getElementData(v, "player:duty") or "brak"), ping=getPlayerPing(v), hex=self:GetPlayerHEX(v), rp=(getElementData(v, "player:srp") or "0"), }) end; end; end; end; function scoreboard:Render() self["index"] = 0; if #self.edit_text > 0 or selected or (getTickCount() - self["update_tick"]) > self["update_player_data"] then self["update_tick"] = getTickCount() self:LoadPlayers() end self.min_row = math.floor(scroll:dxScrollGetPosition("SCOREBOARD-SCROLL") + 1); dxDrawImage(sw/2-721/2/zoom, sh/2-787/2/zoom, 721/zoom, 787/zoom, self.img[1], 0, 0, 0, tocolor(255, 255, 255, alpha), false); dxDrawImage(sw/2-700/2/zoom, sh/2-820/2/zoom, 123/zoom, 123/zoom, self.img[3], 0, 0, 0, tocolor(255, 255, 255, alpha), false); dxDrawText("Obecnie na serwerze:", 0, sh/2-375/zoom, sw/2+340/zoom, 0, tocolor(200, 200, 200, alpha), 1, f1, "right", "top", false); dxDrawText("#00cf9b"..#getElementsByType("player").."#ced1d0 ONLINE", 0, sh/2-360/zoom, sw/2+340/zoom, 0, tocolor(255, 255, 255, alpha), 1, f2, "right", "top", false, false, false, true); dxDrawText("Naciśnij PPM by pokazać kursor", 0, sh/2+367/zoom, sw, sh, tocolor(206, 209, 208, alpha), 1, f1, "center", "top", false); dxDrawText("ID", sw/2-655/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText("NICK", sw/2-480/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText("RP", sw/2-210/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText("SŁUŻBA", sw/2+350/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText("ORGANIZACJA", sw/2+50/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText("PING", sw/2+590/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); local sapdy = getElementsByType('players'); for i,v in pairs(sapdy) do print(getElementData(v, 'player:faction')); end; for i,v in pairs(self["players"]) do if(self["min_row"]+20 >= i and self["min_row"] <= i)then self["index"] = self["index"]+1; local sY = (30/zoom)*self["index"]+5; dxDrawText(v.id, sw/2-655/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText(v.hex..v.name, sw/2-480/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false, false, false, true); dxDrawText(v.rp, sw/2-210/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText(v.faction, sw/2+350/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText(v.organization, sw/2+50/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); dxDrawText(v.ping, sw/2+590/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false); end end scroll:dxScrollSetAlpha("SCOREBOARD-SCROLL", alpha); end function scoreboard:Click(key, state) if(key == "left" and state == "down")then if(isMouseIn(sw/2+115/zoom, sh/2-721/2/zoom, 17/zoom, 17/zoom))then if(self.page == 1)then self.page = 2; else self.page = 1; end; self["update_tick"] = getTickCount() self:LoadPlayers() end; end; end; function scoreboard:Toggle(key, state) if key == "tab" then if state == "up" and isEventHandlerAdded("onClientRender", root, self["render_fnc"]) then if self["mouse_showed"] == true then return end local sapdy = getElementsByType('players'); for i,v in pairs(sapdy) do if #sapdy == 0 then print("brak") return end print(getElementData(v, 'player:faction')); end; animate(alpha, 0, 1, 100, function(a) alpha = a; if(a == 0)then removeEventHandler("onClientRender", root, self["render_fnc"]) showCursor(false) self["mouse_showed"] = false unbindKey("mouse2", "down", self["mouse_fnc"]) scroll:dxDestroyScroll("SCOREBOARD-SCROLL"); end; end); elseif state == "down" then if self["mouse_showed"] == true and isEventHandlerAdded("onClientRender", root, self["render_fnc"]) then animate(alpha, 0, 1, 100, function(a) alpha = a; if(a == 0)then removeEventHandler("onClientRender", root, self["render_fnc"]) showCursor(false) self["mouse_showed"] = false unbindKey("mouse2", "down", self["mouse_fnc"]) scroll:dxDestroyScroll("SCOREBOARD-SCROLL"); end; end); end; if isEventHandlerAdded("onClientRender", root, self["render_fnc"]) then return end self:LoadPlayers() self["update_tick"] = getTickCount() addEventHandler("onClientRender", root, self["render_fnc"]) scroll:dxCreateScroll("SCOREBOARD-SCROLL", sw/2+342/zoom, sh/2-280/zoom, 6/zoom, 60/zoom, 0, 21, self.players, 635/zoom); self["mouse_showed"] = false bindKey("mouse2", "down", self["mouse_fnc"]) animate(alpha, 255, 1, 100, function(a) alpha = a; end); end end end function scoreboard:Mouse(key, state) if key == "mouse2" then showCursor(not self["mouse_showed"], false) self["mouse_showed"] = not self["mouse_showed"] end end addEventHandler("onClientResourceStart", resourceRoot, function() scoreboard:Construction() end) addEventHandler("onClientResourceStop", resourceRoot, function() scroll:dxDestroyScroll("SCOREBOARD-SCROLL"); end)