Firespider Posted July 29, 2022 Author Share Posted July 29, 2022 Worthless Cynomys 4 nappal ezelőtt X2 and Y2 are the x of panel + panel size and y of panel + panel size X2 and Y2 are the x of panel + panel size and y of panel + panel size I don't understand what with what. Link to comment
MouNiR.Dz Posted July 29, 2022 Share Posted July 29, 2022 33 minutes ago, Firespider said: Worthless Cynomys 4 nappal ezelőtt X2 and Y2 are the x of panel + panel size and y of panel + panel size X2 and Y2 are the x of panel + panel size and y of panel + panel size I don't understand what with what. Well i see there is too 'gombl' dx draw in your screen shot Btw if u mean the first 'gombl' use sy,sy = guiGetScreenSize() if isInBox(sx*.40,sy*.47,sx*.06,sx*.05) then If u mean the second 'gombl' use sx,sy = guiGetScreenSize() if IsInBox(sx*.55,sy*.47,sx*.06,sy*.05) then That what i got after trying to understand Link to comment
Mr.Hugin Posted July 29, 2022 Share Posted July 29, 2022 (edited) 8 hours ago, Firespider said: function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end ------------ color = tocolor(0, 0, 0, 180) --Here is the color of the button I made ------------ dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color, false) --gombl ------------ if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then color1 = tocolor(88, 0, 0, 50) --And here you put any color when the mouse touches the button, a color appears else color1 = color end try this Edited July 29, 2022 by Mr.Hugin 1 Link to comment
Firespider Posted July 30, 2022 Author Share Posted July 30, 2022 Doesn't working Doesn't working Link to comment
#\_oskar_/# Posted July 31, 2022 Share Posted July 31, 2022 5 minutes ago, Firespider said: I already use it Show me your code Link to comment
Firespider Posted July 31, 2022 Author Share Posted July 31, 2022 That way it can be more transparent ocal sx,sy = guiGetScreenSize();--1920,1080 local relx,rely = sx/1920,sy/1080; local cardPed = createPed(1, 337.536, -1358.894, 14.508, 280) local shopWindow = {0.3, 0.25} local IsCardShop = false local money = getPlayerMoney(localPlayer) local Cardlist = { [1] = {411, "Jogosítvány", 1000}, [2] = {482, "Jogosítvány", 10000}, }; function isInBox(x,y,x2,y2) if (isCursorShowing()) then local cX, cY = getCursorPosition(); if ( (cX >= x) and (cY >= y) and (cX <= x2) and (cY <= y2) ) then return true; else return false; end end end local Buttoncolors = { [1] = tocolor(49, 230, 32, 250); } addEventHandler("onClientRender", root, function() if (IsCardShop) then dxDrawRectangle(sx*.35, sy*.35, sx*.30, sy*.05, tocolor(0, 0, 0, 200))--Fejléc dxDrawText("Jogosítvány", sx*.50, sy*.035, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawRectangle(sx*.35, sy*.40, sx*.30, sy*.20, tocolor(30, 40, 50, 250))-- panel dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, tocolor(49, 230, 32, 250))--gomb1 dxDrawText("Megvétel", sx*.36, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Legális 1000$", sx*.36, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawRectangle(sx*0.55, sy*0.47, sx*0.06, sy*0.05, Buttoncolors[1])--gomb1 dxDrawText("Megvétel", sx*.66, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Ilegális 10000$", sx*.66, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Összeged: "..money.."$", sx*.52, sy*.40, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat end end ); bindKey("BACKSPACE","down",function() if IsCardShop == true then IsCardShop = false end end ) function showCard(index) end addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) if (button == "right") and (state == "up") then IsCardShop = true--- end end) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end ------------ color = tocolor(230, 32, 250, 180) --Here is the color of the button I made ------------ dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color, false) --gombl ------------ if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then color1 = tocolor(88, 0, 0, 50) --And here you put any color when the mouse touches the button, a color appears else color1 = color end Link to comment
Mr.Hugin Posted July 31, 2022 Share Posted July 31, 2022 3 hours ago, Firespider said: That way it can be more transparent ocal sx,sy = guiGetScreenSize();--1920,1080 local relx,rely = sx/1920,sy/1080; local cardPed = createPed(1, 337.536, -1358.894, 14.508, 280) local shopWindow = {0.3, 0.25} local IsCardShop = false local money = getPlayerMoney(localPlayer) local Cardlist = { [1] = {411, "Jogosítvány", 1000}, [2] = {482, "Jogosítvány", 10000}, }; function isInBox(x,y,x2,y2) if (isCursorShowing()) then local cX, cY = getCursorPosition(); if ( (cX >= x) and (cY >= y) and (cX <= x2) and (cY <= y2) ) then return true; else return false; end end end local Buttoncolors = { [1] = tocolor(49, 230, 32, 250); } addEventHandler("onClientRender", root, function() if (IsCardShop) then dxDrawRectangle(sx*.35, sy*.35, sx*.30, sy*.05, tocolor(0, 0, 0, 200))--Fejléc dxDrawText("Jogosítvány", sx*.50, sy*.035, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawRectangle(sx*.35, sy*.40, sx*.30, sy*.20, tocolor(30, 40, 50, 250))-- panel dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, tocolor(49, 230, 32, 250))--gomb1 dxDrawText("Megvétel", sx*.36, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Legális 1000$", sx*.36, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawRectangle(sx*0.55, sy*0.47, sx*0.06, sy*0.05, Buttoncolors[1])--gomb1 dxDrawText("Megvétel", sx*.66, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Ilegális 10000$", sx*.66, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Összeged: "..money.."$", sx*.52, sy*.40, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat end end ); bindKey("BACKSPACE","down",function() if IsCardShop == true then IsCardShop = false end end ) function showCard(index) end addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) if (button == "right") and (state == "up") then IsCardShop = true--- end end) function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end ------------ color = tocolor(230, 32, 250, 180) --Here is the color of the button I made ------------ dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color, false) --gombl ------------ if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then color1 = tocolor(88, 0, 0, 50) --And here you put any color when the mouse touches the button, a color appears else color1 = color end local sx,sy = guiGetScreenSize();--1920,1080 local relx,rely = sx/1920,sy/1080; ----------- IsCardShop = false local money = getPlayerMoney(localPlayer) local Cardlist = { [1] = {411, "Jogosítvány", 1000}, [2] = {482, "Jogosítvány", 10000}, }; color = tocolor(255, 0, 0, 255) ----------- function Panel() if IsCardShop == true then dxDrawRectangle(sx*.35, sy*.35, sx*.30, sy*.05, tocolor(0, 0, 0, 200))--Fejléc dxDrawText("Jogosítvány", sx*.50, sy*.035, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawRectangle(sx*.35, sy*.40, sx*.30, sy*.20, tocolor(30, 40, 50, 250))-- panel dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color)--gomb1 dxDrawText("Megvétel", sx*.36, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Legális 1000$", sx*.36, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawRectangle(sx*0.55, sy*0.47, sx*0.06, sy*0.05, color2 or color)--gomb1 dxDrawText("Megvétel", sx*.66, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Ilegális 10000$", sx*.66, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Összeged: "..money.."$", sx*.52, sy*.40, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat ----------- function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end ----------- if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then color1 = tocolor(88, 0, 0, 50) else color1 = color end ----------- if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then color2 = tocolor(88, 0, 0, 50) else color2 = color end end end ----------- function OpenWindow() IsCardShop = not IsCardShop if removeEventHandler("onClientRender", root, Panel) then removeEventHandler("onClientRender", root, Panel) showCursor(false) else addEventHandler("onClientRender", root, Panel) showCursor(true) end end bindKey("F3", "down", OpenWindow) try this Link to comment
Firespider Posted July 31, 2022 Author Share Posted July 31, 2022 It is not necessary to solve the problem of opening it by pressing the F3 button, but how to calculate the Cy Cx value. And if it is there, the button will light up when you move the cursor over it. Link to comment
Mr.Hugin Posted July 31, 2022 Share Posted July 31, 2022 40 minutes ago, Firespider said: It is not necessary to solve the problem of opening it by pressing the F3 button, but how to calculate the Cy Cx value. And if it is there, the button will light up when you move the cursor over it. Yes, you do not have to open a panel, but now you have the buttons that light up. Try this and you will know for yourself Link to comment
Firespider Posted July 31, 2022 Author Share Posted July 31, 2022 Okay, just like that, it won't go away with Ped. Ok, so it won't open with Ped.* I wrote sorry. Link to comment
Mr.Hugin Posted July 31, 2022 Share Posted July 31, 2022 19 minutes ago, Firespider said: I wrote it, sorry* not a problem Link to comment
Firespider Posted July 31, 2022 Author Share Posted July 31, 2022 Is it possible to open it with an NPC in the same way? Link to comment
Mr.Hugin Posted July 31, 2022 Share Posted July 31, 2022 39 minutes ago, Firespider said: Is it possible to open it with an NPC in the same way? I do not understand what you're saying Link to comment
Firespider Posted July 31, 2022 Author Share Posted July 31, 2022 I mean that if the player clicks on a ped, the menu opens like in my code, this is possible with this code. Link to comment
Mr.Hugin Posted July 31, 2022 Share Posted July 31, 2022 27 minutes ago, Firespider said: I mean that if the player clicks on a ped, the menu opens like in my code, this is possible with this code. You mean when I play, he presses the button, a panel appears Link to comment
Firespider Posted July 31, 2022 Author Share Posted July 31, 2022 No, you know, the pads are included in the game and if you click on them, the panel will appear addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) if (button == "right") and (state == "up") then IsCardShop = true--- end end) That's what I mean Is this also possible with the new code? So I don't mean that if a button is pressed, the panel opens, but if a player clicks on a Ped, the panel opens. Anyway, thanks for the code you sent, I'll try it later. and if everything is true, I have already solved the ped thing Link to comment
roaddog Posted August 1, 2022 Share Posted August 1, 2022 7 hours ago, Firespider said: No, you know, the pads are included in the game and if you click on them, the panel will appear addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) if (button == "right") and (state == "up") then IsCardShop = true--- end end) That's what I mean Is this also possible with the new code? So I don't mean that if a button is pressed, the panel opens, but if a player clicks on a Ped, the panel opens. Anyway, thanks for the code you sent, I'll try it later. and if everything is true, I have already solved the ped thing local thePed = createPed(0, x, y, z) addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) if (button == "right") and (state == "up") then if isElement(clickedWorld) and clickedWorld == thePed then IsCardShop = not IsCardShop removeEventHandler("onClientRender", root, Panel) if IsCardShop then addEventHandler("onClientRender", root, Panel) end end end end) here Link to comment
#\_oskar_/# Posted August 1, 2022 Share Posted August 1, 2022 you must use this to calculate the distance getDistanceBetweenPoints3D Link to comment
Firespider Posted August 1, 2022 Author Share Posted August 1, 2022 And how can I make it function as a button, because I guess it doesn't work with my old method Link to comment
Firespider Posted August 1, 2022 Author Share Posted August 1, 2022 I wrote this, but something doesn't work with then, it says an error code Link to comment
Mr.Hugin Posted August 1, 2022 Share Posted August 1, 2022 2 hours ago, Firespider said: I wrote this, but something doesn't work with then, it says an error code addEventHandler("onClientClick", root, function(button,state) if IsCardShop then if ( button == "left" and state == "down" ) then if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then end end end end) try this There is something that, if it is not there, may not work function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end Link to comment
Mr.Hugin Posted August 1, 2022 Share Posted August 1, 2022 It must be available to turn on the button or press the divorce Take this as a rule in the DX. If this is not available, the button will not work in any case function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end -------------- addEventHandler("onClientClick", root, function(button,state) if IsCardShop then if ( button == "left" and state == "down" ) then if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then end end end end) It should be like this try this 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