iAxel Posted January 25, 2015 Share Posted January 25, 2015 Hello guys! A few days ago did DxScroll, but can not seem to solve one problem How to limit the visibility of items, as in the gui Scroll Namely thus Screenshots: Code: local sW, sH = guiGetScreenSize() local bW, bH = (sW/2), (sH/2) local offset = 0 -- addEventHandler('onClientRender', root, function () if (isLogged(localPlayer)) then dxDrawRectangle(bW+190, bH-300, 320, 20, tocolor(0, 0, 0, 255)) dxDrawText('INVENTORY', bW+195, bH-300, bW+510, bH-280, tocolor(160, 160, 160, 255), 1, 'default', 'left', 'center', false, false, true, false, false) --Box dxDrawLine(bW+190, bH-281, bW+190, bH+280, tocolor(200, 200, 200, 100), 1) dxDrawLine(bW+510, bH-281, bW+190, bH-281, tocolor(200, 200, 200, 100), 1) dxDrawLine(bW+190, bH+280, bW+510, bH+280, tocolor(200, 200, 200, 100), 1) dxDrawLine(bW+510, bH+280, bW+510, bH-281, tocolor(200, 200, 200, 100), 1) dxDrawRectangle(bW+191, bH-280, 319, 560, tocolor(0, 0, 0, 70)) dxDrawLine(bW+500, bH-280, bW+500, bH+279, tocolor(200, 200, 200, 100), 1) --Scrollbar dxDrawLine(bW+502, bH-280+offset, bW+502, bH-109+offset, tocolor(200, 200, 200, 100), 1) dxDrawLine(bW+508, bH-280+offset, bW+502, bH-280+offset, tocolor(200, 200, 200, 100), 1) dxDrawLine(bW+502, bH-109+offset, bW+508, bH-109+offset, tocolor(200, 200, 200, 100), 1) dxDrawLine(bW+508, bH-109+offset, bW+508, bH-280+offset, tocolor(200, 200, 200, 100), 1) dxDrawRectangle(bW+503, bH-279+offset, 5, 170, tocolor(0, 0, 0, 0)) --Items for i = 1, 10 do dxDrawRectangle(bW+191, bH-345+65*i-offset, 309, 60, tocolor(100, 100, 100, 200)) dxDrawImage(bW+191, bH-345+65*i-offset, 60, 60, ':guieditor/images/plus.png', 0, 0, 0, tocolor(255, 255, 255, 255)) dxDrawText('Backpack '..i, bW+261, bH-326+65*i-offset, bW+499, bH-306+65*i-offset, tocolor(255, 255, 255, 255), 1, 'default-bold', 'left', 'center', false, false, true, false, false) dxDrawText('0/'..i, bW+451, bH-346+65*i-offset, bW+499, bH-326+65*i-offset, tocolor(255, 255, 255, 255), 1, 'default-bold', 'right', 'center', false, false, true, false, false) end end end end ) -- function Scroll(key, state) if (isLogged(localPlayer)) then if (state == 'down') then if (key == 'mouse_wheel_up') then if (offset > 0) then offset = offset-97 else offset = 0 end elseif (key == 'mouse_wheel_down') then if (offset < 388) then offset = offset+97 else offset = 388 end end end end end bindKey('mouse_wheel_up', 'down', Scroll) bindKey('mouse_wheel_down', 'down', Scroll) Help solve the problem Thanks in advance to all Link to comment
iAxel Posted January 26, 2015 Author Share Posted January 26, 2015 Solved: helped dxCreateRenderTarget. Link to comment
iAxel Posted January 26, 2015 Author Share Posted January 26, 2015 Help me please with function moving the scrollbar with mouse To do this I will need the features OnClientKey OnClientCursorMove But I have no idea how to do it Please help me and thanks in advance Link to comment
Malak Posted January 26, 2015 Share Posted January 26, 2015 Hi, Scrollbar is also a difficult script to make it in dX but in fact you can use the both function. onclientclick with button in 'up' states put a variable for looking if its hold. then when u use oncursormove make a math calcul for see the last position and the current position then u move your scrollbar (image) with it and also move the content too. I don't know to make you a good answer but i didn't have a lot of time for make you this script. I hope i could help you. Link to comment
iAxel Posted January 27, 2015 Author Share Posted January 27, 2015 Thanks for the reply Link to comment
Dealman Posted January 28, 2015 Share Posted January 28, 2015 He answered your question. First you use onClientClick, if the state is "down" - assume the player is holding the left key down. You can also make sure it's held down via using getKeyState. You then use onClientMove to calculate whether the client is moving his cursor up or down and change the offset accordingly. Link to comment
iAxel Posted January 28, 2015 Author Share Posted January 28, 2015 He answered your question.First you use onClientClick, if the state is "down" - assume the player is holding the left key down. You can also make sure it's held down via using getKeyState. You then use onClientMove to calculate whether the client is moving his cursor up or down and change the offset accordingly. Thank you of course, but I need a start code to understand how it works, please help me this is really necessary Link to comment
Dealman Posted January 28, 2015 Share Posted January 28, 2015 Try it yourself, you'll learn the most if you actually give it a few attempts. We'll help from there Link to comment
iAxel Posted January 30, 2015 Author Share Posted January 30, 2015 (edited) Is it possible to find the coordinates of the cursor in RenderTarget? getCursorPosition () is not helping, output is wrong x, y coordinates local sW, sH = guiGetScreenSize() local bW, bH = (sW / 2), (sH / 2) local Box = dxCreateRenderTarget(1019, 560, true) local mX, mY = (1019 / 2), (560 / 2) addEventHandler('onClientRender', root, function () if (isLogged(localPlayer)) then if (isVisible) then --Scrollbar dxDrawRectangle(bW - 197, bH - 279 + offset, 5, 170, tocolor(200, 200, 200, 100)) dxDrawRectangle(bW + 503, bH - 279 + offset, 5, 170, tocolor(200, 200, 200, 100)) --Box dxSetRenderTarget(Box, true) for i = 1, 14 do dxDrawRectangle(0, mY - 345 + 65 * i - offset, 309, 60, tocolor(75, 75, 75, 200)) dxDrawImage(0, mY - 345 + 65 * i - offset, 60, 60, ':guieditor/images/plus.png') dxDrawText('Backpack '..i, mX - 439.5, mY - 324 + 65 * i - offset) dxDrawText(i..'/35', mX - 234.5, mY - 345 + 65 * i - offset) dxDrawRectangle(mX + 190.5, mY - 345 + 65 * i - offset, 309, 60, tocolor(75, 75, 75, 200)) dxDrawImage(mX + 190.5, mY - 345 + 65 * i - offset, 60, 60, ':guieditor/images/plus.png') dxDrawText('Backpack '..i, mX + 260.5, mY - 324 + 65 * i - offset) dxDrawText(i..'/35', mX + 465.5, mY - 345 + 65 * i - offset) end dxSetRenderTarget() dxDrawImage(bW - 509, bH - 280, 1019, 560, Box) end end end ) Edited January 31, 2015 by Guest Link to comment
Dealman Posted January 30, 2015 Share Posted January 30, 2015 I agree that getCursorPosition is pretty bad, it needs have a boolean added to it so it can return both relative and absolute. That said, you can still use relative values as effectively as absolute values, in fact, I'd rather use relative values as it'll work on all resolutions. onClientMouseMove returns absolute X and Y. Link to comment
iAxel Posted January 31, 2015 Author Share Posted January 31, 2015 I agree that getCursorPosition is pretty bad, it needs have a boolean added to it so it can return both relative and absolute.That said, you can still use relative values as effectively as absolute values, in fact, I'd rather use relative values as it'll work on all resolutions. onClientMouseMove returns absolute X and Y. Do not onClientMouseMove for GUI? Updated the code above I need to know the position of the cursor inside RenderTarget Link to comment
Dealman Posted January 31, 2015 Share Posted January 31, 2015 Do not onClientMouseMove for GUI? Updated the code above I need to know the position of the cursor inside RenderTarget So it does... You need the position relative to the rendertarget? Link to comment
iAxel Posted February 4, 2015 Author Share Posted February 4, 2015 Do not onClientMouseMove for GUI? Updated the code above I need to know the position of the cursor inside RenderTarget So it does... You need the position relative to the rendertarget? I need to move objects within rendertarget with the mouse Link to comment
..:D&G:.. Posted February 4, 2015 Share Posted February 4, 2015 Download Valhalla gaming roleplay from google and get the resource called 'vgscoreboard' and get the example from there. Link to comment
iAxel Posted February 4, 2015 Author Share Posted February 4, 2015 [quote name=..&G:..]Download Valhalla gaming roleplay from google and get the resource called 'vgscoreboard' and get the example from there. There's nothing related to rendertarget 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