Jump to content

[Help] How to make scroll for multiple loops?


Recommended Posts

I tried a method, which works with one table, but now, when i tried merge 2 table datas, this method does not working...

This is my code (not full) I tried to highlight the important parts, if necessary, I will send in pm the full code:

Spoiler

local adminok = {}
local jatekosok = {}

local score = {}

local normalScoreGorget = 0
local maxMegjelenit = 10

function scoreboard()
local elem = 0
    for i, v in ipairs(score) do 
        if (i > normalScoreGorget and elem < maxMegjelenit) then
            elem = elem + 1
                ---some dx element, etc...   
            for k, d in ipairs (adminok) do
                -- more dx stuff...
        		elem = elem + 1
            end
            jatekosok = {}
            local online = #getElementsByType("player")
                for i, player in pairs(getElementsByType("player")) do
                    if not getPlayerTeam(player) then
                        table.insert(jatekosok, player);
                    end
                end
    
                for i, team in pairs(getElementsByType("team")) do
                    local team_players = getPlayersInTeam(team);
                    if #team_players >= 0 then
                        table.insert(jatekosok, team);
                        for i, player in pairs(team_players) do
                            table.insert(jatekosok, player);
                        end
                    end
                end

                if #getElementsByType("player") >= 1 then 
                    --dx elements....
                for r, w in pairs(jatekosok) do
                    elem = elem + 1

                if getElementType(w) == "player" then
                    --dx elements...
                elseif getElementType(w) == "team" then
                    --dx elements...
                end
            end
        end
    end
end
addEventHandler("onClientRender",root,scoreboard)

function start()
	merge(score, {"Adminok"}, adminok, {"Játékosok"}, jatekosok)
end
addEventHandler("onClientResourceStart",resourceRoot,start)

function merge(table1,...)
    for _,table2 in ipairs({...}) do
        for key,value in pairs(table2) do
            if (type(key) == "number") then
                table.insert(table1,value)
            else
                table1[key] = value
            end
        end
    end
    return table1
end
  
  bindKey("mouse_wheel_down", "both", 
	function() 
			if normalScoreGorget < #score - maxMegjelenit then
				normalScoreGorget = normalScoreGorget + 1	
end
		end
)

bindKey("mouse_wheel_up", "both", 
	function() 

			if normalScoreGorget > 0 then
				normalScoreGorget = normalScoreGorget - 1		
			end
	end
)

 

I want show maximum 10 rows, and if have more rows, then show another rows with scrolling. This working fine with 1 table, and loop, but now does not working at all.

It always show all rows, even if there are already more than 10, and ofc cannot scrolling.

What wrong?? How to fix this? I've been trying fix this for hours, but nothing... :(

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...