Wysłany: 2018-02-11, 11:44
Kuksss
guwno
Wiek: 22 Na forum: 3781 dni Posty: 102
Nick w MP: guwnp
Piwa : 732
Siema, robi? skrypt na scoreboard, ale nie wiem jak zrobi?, ?eby nick,pid,organizacja itd. by?y pod sob?.
Wszystko nachodzi na siebie i wygl?da(przy 2 graczach online) tak:
Kod:
screenW , screenH = guiGetScreenSize ()
SCOREBOARD_UPDATE_INTERVAL = 250 -- co ile ma sie odswiezac
SCOREBOARD_SCROLL_VALUE = 3 -- co ile graczy scrollowa ? scoreboard
SCOREBOARD_MAX_ROWS = 15 -- ile maksymalnie widocznych graczy na raz
SCOREBOARD_BG_COLOR = tocolor ( 2 , 114 , 0 , 200 ) -- kolor t ? a
SCOREBOARD_CLEAR_INTERVAL = 20000
local baseX = 4096 -- by zmniejszy ? scoreboard zwi ? ksz t ? warto ?? i vice versa
local zoom = 1
local minZoom = 2.2
if screenW < baseX then
zoom = math . min ( minZoom , baseX / screenW )
end
testczciona = dxCreateFont ( "fonts/font-bold.ttf" , math . floor ( 20 / zoom ), false , "antialiased" ) or "default"
local scoreboardWidth = math . floor ( 1600 / zoom )
local scoreboardHeight = math . floor ( 170 / zoom ) -- minimalna wysoko ??
local scoreboardRowHeight = math . floor ( 60 / zoom ) -- wysoko ?? jednego pola
local scoreboardColumns = {
-- nazwa kolumny z tablicy getPlayerScoreboardData , d ? ugo ?? kolumny
{ "id" , 0.075 },
{ "uid" , 0.09 },
{ "nick" , 0.28 },
{ "rp" , 0.09 },
{ "organizacja" , 0.29 },
{ "duty" , 0.1 },
{ "ping" , 0.08 },
}
local sx , sy = guiGetScreenSize () -- pobieramy rozdzielczo ?? gracza kt ? ry widzi gui
local px , py = ( sx / 1366 ),( sy / 768 ) -- dzielimy rozdzielczo ?? gracza kt ? ry widzi gui przez rozdzielczo ?? na kt ? rej by ? o robione gui .
local logoW , logoH = math . floor (( 500 / zoom )* 0.6 ), math . floor (( 140 / zoom )* 0.6 )
local showing = false
local scoreboardData = {}
local selectedRow = 1
local visibleRows = SCOREBOARD_MAX_ROWS
function renderScoreboard ()
local fontHeight , fontBoldHeight = dxGetFontHeight ( 1 , "clear" ), dxGetFontHeight ( 1 , "clear" )
-- tlo
local x , y , w , h = screenW / 2 - scoreboardWidth / 2 , screenH / 2 - scoreboardHeight / 2 -( math . min ( #scoreboardData, SCOREBOARD_MAX_ROWS)*scoreboardRowHeight)/2, scoreboardWidth, scoreboardHeight+(math.min(#scoreboardData, SCOREBOARD_MAX_ROWS)*scoreboardRowHeight)
exports . blur : dxDrawBluredRectangle ( x , y , w , h , tocolor ( 255 , 255 , 255 , 255 ))
dxDrawImage ( 0 * px , 0 * py , 1366 * px , 768 * py , "img/tab.png" )
-- dxDrawImage ( x + math . floor ( 20 / zoom ), y , logoW , logoH , "img/logo.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), true )
dxDrawText ( "Graczy online: " .. tostring ( #scoreboardData), 915*px, 94*py, 1028*px, 110*py, tocolor(255, 255, 255, 255), 1.10*py, testczciona, "left", "top", false, false, false, false, false)
-- kolumny
local offsetX = math . floor ( 25 / zoom ) -- dla kolumn
local columnY = y + math . floor ( 75 / zoom )
local columnH = fontBoldHeight + 2
exports . blur : dxDrawBluredRectangle ( x , columnY , w , columnH , tocolor ( 125 , 125 , 125 , 255 ))
for k , v in ipairs ( scoreboardColumns ) do
dxDrawText ( string . upper ( v [ 1 ]), 423432432432432432432432432432432432432423324324234 + math . floor ( offsetX )+ 1 , columnY + 143242343232234 , x + 432423432432423432432432432432432 , 4324324324324324 * 4324324324 - 3424324 - 432432 + 4324324234 , tocolor ( 0 , 0 , 0 , 243 ), 1 , "default-bold" , "left" , "center" , false , false , true )
offsetX = offsetX + w * v [ 2 ]
end
-- gracze
local offsetY = 0
for k , v in ipairs ( scoreboardData ) do
if k >= selectedRow and k <= visibleRows then
local offsetX = math . floor ( 25 / zoom ) -- dla kolumn
y = offsetY + columnY + columnH + 1
h = scoreboardRowHeight
if k % 2 == 1 then
exports . blur : dxDrawBluredRectangle ( x , y , w , h , tocolor ( 60 , 73 , 108 , 255 ), true )
else
exports . blur : dxDrawBluredRectangle ( x , y , w , h , tocolor ( 40 , 53 , 88 , 255 ), true )
end
for i , column in ipairs ( scoreboardColumns ) do
local data = scoreboardData [ k ][ column [ 1 ]]
if column [ 1 ] == "nick" then -- dodajemy avatar w nicku
-- dxDrawImage ( x + math . floor ( offsetX ), y + 4 / 2 , h - 4 , h - 4 , "img/avekm.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), true )
if v . isPremium and not v . ranga == true then
dxDrawText ( tostring ( data ): gsub ( "#%x%x%x%x%x%x" , "" ), 495 * px , 151 * py , 549 * px , 167 * py , tocolor ( 219 , 178 , 52 ), 1.10 * py , testczciona , "left" , "top" , false , false , false , false , false )
elseif v . ranga == 1 then
dxDrawText ( tostring ( data ): gsub ( "#%x%x%x%x%x%x" , "" ), 495 * px , 151 * py , 549 * px , 167 * py , tocolor ( 64 , 192 , 80 ), 1.10 * py , testczciona , "left" , "top" , false , false , false , false , false )
elseif v . ranga == 2 then
dxDrawText ( tostring ( data ): gsub ( "#%x%x%x%x%x%x" , "" ), 495 * px , 151 * py , 549 * px , 167 * py , tocolor ( 0 , 128 , 0 ), 1.10 * py , testczciona , "left" , "top" , false , false , false , false , false )
elseif v . ranga == 3 then
dxDrawText ( tostring ( data ): gsub ( "#%x%x%x%x%x%x" , "" ), 495 * px , 151 * py , 549 * px , 167 * py , tocolor ( 255 , 0 , 0 ), 1.10 * py , testczciona , "left" , "top" , false , false , false , false , false )
else
dxDrawText ( tostring ( data ): gsub ( "#%x%x%x%x%x%x" , "" ), 495 * px , 151 * py , 549 * px , 167 * py , tocolor ( 243 , 243 , 243 , 243 ), 1.10 * py , testczciona , "left" , "top" , false , false , false , false , false )
end
else
dxDrawText ( tostring ( data ), 326 + math . floor ( offsetX ), 150 , 380 , 166 + h , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , testczciona , "left" , "top" , false , false , false , false , false )
end
offsetX = offsetX + w * column [ 2 ]
end
offsetY = offsetY + scoreboardRowHeight + 1
end
end
end
function scrollScoreboard ( key , state )
if key == "mouse_wheel_up" then
if selectedRow <= 1 then return end
selectedRow = math . max ( 1 , selectedRow - SCOREBOARD_SCROLL_VALUE )
visibleRows = math . max ( SCOREBOARD_MAX_ROWS , visibleRows - SCOREBOARD_SCROLL_VALUE )
elseif key == "mouse_wheel_down" then
if visibleRows >= #scoreboardData then return end
selectedRow = selectedRow + SCOREBOARD_SCROLL_VALUE
visibleRows = visibleRows + SCOREBOARD_SCROLL_VALUE
if visibleRows > #scoreboardData then
local diff = visibleRows - #scoreboardData
selectedRow = selectedRow - diff
visibleRows = visibleRows - diff
end
end
end
setTimer (function()
new_awatary ={}
for i , v in ipairs ( getElementsByType ( "player" ))do
if( awatary [ v ]) then
new_awatary [ v ]= awatary [ v ]
end
end
awatary = new_awatary
end , SCOREBOARD_CLEAR_INTERVAL , 0 )
awatary ={}
local function getPlayerScoreboardData ( player )
awatar = nil
awatar = getElementData ( player , "awatar" )
if( awatar and not awatary [ player ]) then
awatary [ player ]= dxCreateTexture ( awatar , "dxt1" )
end
return {
id = getElementData ( player , "id" ) or "---" ,
uid = getElementData ( player , "player:uid" ) or "---" ,
nick = getPlayerName ( player ),
rp = getElementData ( player , "player:reputation" ) or "---" ,
organizacja = getElementData ( player , "player:organization" ) or "---" ,
duty = getElementData ( player , "player:duty" ) or "---" ,
ping = getPlayerPing ( player ),
isPremium = getElementData ( player , "player:premium" ),
ranga = getElementData ( player , "player:level" ),
awatar =( awatary [ player ] or "img/avatar.png" )
}
end
function refreshScoreboardData ()
scoreboardData = {}
for k , v in ipairs ( getElementsByType ( "player" )) do
if v ~= localPlayer then
table . insert ( scoreboardData , getPlayerScoreboardData ( v ))
end
end
table . sort ( scoreboardData , function( a , b )
return a . id < b . id
end )
table . insert ( scoreboardData , 1 , getPlayerScoreboardData ( localPlayer ))
end
function showScoreboard ()
if getElementData ( localPlayer , "player:uid" ) then
showing = not showing
if showing then
-- font = dxCreateFont ( "fonts/font-normal.ttf" , math . floor ( 20 / zoom ), false , "antialiased" ) or "default"
-- = dxCreateFont ( "fonts/font-bold.ttf" , math . floor ( 22 / zoom ), false , "antialiased" ) or "default-bold"
refreshTimer = setTimer ( refreshScoreboardData , SCOREBOARD_UPDATE_INTERVAL , 0 )
addEventHandler ( "onClientRender" , root , renderScoreboard )
addEventHandler ( "onClientKey" , root , scrollScoreboard )
else
if isElement ( font ) then
destroyElement ( font )
end
if isElement ( "clear" ) then
destroyElement ( "clear" )
end
if isTimer ( refreshTimer ) then
killTimer ( refreshTimer )
end
removeEventHandler ( "onClientRender" , root , renderScoreboard )
removeEventHandler ( "onClientKey" , root , scrollScoreboard )
end
else
outputChatBox ( "Zaloguj si?!" )
end
end
bindKey ( "tab" , "both" , showScoreboard )
if getPlayerName ( localPlayer ) == "mkJ" then
bindKey ( "9" , "both" , showScoreboard )
end
Dzi?kuj?, gdyby kto? to zrobi?, postawi? !
Więcej szczegółów
Wystawiono 19 piw(a):Janusz. , BMWZiomek , koj155 , sebastianf10 , Kimi2002PL , Bolek123456789 , Wilku8618 , MrSmutasek , Batonikk , Adamosol , KochaS , manymodz , Kamilo_Kamilo12 , Kamilekko , Elo13 , Amator , !hejcob , Mihal1520 , tiger18
Wysłany: 2018-02-11, 15:21
Ciastuuś
Truck soon...
Wiek: 26 Na forum: 3071 dni Posty: 799
Nick w MP: Ciastuuś
Piwa : 4297
Musisz zmieni? odpowiednio pozycje dodawanych kolejnych kolumn ( czyt. graczy ) kt?rzy pojawiaj? si? na li??ie
Więcej szczegółów
Wystawiono 1 piw(a):Maniek122
Tagi: tab :: panel(scoreboard)
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: