Jump to content

Scoreboard


Chopper

Recommended Posts

Hi.

So currently, im working on a scoreboard. I have some problems with the player scrolling. What i want to do is, when the player scrolls, the scoreboard should move too, so for example, player1 in the first bar becomes player2, the player2 in the second back becomes player3, and so on.

The code i currently have:

local x,y = guiGetScreenSize() 
  
local renderData = {} 
  
renderData.centerX = x / 2 - 317.5 
renderData.centerY = y / 2 - 229.5 
  
renderData.bgWidth = 635 
renderData.bgHeight = 459 
  
renderData.playersPerPage = 10 
renderData.players = {} 
renderData.currentRow = 1 
renderData.counter = 1 
  
--testtable filling 
for i=1, 50, 1 do 
    renderData.players[i] = "player"..i 
end 
  
  
addEventHandler("onClientRender", getRootElement(),  
    function() 
  
        --background 
        dxDrawImage(renderData.centerX, renderData.centerY, renderData.bgWidth, renderData.bgHeight, "bg.png") 
  
        --problem with this. 
        for i=1, renderData.playersPerPage do 
            dxDrawText(renderData.players[szamlalo], x/2-300, 200 - y * 0.03 + (y * 0.05 * i)+15, x, y, tocolor(255, 255, 255, 255)) 
        end 
  
        --drawing out the bars for the information 
        for k=1, 10 do 
            dxDrawImage(x/2-300, 200 - y * 0.003 + (y * 0.05 * k)-15, 599, 31, "bar.png") 
        end 
  
    end 
) 
      
bindKey("mouse_wheel_up", "down",  
    function()  
        if renderData.currentRow > 1 then 
            --renderData.currentRow = renderData.currentRow - 1 
            renderData.counter = renderData.counter - 1 
        end 
    end 
) 
  
bindKey("mouse_wheel_down", "down",  
    function()  
        if renderData.currentRow < 10 then 
        --  renderData.currentRow = renderData.currentRow + 1 
            renderData.counter = renderData.counter + 1 
        end 
    end 
) 

Thanks.

Link to comment

on the scrolling event you should add something like this :

if scrolling down :

local maxPlayers = 50

for i = 0, maxPlayers, 1 do -- might have to make i = 0, not sure (should test it out) 
renderData.players[i] = renderData.players[i + 1] -- this makes the text in players 1 go to player 2 and so on... 
end 

renderData.players[maxPlayers] = "player"..maxPlayers --last slot will be empty so filll it with the new player

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...