NeVada Posted July 14, 2018 Share Posted July 14, 2018 (edited) Hey guys, I have some problem with my panel. So, first of all, I did a small panel with two buttons. I can close the panel, but I don't know how to make a next page. How could I make a next page? Should I disappear the first page, and then create another one? Here's my code: local thePlayer = getLocalPlayer() local x, y = guiGetScreenSize(thePlayer) local pS = [[randomtext]] ------------------------------------------------------------------------------------------- function drawInformation() dxDrawRectangle(x/3, y/3, 500, 450, tocolor(0, 0, 0, 125)) dxDrawRectangle(x/3, y/3, 500, 20, tocolor(0, 0, 0, 125)) dxDrawRectangle(x/2.8, y/1.4, 100, 30, tocolor(0, 0, 0, 125)) dxDrawRectangle(x/1.6, y/1.4, 100, 30, tocolor(0, 0, 0, 125)) dxDrawText("Welcome to the help panel!", x/2.3, y/2.8, tocolor(75, 108, 213, 115)) dxDrawText(pS, x/2.8, y/2.6) dxDrawText("Close", x/2.6, y/1.39, tocolor(75, 108, 213, 125)) dxDrawText("Next", x/1.54, y/1.39, tocolor(75, 108, 213, 125)) end ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- function showThings() addEventHandler("onClientRender", root, drawThings) addEventHandler("onClientClick", getRootElement(), onClickThing) showCursor(true) outputChatBox("t") end addCommandHandler("test", showThings) function disappearThings() removeEventHandler("onClientRender", root, drawThings) removeEventHandler("onClientClick", getRootElement(), onClickThing) showCursor(false) outputChatBox("t.") end --------------------------------------------------------------------------------------------- function onClickThing(button, state, absoluteX, absoluteY, worldX, worldZ, clickedElement) if (state == "down") then if (absoluteX >= x/2.8) and (absoluteX <= x/2.8 + 100) and (absoluteY >= y/1.4) and (absoluteY <= y/1.4 + 100) then disappearThings() end end end Edited July 14, 2018 by NeVada t Link to comment
DiGiTal Posted July 14, 2018 Share Posted July 14, 2018 yea, for example: create small icon , when player click on it dispear the precedent content and show the new one ! Link to comment
NeVada Posted July 14, 2018 Author Share Posted July 14, 2018 I've finally made it! And it wasn't so hard haha. Maybe it's a bit amateurish. function drawNextPage() dxDrawRectangle(x/3, y/3, 500, 450, tocolor(0, 0, 0, 125)) dxDrawRectangle(x/3, y/3, 500, 20, tocolor(0, 0, 0, 125)) end function showFirst() addEventHandler("onClientRender", root, drawNextPage) addEventHandler("onClientClick", getRootElement(), onClickNext) showCursor(true) end function onClickNext(button, state, absoluteX, absoluteY, worldX, worldZ, clickedElement) if (state == "down") then if (absoluteX >= x/1.6) and (absoluteX <= x/1.6 + 100) and (absoluteY >= y/1.4) and (absoluteY <= y/1.4 + 100) then disappearThings() showFirst() end end end 1 Link to comment
Discord Moderators Pirulax Posted July 15, 2018 Discord Moderators Share Posted July 15, 2018 use a function instead, because u'll use it a lot in the future. and, if i would be u, i would use a variable like: local currentPanelName = "information" And, then under render I would use an if statement, like: if (currentPanelName=="information") then --// Ur code here elseif (currentPanelName=="panel2") then --// Ur code here end Link to comment
NeVada Posted July 15, 2018 Author Share Posted July 15, 2018 Oh, thank you for your help! It's better than my. 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