Chopper Posted April 20, 2014 Share Posted April 20, 2014 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
aintaro Posted April 20, 2014 Share Posted April 20, 2014 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
Chopper Posted April 20, 2014 Author Share Posted April 20, 2014 Moving every player to a new "slot" in the table? Thats not really a solution.. Edit: Got it working. Ty. Link to comment
vx89 Posted April 20, 2014 Share Posted April 20, 2014 If you're interested, I impemented scrolling in my scoreboard (called raceboard) resource as well: https://community.multitheftauto.com/ind ... ls&id=9061 There's also a default scroll position, which at minimum shows the local player + 2 ones from the bottom (e.g when you're racing you probably want to see who's better than you, but also a few behind you). Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now