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

Wysłany: 2023-06-20, 22:00


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Siemano, pom?g?by kto? z sortowaniem po id (oto m?j scoreboard), mam problem z funkcj? table.sort.
kod

Class = {}


Class.Scroll = {

    1,
    5,
    5,

}

function gui()

local screenWscreenH guiGetScreenSize()


        dxDrawImage(screenW 0.2625screenH 0.1398screenW 0.4755screenH 0.3009texture.background000tocolor(255255255255), false)
        dxDrawText("Hej, Pyrek"screenW 0.2625screenH 0.1491screenW 0.4135screenH 0.1898tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont25'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("100/100"screenW 0.6828screenH 0.1398screenW 0.7380screenH 0.1806tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont25'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Online:"screenW 0.6427screenH 0.1398screenW 0.6828screenH 0.1806tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont25'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("MoveRPG"screenW 0.4625screenH 0.1343screenW 0.5380screenH 0.2046tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont35'), "center""center"falsefalsefalsefalsefalse)
        dxDrawImage(screenW 0.2625screenH 0.1898screenW 0.1510screenH 0.0056texture.line2000tocolor(255255255255), false)
        dxDrawImage(screenW 0.4135screenH 0.1898screenW 0.3245screenH 0.0056texture.line2000tocolor(255255255255), false)
       
        dxDrawText("ID"screenW 0.2646screenH 0.1954screenW 0.2823screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Nick"screenW 0.2823screenH 0.1954screenW 0.4203screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Organizacja"screenW 0.4203screenH 0.1954screenW 0.5583screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Sluzba"screenW 0.5583screenH 0.1954screenW 0.6146screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("MP"screenW 0.6146screenH 0.1954screenW 0.6859screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Ping"screenW 0.6859screenH 0.1954screenW 0.7380screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
       
        
0

for i,p in ipairs(getElementsByType('player')) do

local id getElementData(p"id")
local name getPlayerName(p) or 0





            if >= Class.Scroll[1] and <= Class.Scroll[2then
            x 1
            local offsetY = (math.floor(80)*(x-1))



        dxDrawText(idscreenW 0.2646screenH 0.2306screenW 0.2823screenH 0.2657+offsetYtocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText(namescreenW 0.2823screenH 0.2306screenW 0.4203screenH 0.2657+offsetYtocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsetruefalse)
        dxDrawText("org"screenW 0.4203screenH 0.2306screenW 0.5583screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("SAPDS"screenW 0.5583screenH 0.2306screenW 0.6146screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("100000"screenW 0.6146screenH 0.2306screenW 0.6859screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("100000 m/s"screenW 0.6859screenH 0.2306screenW 0.7380screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)






end
end
end
addEventHandler("onClientRender"rootgui)

bindKey("mouse_wheel_down""both", function()
   if Class.Scroll[2] == Class.Scroll[3then return end
    Class.Scroll[1] = Class.Scroll[1]-1
    Class.Scroll[2] = Class.Scroll[2]-1



end)

bindKey("mouse_wheel_up""both", function()
    if Class.Scroll[2] >= #getElementsByType("player") then return end
    Class.Scroll[1] = Class.Scroll[1]+1
    Class.Scroll[2] = Class.Scroll[2]+1

end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-06-21, 15:11


Norbert1234

Nie umiem w LUA






Wiek: 22
Na forum: 3988 dni
Posty: 319
Nick w MP: Gusterowskyy

Piwa: 242

Respekt: 60

Kod:


function sort(op1, op2)
if isElement(op1) and isElement(op2) then
return (getElementData(op1, "user:tempid") or 0) < (getElementData(op2, "user:tempid") or 0)
end
end

Zmie? element daty pod swoje. ("user:tempid")
po?niej np.

table.sort(localPlayer, sort) -- musisz doda? w odpowiednim miejscu.

To jest pogl?dowe. Dla inspiracji. Nawet nie wiem czy dobrze rozpisa?em. Daj zna? jakby? mia? pytania.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-06-23, 17:50


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Kod troche zmodyfikowa?em ale daje nie sortuje, nie mam poj?cia.

Class = {}

local screenWscreenH guiGetScreenSize()

texture = {
background dxCreateTexture(':amta_gui/img/background2.png'),
line2 dxCreateTexture(':amta_gui/img/line2.png')
}


Class.Scroll = {

    1,
    5,
    5,

}





function sort(op1op2)
if isElement(op1) and isElement(op2then
return (getElementData(op1"id") or 0) < (getElementData(op2"id") or 0)
end
end    
    
    

scroll 0
on 0
function gui()
if on == 1 then







local screenWscreenH guiGetScreenSize()


        dxDrawImage(screenW 0.2625screenH 0.1398screenW 0.4755screenH 0.3009texture.background000tocolor(255255255255), false)
        dxDrawText("Hej, Pyrek"screenW 0.2625screenH 0.1491screenW 0.4135screenH 0.1898tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont25'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("100/100"screenW 0.6828screenH 0.1398screenW 0.7380screenH 0.1806tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont25'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Online:"screenW 0.6427screenH 0.1398screenW 0.6828screenH 0.1806tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont25'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("MoveRPG"screenW 0.4625screenH 0.1343screenW 0.5380screenH 0.2046tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont35'), "center""center"falsefalsefalsefalsefalse)
        dxDrawImage(screenW 0.2625screenH 0.1898screenW 0.1510screenH 0.0056texture.line2000tocolor(255255255255), false)
        dxDrawImage(screenW 0.4135screenH 0.1898screenW 0.3245screenH 0.0056texture.line2000tocolor(255255255255), false)
       
        dxDrawText("ID"screenW 0.2646screenH 0.1954screenW 0.2823screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Nick"screenW 0.2823screenH 0.1954screenW 0.4203screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Organizacja"screenW 0.4203screenH 0.1954screenW 0.5583screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Sluzba"screenW 0.5583screenH 0.1954screenW 0.6146screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("MP"screenW 0.6146screenH 0.1954screenW 0.6859screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("Ping"screenW 0.6859screenH 0.1954screenW 0.7380screenH 0.2306tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
       
        
0

for i,p in ipairs(getElementsByType('player')) do

local id getElementData(p"id")
local name getPlayerName(p) or 0

local gracze getElementsByType("player")




            if >= Class.Scroll[1] and <= Class.Scroll[2then
            x 1
            local offsetY = (math.floor(80)*(x-1))



        dxDrawText(idscreenW 0.2646screenH 0.2306screenW 0.2823screenH 0.2657+offsetYtocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText(namescreenW 0.2823screenH 0.2306screenW 0.4203screenH 0.2657+offsetYtocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsetruefalse)
        dxDrawText("org"screenW 0.4203screenH 0.2306screenW 0.5583screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("SAPDS"screenW 0.5583screenH 0.2306screenW 0.6146screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("100000"screenW 0.6146screenH 0.2306screenW 0.6859screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)
        dxDrawText("100000 m/s"screenW 0.6859screenH 0.2306screenW 0.7380screenH 0.2657tocolor(255255255255), 1.00exports.amta_gui:pobierzFont('bfont20'), "center""center"falsefalsefalsefalsefalse)






end
end
end
end
addEventHandler("onClientRender"rootgui)

addCommandHandler("scr", function(plr)
if not on or on == 0 then
on 1
table.sort(localPlayersort)
else 
on 0 
end
end)

bindKey("mouse_wheel_down""both", function()
   if Class.Scroll[2] == Class.Scroll[3then return end
    Class.Scroll[1] = Class.Scroll[1]-1
    Class.Scroll[2] = Class.Scroll[2]-1



end)

bindKey("mouse_wheel_up""both", function()
    if Class.Scroll[2] >= #getElementsByType("player") then return end
    Class.Scroll[1] = Class.Scroll[1]+1
    Class.Scroll[2] = Class.Scroll[2]+1

end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: sortowanie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Sortowanie 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