Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2021-01-14, 13:28


__MlodyLisek__







Wiek: 25
Na forum: 2030 dni
Posty: 3
Nick w MP: Glowaa_



Respekt: 50

ss z debuga: https://imgur.com/a/iSEkknk
nie wy?wietla si? jak klikam taba ;(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-14, 13:47


DaVeCS

Mapper






Wiek: 31
Na forum: 3386 dni
Posty: 193
Nick w MP: DaVe

Piwa: 59

Respekt: 70,5

Poka? kod tego scoreboard'u

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-14, 14:02


__MlodyLisek__







Wiek: 25
Na forum: 2030 dni
Posty: 3
Nick w MP: Glowaa_



Respekt: 50

Kod:

--[[
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"}

local maxplayers = 0

addEvent('getmaxplayers', true)
addEventHandler('getmaxplayers', resourceRoot, function(max_players)
maxplayers = max_players
end)

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["pystories-tab-dx"]
local editbox = exports["pystories-tab-editbox"]
local scroll = exports["pystories-tab-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.icons = {
[1] = {self.img[4], "Wszyscy"},
[2] = {self.img[5], "Premium"},
[3] = {self.img[6], "Ekipa"},
}

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"] = {}
--[[self["players"][1] = {
id=(getElementData(localPlayer, "id") or 0),
name=(getElementData(localPlayer, "player:sid") and getPlayerName(localPlayer) or "Niezalogowany"),
organization=(getElementData(localPlayer, "player:organization") or "brak"),
faction=(getElementData(localPlayer, "player:faction") or "brak"),
ping=getPlayerPing(localPlayer),
hex=self:GetPlayerHEX(localPlayer),
rp=getElementData(localPlayer, "player:srp"),
}--]]
for i,v in pairs(getElementsByType("player")) do
--if v ~= localPlayer then
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:faction") or "brak"),
ping=getPlayerPing(v),
hex=self:GetPlayerHEX(v),
rp=getElementData(v, "player:srp"),
})
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:faction") or "brak"),
ping=getPlayerPing(v),
hex=self:GetPlayerHEX(v),
rp=getElementData(v, "player:srp"),

})
end;
end;
--end;
end;
table.sort(self["players"], function(a, b)
return a.id < b.id
end)
--[[table.insert(self["players"], {
id=(getElementData(localPlayer, "id") or 0),
name=(getElementData(localPlayer, "player:sid") and getPlayerName(localPlayer) or "Niezalogowany"),
organization=(getElementData(localPlayer, "player:organization") or "brak"),
faction=(getElementData(localPlayer, "player:faction") or "brak"),
ping=getPlayerPing(localPlayer),
hex=self:GetPlayerHEX(localPlayer),
rp=getElementData(localPlayer, "player:srp"),
}, 1)--]]
end;

