Wysłany: 2023-06-20, 22:00
Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
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 screenW , screenH = guiGetScreenSize ()
dxDrawImage ( screenW * 0.2625 , screenH * 0.1398 , screenW * 0.4755 , screenH * 0.3009 , texture . background , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Hej, Pyrek" , screenW * 0.2625 , screenH * 0.1491 , screenW * 0.4135 , screenH * 0.1898 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont25' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "100/100" , screenW * 0.6828 , screenH * 0.1398 , screenW * 0.7380 , screenH * 0.1806 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont25' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Online:" , screenW * 0.6427 , screenH * 0.1398 , screenW * 0.6828 , screenH * 0.1806 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont25' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "MoveRPG" , screenW * 0.4625 , screenH * 0.1343 , screenW * 0.5380 , screenH * 0.2046 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont35' ), "center" , "center" , false , false , false , false , false )
dxDrawImage ( screenW * 0.2625 , screenH * 0.1898 , screenW * 0.1510 , screenH * 0.0056 , texture . line2 , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawImage ( screenW * 0.4135 , screenH * 0.1898 , screenW * 0.3245 , screenH * 0.0056 , texture . line2 , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "ID" , screenW * 0.2646 , screenH * 0.1954 , screenW * 0.2823 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Nick" , screenW * 0.2823 , screenH * 0.1954 , screenW * 0.4203 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Organizacja" , screenW * 0.4203 , screenH * 0.1954 , screenW * 0.5583 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Sluzba" , screenW * 0.5583 , screenH * 0.1954 , screenW * 0.6146 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "MP" , screenW * 0.6146 , screenH * 0.1954 , screenW * 0.6859 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Ping" , screenW * 0.6859 , screenH * 0.1954 , screenW * 0.7380 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
x = 0
for i , p in ipairs ( getElementsByType ( 'player' )) do
local id = getElementData ( p , "id" )
local name = getPlayerName ( p ) or 0
if i >= Class. Scroll [ 1 ] and i <= Class. Scroll [ 2 ] then
x = x + 1
local offsetY = ( math . floor ( 80 )*( x - 1 ))
dxDrawText ( id , screenW * 0.2646 , screenH * 0.2306 , screenW * 0.2823 , screenH * 0.2657 + offsetY , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( name , screenW * 0.2823 , screenH * 0.2306 , screenW * 0.4203 , screenH * 0.2657 + offsetY , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , true , false )
dxDrawText ( "org" , screenW * 0.4203 , screenH * 0.2306 , screenW * 0.5583 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "SAPDS" , screenW * 0.5583 , screenH * 0.2306 , screenW * 0.6146 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "100000" , screenW * 0.6146 , screenH * 0.2306 , screenW * 0.6859 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "100000 m/s" , screenW * 0.6859 , screenH * 0.2306 , screenW * 0.7380 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
end
end
end
addEventHandler ( "onClientRender" , root , gui )
bindKey ( "mouse_wheel_down" , "both" , function()
if Class. Scroll [ 2 ] == Class. Scroll [ 3 ] then 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 )
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: 3987 dni Posty: 319
Nick w MP: Gusterowskyy
Piwa : 242
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.
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
Kod troche zmodyfikowa?em ale daje nie sortuje, nie mam poj?cia.
Class = {}
local screenW , screenH = guiGetScreenSize ()
texture = {
background = dxCreateTexture ( ':amta_gui/img/background2.png' ),
line2 = dxCreateTexture ( ':amta_gui/img/line2.png' )
}
Class. Scroll = {
1 ,
5 ,
5 ,
}
function sort ( op1 , op2 )
if isElement ( op1 ) and isElement ( op2 ) then
return ( getElementData ( op1 , "id" ) or 0 ) < ( getElementData ( op2 , "id" ) or 0 )
end
end
scroll = 0
on = 0
function gui ()
if on == 1 then
local screenW , screenH = guiGetScreenSize ()
dxDrawImage ( screenW * 0.2625 , screenH * 0.1398 , screenW * 0.4755 , screenH * 0.3009 , texture . background , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Hej, Pyrek" , screenW * 0.2625 , screenH * 0.1491 , screenW * 0.4135 , screenH * 0.1898 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont25' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "100/100" , screenW * 0.6828 , screenH * 0.1398 , screenW * 0.7380 , screenH * 0.1806 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont25' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Online:" , screenW * 0.6427 , screenH * 0.1398 , screenW * 0.6828 , screenH * 0.1806 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont25' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "MoveRPG" , screenW * 0.4625 , screenH * 0.1343 , screenW * 0.5380 , screenH * 0.2046 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont35' ), "center" , "center" , false , false , false , false , false )
dxDrawImage ( screenW * 0.2625 , screenH * 0.1898 , screenW * 0.1510 , screenH * 0.0056 , texture . line2 , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawImage ( screenW * 0.4135 , screenH * 0.1898 , screenW * 0.3245 , screenH * 0.0056 , texture . line2 , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "ID" , screenW * 0.2646 , screenH * 0.1954 , screenW * 0.2823 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Nick" , screenW * 0.2823 , screenH * 0.1954 , screenW * 0.4203 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Organizacja" , screenW * 0.4203 , screenH * 0.1954 , screenW * 0.5583 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Sluzba" , screenW * 0.5583 , screenH * 0.1954 , screenW * 0.6146 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "MP" , screenW * 0.6146 , screenH * 0.1954 , screenW * 0.6859 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "Ping" , screenW * 0.6859 , screenH * 0.1954 , screenW * 0.7380 , screenH * 0.2306 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
x = 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 i >= Class. Scroll [ 1 ] and i <= Class. Scroll [ 2 ] then
x = x + 1
local offsetY = ( math . floor ( 80 )*( x - 1 ))
dxDrawText ( id , screenW * 0.2646 , screenH * 0.2306 , screenW * 0.2823 , screenH * 0.2657 + offsetY , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( name , screenW * 0.2823 , screenH * 0.2306 , screenW * 0.4203 , screenH * 0.2657 + offsetY , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , true , false )
dxDrawText ( "org" , screenW * 0.4203 , screenH * 0.2306 , screenW * 0.5583 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "SAPDS" , screenW * 0.5583 , screenH * 0.2306 , screenW * 0.6146 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "100000" , screenW * 0.6146 , screenH * 0.2306 , screenW * 0.6859 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
dxDrawText ( "100000 m/s" , screenW * 0.6859 , screenH * 0.2306 , screenW * 0.7380 , screenH * 0.2657 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , exports . amta_gui : pobierzFont ( 'bfont20' ), "center" , "center" , false , false , false , false , false )
end
end
end
end
addEventHandler ( "onClientRender" , root , gui )
addCommandHandler ( "scr" , function( plr )
if not on or on == 0 then
on = 1
table . sort ( localPlayer , sort )
else
on = 0
end
end )
bindKey ( "mouse_wheel_down" , "both" , function()
if Class. Scroll [ 2 ] == Class. Scroll [ 3 ] then 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 )
Więcej szczegółów
Wystawiono 1 piw(a):borsuk
Tagi: sortowanie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: