Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sw, sh = guiGetScreenSize()
- scoreboardColumns = {
- { name = "Player", width = 200, data = function (element) return getPlayerName ( element ) end },
- { name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ).. "/"..( getElementData ( element, "murders_total" ) or 0 ) end },
- { name = "Killed Zombies", width = 80, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ).. "/"..( getElementData ( element, "zombieskilled_total" ) or 0 ) end },
- { name = "Alive Time", width = 80, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ).."/"..formatTimeFromMinutes(getElementData ( element, "alivetime_total" ) or 1 ) end },
- { name = "Group", width = 80, data = function (element) return getElementData ( element, "gang" ) or "None" end },
- { name = "TM", width = 50, data = function (element) return ( getElementData ( element, "murders_total" ) or 0 ) end },
- { name = "TD", width = 50, data = function (element) return ( getElementData ( element, "deaths_total" ) or 0 ) end },
- { name = "KD Ratio", width = 50, data = function (element)
- if not (getElementData ( element, "deaths_total" ) and getElementData ( element, "murders_total" ) ) then
- return 0
- elseif not (getElementData ( element, "deaths_total" ) > 0 ) then
- return ( ('%.2f'):format( (getElementData ( element, "murdesrs_total" ) or 0) / 1) )
- else
- return ( ('%.2f'):format( (getElementData ( element, "murders_total" ) or 0) / getElementData ( element, "deaths_total" ) ) ) end end },
- { name = "Ping", width = 40, data = function (element) return (getPlayerPing(element)) end },
- }
- local serverName = "CLASSIC DAYZ" -- название сервера
- local topsize = 60 -- величина шляпы
- local playersize = topsize-30 -- высота одной строки
- local panelsize = playersize*10 -- величина панели
- function calculateWidth()
- local width = 0
- for key, value in ipairs( scoreboardColumns ) do
- width = width + value.width
- end
- return width + 60
- end
- local max_players = 20
- local ploff = 0
- local width = calculateWidth()
- local baseX = sw/2-width/2
- local baseY = sh/2-(panelsize+topsize)/2
- addEventHandler( "onClientRender", root,
- function()
- if getKeyState( "tab" ) == false then ploff = 0; return end
- if getElementData(getLocalPlayer(),"logedin") then
- dxDrawRectangle ( baseX, baseY, width, topsize, tocolor(32,32,32) )
- dxDrawText ( serverName, baseX+20, baseY+10, baseX+width, baseY+topsize, tocolor(255,255,255), 0.9, "default-bold" )
- dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0,0,0,150) )
- dxDrawLine ( baseX, baseY+30, baseX+width, baseY+30, tocolor(100,100,100),0.8 )
- dxDrawLine ( baseX, baseY+30, baseX, baseY+panelsize+topsize, tocolor(100,100,100),0.8 )
- dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100),0.8 )
- dxDrawLine ( baseX+40, baseY+30, baseX+40, baseY+panelsize+topsize, tocolor(100,100,100),0.8 )
- dxDrawText ( "#", baseX, baseY+60, baseX+40, baseY+topsize-30, tocolor(255,255,255), 1, "default-bold", "center", "center" )
- local xoff = 60
- for i, v in ipairs ( scoreboardColumns ) do
- dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize+topsize, tocolor(100,100,100),0.8 )
- dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255), 1, "default-bold", "center", "center" )
- xoff = xoff+v.width
- end
- local playersTable = getElementsByType ( "player" )
- --local playersTable = { localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer }
- dxDrawText ( "Online: "..tostring(#playersTable).."/"..tostring(max_players), baseX+20, baseY+10, baseX+width-20, baseY+topsize, tocolor(255,255,255), 0.9, "default-bold", "right" )
- local maxNum = #playersTable
- if maxNum > 10 then
- maxNum = 10
- end
- for i = 1, maxNum do
- dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(100,100,100),0.8 )
- dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+40, baseY+topsize+playersize*i, tocolor(255,255,255), 1, "default-bold", "center", "center" )
- if playersTable[i+ploff] == localPlayer then
- dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(112,112,112,100) )
- end
- local xoff = 60
- for c, d in ipairs ( scoreboardColumns ) do
- local data = d.data(playersTable[i+ploff])
- local r,g,b = 255,255,255
- if d.name == "Group" and data == "None" then
- r,g,b = 0,255,0
- data = ""
- end
- dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width, baseY+topsize+playersize*i, tocolor(r,g,b), 1, "default-bold", "center", "center" )
- xoff = xoff+d.width
- end
- end
- end
- end
- )
- function PlayerScrollMenu (key,keyState,arg)
- if getElementData(localPlayer,"logedin") and getKeyState( "tab" ) then
- if ( keyState == "down" ) then
- if arg == "up" then
- if ploff > 0 then
- ploff=ploff-1
- end
- elseif arg == "down" then
- local playersTable = getElementsByType ( "player" )
- --local playersTable = { localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer }
- if ploff < #playersTable-10 then
- ploff = ploff+1
- end
- end
- end
- end
- end
- bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
- bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )
- function formatTimeFromMinutes(value)
- if value then
- local hours = math.floor(value/60)
- local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
- if minutes < 10 then minutes = "0"..minutes end
- value = hours..":"..minutes
- return value
- end
- return false
- end
- function math.round(number, decimals, method)
- decimals = decimals or 0
- local factor = 10 ^ decimals
- if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
- else return tonumber(("%."..decimals.."f"):format(number)) end
- end
- function sendMaxPlayersOnServer (players)
- max_players = players
- end
- addEvent("sendMaxPlayersOnServer",true)
- addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)
Advertisement
Add Comment
Please, Sign In to add comment