local sw,sh = guiGetScreenSize()
local scale = 1920 / sw
function scoreboard:Render()
--self["edit_text"] = editbox:dxGetEditText("SCOREBOARD-SEARCH") or "";
self["index"] = 0;



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-770/2/zoom, 200/zoom, 60/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("#ffe000"..#getElementsByType("player").."/"..maxplayers.." #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("REPUTACJA", sw/2-210/zoom, sh/2-311/zoom, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false);
dxDrawText("ORGANIZACJA", sw/2+200/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);
dxDrawText("Taks?wkarzy:", 955/scale, 165/scale, 940/scale, 178/scale, tocolor(200, 200, 200, alpha), 1.00, f1, "right", "top", false, false, false, true, false)
dxDrawText("#003bedSAPD: #FFFFFF" ..sapd, 608/scale, 970/scale, 785/scale, 940/scale, tocolor(255, 255, 255, alpha), 1.00, f3, "center", "center", false, false, false, true, false)
dxDrawText("#ed1800SAFD: #FFFFFF" ..safd, 996.5/scale, 970/scale, 785/scale, 940/scale, tocolor(255, 255, 255, alpha), 1.00, f3, "center", "center", false, false, false, true, false)
dxDrawText("#00f2ffSAMC: #FFFFFF" ..samc, 1385/scale, 970/scale, 785/scale, 940/scale, tocolor(255, 255, 255, alpha), 1.00, f3, "center", "center", false, false, false, true, false)
dxDrawText("#f77f00SARA: #FFFFFF" ..sara, 1773.5/scale, 970/scale, 785/scale, 940/scale, tocolor(255, 255, 255, alpha), 1.00, f3, "center", "center", false, false, false, true, false)
dxDrawText("#FFFF00TSA: #FFFFFF" ..tsa1, 608/scale, 1020/scale, 785/scale, 940/scale, tocolor(255, 255, 255, alpha), 1.00, f3, "center", "center", false, false, false, true, false)
dxDrawText("Administrator?w:", 955/scale, 165/scale, 1132/scale, 178/scale, tocolor(200, 200, 200, alpha), 1.00, f1, "right", "top", false, false, false, true, false)
dxDrawText("#ffe000"..admins.." #ced1d0ONLINE", 1020/scale, 180/scale, 1132/scale, 200/scale, tocolor(255, 255, 255, alpha), 1.00, f2, "right", "top", false, false, false, true, false)
dxDrawText("#ffe000"..tsa.." #ced1d0ONLINE", 1020/scale, 180/scale, 940/scale, 200/scale, tocolor(255, 255, 255, alpha), 1.00, f2, "right", "top", false, false, false, true, 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;
andrzej = v.rp or "0"
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(andrzej, sw/2-210/zoom, sh/2-311/zoom+sY, sw/2, sh, tocolor(206, 209, 208, alpha), 1, f3, "center", "top", false);
dxDrawText(v.organization, sw/2+200/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);
--editbox:dxSetEditAlpha("SCOREBOARD-SEARCH", 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
if getElementData(localPlayer, "stolen_money") then return end
animate(alpha, 0, 1, 100, function(a)
alpha = a;

if(a == 0)then
removeEventHandler("onClientRender", root, self["render_fnc"])

--editbox:dxDestroyEdit("SCOREBOARD-SEARCH")
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"])

--editbox:dxDestroyEdit("SCOREBOARD-SEARCH")
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()
sapd, safd, samc, tsa, sara, admins, tsa1 = 0, 0, 0, 0, 0, 0, 0
for i, v in ipairs(getElementsByType("player")) do
if getElementData(v, "player:duty") == "SAPD" then
sapd = sapd+1
end
if getElementData(v, "player:duty") == "SARA" then
sara = sara+1
end
if getElementData(v, "player:duty") == "SAFD" then
safd = safd+1
end
if getElementData(v, "player:duty") == "SAMC" then
samc = samc+1
end
if getElementData(v, "player:duty") == "TSA" then
tsa1 = tsa1+1
end
if getPedOccupiedVehicle(v) and getElementData(getPedOccupiedVehicle(v), "vehicle:taxo") == 1 then
tsa = tsa+1
end
if getElementData(v, "player:admin") then
admins = admins+1
end
end
addEventHandler("onClientRender", root, self["render_fnc"])

--editbox:dxCreateEdit("SCOREBOARD-SEARCH", "", "Aby wyszuka? wpisz nick/id", sw/2-250/2/zoom, sh/2-740/2/zoom, 180/zoom, 34/zoom, false, 0, 255, false, true);
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()
--editbox:dxDestroyEdit("SCOREBOARD-SEARCH")
scroll:dxDestroyScroll("SCOREBOARD-SCROLL");
end)

triggerServerEvent('s-getmaxplayers', resourceRoot)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-14, 16:09


_jvneczek







Wiek: 22
Na forum: 4326 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Wska? 236 linijke.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-14, 16:27


__MlodyLisek__







Wiek: 25
Na forum: 2030 dni
Posty: 3
Nick w MP: Glowaa_



Respekt: 50

Kod:

self.min_row = math.floor(scroll:dxScrollGetPosition("SCOREBOARD-SCROLL") + 1);


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-14, 23:58


Mikołajj







Wiek: 22
Na forum: 2885 dni
Posty: 303
Nick w MP: Mikołaj

Piwa: 132

Respekt: 91

Wydaje mi si?, ?e skrypt 'scroll' nie jest w??czony lub funkcja dxScrollGetPosition zwraca nieprawid?ow? warto?? == nil.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-15, 16:01


_jvneczek







Wiek: 22
Na forum: 4326 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Widzia?em ju? ten scoreboard kilka razy i najprawdopodobniej brakuje pliku pystories-tab-scroll

Postaw piwo autorowi tego posta
 

 
Tagi: scoreboard :: nie :: działa
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku