I think it's okay.
Maybe if you define the 'latestRow' once in bindKey functions and not in the 'drawPanel' function.
function drawPanel()
dxDrawRectangle(panelX, panelY, mainW, mainH, tocolor(0, 0, 0, 180))
for i, v in ipairs(TextsInTable) do
if i >= currentRow and i <= latestRow then
i = i - currentRow + 1
local rowY = panelY + rowH + ((i - 1) * rowH) - 180
dxDrawCenterText(v[1].." "..v[2], panelX, rowY, mainW, mainH, Font)
end
end
end
addEventHandler("onClientRender", root, drawPanel)
bindKey("mouse_wheel_down", "down", function()
if currentRow < #TextsInTable - (maxRow - 1) then
currentRow = currentRow + 1
latestRow = currentRow + maxRow - 1
end
end)
bindKey("mouse_wheel_up", "down", function()
if currentRow > 1 then
currentRow = currentRow - 1
latestRow = currentRow + maxRow - 1
end
end)
function dxDrawCenterText(text, startX, startY, width, height, color)
dxDrawText(text, startX, startY, startX + width , startY + height, color, 1, "normal", "center", "center", false, false, false, true)
end