Karuzo Posted May 12, 2014 Share Posted May 12, 2014 Hey Guys, I'm in need of help, i'm trying to make a scoreboard which allows you to select every player if you're scrolling. The only problem is that i just can't limit the player lines to 8 , like if there are more than 8 players online it should go on the next page, and if you're on offset 8 then it should go on the next page and if you're on offset 0 it should do page = page - 1. The thing with the offset 0 works, but if i'm on offset 8 it just does page = page + 1 till 100000etc.. I know it's cuz i'm asking for the offset and if it's 8 it should do page + 1 but i just don't know how to make that it just should do page = page + 1 and not page = page + 1 till dunno 100k or smth like that. It looks like this atm : And this is my code: local root = getRootElement() local x,y = guiGetScreenSize() local lp = getLocalPlayer() local resroot = getResourceRootElement(getThisResource()) local recw,rech = 500,200 local recx,recy = x/2-recw/2,y/2-rech/2 local offset = 1 local step = 1 local names = {} local totallines = 9 local testtable = {} local page = 0 --local tab = dxElement:create("gridlist",nil,recx+10,recy+10,180,180,{255,255,255,255},1,"default-bold",nil,nil,nil,{0, 0,0,5},{15,192,252,80},{255,255,255,255},nil) --tab:setVisibility(false) for k=0,40,1 do table.insert(testtable,"Player "..k) end function performRender() local playertab = getElementsByType("player") dxDrawRectangle(recx,recy,recw,rech,tocolor(101,101,101,100),false) dxDrawRectangle(recx+10,recy+10,180,180,tocolor(0,0,0,200),false) local player = playertab[offset*page] local test = testtable[offset] for i,v in ipairs(testtable) do --local test = getElementData(player,"Level") --outputChatBox(test) --names[i] = string.gsub( getPlayerName( v ), "#%x%x%x%x%x%x", "", 1 ) dxDrawRectangle(recx+10,((recy-10))+offset*20,180,20,tocolor(15,192,252,80),false) dxDrawText(testtable[i],recx+15,(recy-10)+i*20) end outputChatBox(test) if page < 1 then page = 1 end outputChatBox(page) end function scrolling(side) if side == "up" then offset = offset - step elseif side == "down" then offset = offset + step end if offset >= totallines then page = page + 1 offset = 0 elseif offset <= 1 then page = page - 1 offset = 1 end end function scrollUP() scrolling("up") end function scrollDown() scrolling("down") end bindKey("mouse_wheel_up","down",scrollUP) bindKey("mouse_wheel_down","down",scrollDown) bindKey("tab","both", function(_,state) if state == "down" then addEventHandler("onClientRender",root,performRender) showingtab = true elseif state == "up" then removeEventHandler("onClientRender",root,performRender) offset = 1 page = 1 showingtab = false end end ) Link to comment
xXMADEXx Posted May 12, 2014 Share Posted May 12, 2014 Maybe you can try to edit this resource or just looking at how he made the scroll. Link to comment
Karuzo Posted May 12, 2014 Author Share Posted May 12, 2014 I understand the scrolling, and did that, as you could see in the code i've posted. The only problem is idk how to change pages and to divide the players in different pages. Like if there are more players then the totallines it should go on the next page and if i'm on offset 8 it should do page + 1 and if i'm on offset 0 it should do page - 1 , the one with offset 0 works already. 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