Firespider Posted September 4, 2022 Share Posted September 4, 2022 Why doesn't the button light up when you move the mouse over it? And if they click on him, why doesn't he take the money if he has enough. local sx,sy = guiGetScreenSize();--1920,1080 local relx,rely = sx/1920,sy/1080; local isCardShop = false local money = getPlayerMoney(localPlayer) local Cardlist = { [1] = {411, "Cég1", 100}, }; color = tocolor(41, 173, 21, 255) addEventHandler("onClientRender", root, function() if (isCardShop) then ---Rajz dxDrawRectangle(sx*.25, sy*.20, sx*.50, sy*.05, tocolor(0, 0, 0, 200))--Fejléc dxDrawRectangle(sx*.250, sy*.25, sx*.50, sy*.7, tocolor(30, 40, 50, 200))--Menű dxDrawRectangle(sx*.450, sy*.50, sx*.10, sy*.07, color1 or color)--Gomb ---Feliratok dxDrawText("Cég menű", sx*.50, sy*.090, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Cégek:", sx*.50, sy*.20, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Kamionos cég", sx*.50, sy*.25, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Kamionos cég", sx*.50, sy*.70, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("50000$", sx*.50, sy*.75, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat end end ); bindKey("F5","down",function() if isCardShop == true then isCardShop = false else 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 ---------- if isMouseInPosition(sx*.450, sy*.50, sx*.10, sy*.07) then color1 = tocolor(88, 0, 0, 50) else color1 = color 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) ---------- addEventHandler("onClientClick", root, function(button,state) if isCardShop == true then if ( button == "left" and state == "down" ) then if isMouseInPosition(sx*.450, sy*.50, sx*.10, sy*.07) then local yourMoney = getPlayerMoney() if ( yourMoney <= 100) then takePlayerMoney(100) else outputChatBox("Nincs elég pénzed",255,0,0,true) --outputChatBox("Menj be a Markerbe a vizsga elkezdéséhez") end end end end end) ---------- Link to comment
markenic Posted September 5, 2022 Share Posted September 5, 2022 Where is your isMouseInPosition function? You need to put this code if isMouseInPosition(sx*.450, sy*.50, sx*.10, sy*.07) then color1 = tocolor(88, 0, 0, 50) else color1 = color end into the render above the rectangles Link to comment
Firespider Posted September 5, 2022 Author Share Posted September 5, 2022 He already solved that For some reason, he won't take money even if he has enough. Link to comment
Spakye Posted September 6, 2022 Share Posted September 6, 2022 if ( yourMoney >= 100) Link to comment
Firespider Posted September 6, 2022 Author Share Posted September 6, 2022 Doesn't working Link to comment
AngelAlpha Posted September 7, 2022 Share Posted September 7, 2022 22 hours ago, Firespider said: Doesn't working local sx,sy = guiGetScreenSize();--1920,1080 local relx,rely = sx/1920,sy/1080; local isCardShop = false local money = getPlayerMoney(localPlayer) local Cardlist = { [1] = {411, "Cég1", 100}, }; color = tocolor(41, 173, 21, 255) addEventHandler("onClientRender", root, function() if (isCardShop) then if isMouseInPosition(sx*.450, sy*.50, sx*.10, sy*.07) then color1 = tocolor(88, 0, 0, 50) else color1 = color end ---Rajz dxDrawRectangle(sx*.25, sy*.20, sx*.50, sy*.05, tocolor(0, 0, 0, 200))--Fejléc dxDrawRectangle(sx*.250, sy*.25, sx*.50, sy*.7, tocolor(30, 40, 50, 200))--Menű dxDrawRectangle(sx*.450, sy*.50, sx*.10, sy*.07, color1 or color)--Gomb ---Feliratok dxDrawText("Cég menű", sx*.50, sy*.090, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Cégek:", sx*.50, sy*.20, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Kamionos cég", sx*.50, sy*.25, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("Kamionos cég", sx*.50, sy*.70, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat dxDrawText("50000$", sx*.50, sy*.75, sx*.50, sy*.36, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat end end ); bindKey("F5","down",function() if isCardShop == true then isCardShop = false else 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 ----------- 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) ---------- addEventHandler("onClientClick", root, function(button,state) if isCardShop == true then if ( button == "left" and state == "down" ) then if isMouseInPosition(sx*.450, sy*.50, sx*.10, sy*.07) then local yourMoney = getPlayerMoney() if ( yourMoney <= 100) then --takePlayerMoney(100) triggerServerEvent ("takeMoney", resourceRoot, 100) else outputChatBox("Nincs elég pénzed",255,0,0,true) --outputChatBox("Menj be a Markerbe a vizsga elkezdéséhez") end end end end end) Server-side addEvent ("takeMoney", true) addEventHandler("takeMoney", resourceRoot, function(money) takePlayerMoney(client, money) end) Link to comment
Firespider Posted September 7, 2022 Author Share Posted September 7, 2022 Doesn't working Link to comment
AngelAlpha Posted September 7, 2022 Share Posted September 7, 2022 (edited) 1 hour ago, Firespider said: Doesn't working addEventHandler("onClientClick", root, function(button,state) if isCardShop == true then if ( button == "left" and state == "down" ) then if isMouseInPosition(sx*.450, sy*.50, sx*.10, sy*.07) then local yourMoney = getPlayerMoney() if ( yourMoney >= 100) then --takePlayerMoney(100) triggerServerEvent ("takeMoney", resourceRoot, 100) else outputChatBox("Nincs elég pénzed",255,0,0,true) --outputChatBox("Menj be a Markerbe a vizsga elkezdéséhez") end end end end end) Change this code Edited September 7, 2022 by AngelAlpha Link to comment
Firespider Posted September 7, 2022 Author Share Posted September 7, 2022 Isn't that the code? 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