lima Posted October 11, 2023 Share Posted October 11, 2023 my code : dxDrawRectangle(x-4, y-4 -sroll,52, 53, i == selected and dxDrawImage(x-4, y-4 -sroll,52, 53,"assets/img/slot-effect.png") or scrollColor) error : Bad argument @ 'dxDrawRectangle' [expected number at argument 5 , got boolean] Link to comment
Hydra Posted October 11, 2023 Share Posted October 11, 2023 15 minutes ago, lima said: my code : dxDrawRectangle(x-4, y-4 -sroll,52, 53, i == selected and dxDrawImage(x-4, y-4 -sroll,52, 53,"assets/img/slot-effect.png") or scrollColor) error : Bad argument @ 'dxDrawRectangle' [expected number at argument 5 , got boolean] Almost nothing you posted can be understood. The correct way to use dxDrawRectangle and dxDrawImage is: dxDrawRectangle(posX, posY, width, height, color, postGUI) dxDrawImage(posX, posY, width, height, imagePath, rotationX, rotationY, rotationZ, color, postGUI) Link to comment
lima Posted October 11, 2023 Author Share Posted October 11, 2023 34 minutes ago, Hydra said: Quase nada do que você postou pode ser entendido. A maneira correta de usar dxDrawRectangle e dxDrawImage é: because this code is inside the render. Link to comment
Hydra Posted October 11, 2023 Share Posted October 11, 2023 (edited) 29 minutes ago, lima said: because this code is inside the render. Even if it's inside a render you are using it wrong. You have dxDrawRectangle(x-4, y-4 -sroll,52, 53, i == selected and dxDrawImage(x-4, y-4 -sroll,52, 53,"assets/img/slot-effect.png") or scrollColor). Calling dxDrawImage inside dxDrawRectangle it is not possible according to my experience and that is why you have errors in your code. But wait for more answers maybe there are people that disagree with me. My advice is to use them separate, I hope you understood what I was talking Edited October 11, 2023 by Hydra Link to comment
lima Posted October 11, 2023 Author Share Posted October 11, 2023 So give me a tip on how to use both within the render and when selecting the rectangle activate the effect image?! Link to comment
Hydra Posted October 11, 2023 Share Posted October 11, 2023 Just now, lima said: So give me a tip on how to use both within the render and when selecting the rectangle activate the effect image?! Leave the full code because with only what you gave I can't test it. Link to comment
lima Posted October 11, 2023 Author Share Posted October 11, 2023 local rx, ry = 229, 225 local render = dxCreateRenderTarget(rx,ry,true) local x, y = guiGetScreenSize(); local selected = nil; local slots = {x, y ,52, 53} local cx, cy = (x/2) - (rx/2) - 50, (y/2) - (ry/2); local sroll = 0 local sroll1 = 0 local scrollColor = tocolor(24, 30, 40,155) local scrollColorS = tocolor(0,191,255,150) local maxScroll = 0; local maxScroll1 = 0 local peso = math.floor((getElementData(localPlayer, "peso") or 0)) ---------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------ function isMouseInPosition(x,y,w,h) if isCursorShowing() then local sx,sy = guiGetScreenSize() local cx,cy = getCursorPosition() local cx,cy = (cx*sx),(cy*sy) if (cx >= x and cx <= x+w) and (cy >= y and cy <= y+h) then return true end end end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- function Inv() dxDrawImage(488, 254, 424, 436, "assets/img/base.png"); dxDrawImageSection(543, 362, (352/peso*g_peso), 3, 0, 0, (352/peso*g_peso), 3, "assets/img/pesoBar.png") if render and isElement(render) then local element = localPlayer --dxDrawImage(0, 0, 1440, 900, "assets/img/base2.png"); dxDrawRectangle(829, 362 +sroll1, 3, 116,tocolor(0,191,255,150)) dxDrawRectangle( 829,362,52, 53, tocolor(24, 30, 40,155)) --dxDrawRectangle(594,297,249, 259, tocolor(24, 30, 40,25)) local Itens = getElementData(localPlayer, "mochila"); local peso = (getElementData(localPlayer, "peso") or config["Weight Template"]) local x,y= 5,5 slots = {} maxScroll = 0 maxScroll1 = 0 dxSetRenderTarget(render, true); --dxDrawRectangle(227, -1 +sroll, 8, 126,tocolor(0,191,255,150)) for i,v in ipairs(Itens) do dxDrawRectangle(x-4, y-4 -sroll,52, 53, i == selected and dxDrawImage(x-4, y-4 -sroll,52, 53, "assets/img/slot-effect.png") or scrollColor) table.insert(slots, {x-4, y-4, 52, 53}) dxDrawImage(x, y -sroll, 48, 45,"assets/itens/"..(v.id)..".png") x = x + 52 + 5; if x >= 229 then x = 5; y = y + 53 + 4; end end maxScroll = math.max(114, y -300) maxScroll1 = math.max(110, y -300) dxSetRenderTarget(); dxDrawImage( 600, 363, 231, 225, render); end if (isMouseInPosition(544, 376, 29, 35) and not manageEdits) or aba == 1 then dxDrawImage(544, 376, 29, 35, "assets/img/privado.png",0, 0, 0, tocolor(0,191,255,255)) -- dxDrawImage(810, 256, 80, 140, "assets/img/baseBar.png") --dxDrawText('Pessoal', 1597, 514, 30, 31, tocolor(255, 255, 255, 255), 1, fonts, 'center', 'center', false, false, false, false, false) else dxDrawImage(544, 376, 29, 35, "assets/img/privado.png",0, 0, 0, tocolor(255,255,255,255)) end if (isMouseInPosition(536, 434, 36, 36)and not manageEdits) or aba == 2 then dxDrawImage(536, 434, 36, 36, "assets/img/food.png",0, 0, 0, tocolor(0,191,255,255)) ---dxDrawImage(810, 325, 80, 140, "assets/img/baseBar.png") ---dxDrawImage(594,293, 60, 64, "assets/itens/agua.png") --dxDrawText('Alimentos', 1580, 514, 30, 31, tocolor(255, 255, 255, 255), 1, fonts, 'center', 'center', false, false, false, false, false) else dxDrawImage(536, 434, 36, 36, "assets/img/food.png",0, 0, 0, tocolor(255,255,255,255)) end if (isMouseInPosition(538, 495, 37, 26) and not manageEdits) or aba == 3 then dxDrawImage(538, 495, 37, 26, "assets/img/ilegal.png",0, 0, 0, tocolor(0,191,255,255)); --dxDrawImage(810, 389, 80, 140, "assets/img/baseBar.png") --dxDrawText('Ilegal', 1613, 514, 30, 31, tocolor(255, 255, 255, 255), 1, fonts, 'center', 'center', false, false, false, false, false) else dxDrawImage(538, 495, 37, 26, "assets/img/ilegal.png",0, 0, 0, tocolor(255,255,255,255)) end if (isMouseInPosition(538, 545, 36, 38) and not manageEdits) or aba == 4 then dxDrawImage(538, 545, 36, 38, "assets/img/tools.png",0, 0, 0, tocolor(0,191,255,255)) --dxDrawImage(810, 455, 80, 140, "assets/img/baseBar.png") --dxDrawText('Ferramentas', 1560, 514, 30, 31, tocolor(255, 255, 255, 255), 1, fonts, 'center', 'center', false, false, false, false, false) else dxDrawImage(538, 545, 36, 38, "assets/img/tools.png",0, 0, 0, tocolor(255,255,255,255)) end end --------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------- function ScrollRoler(b, p) if p then if isMouseInPosition(601, 367, 227, 228) then if b == 'mouse_wheel_up' then sroll = math.max(0, sroll - 50) elseif b == "mouse_wheel_down" then sroll = math.min(maxScroll, sroll + 50) end end end end addEventHandler("onClientKey", root, ScrollRoler) function ScrollR(b,p) if p then if isMouseInPosition(601, 367, 227, 228) then if b == 'mouse_wheel_up' then sroll1 = math.max(0, sroll - 70) elseif b == "mouse_wheel_down" then sroll1 = math.min(maxScroll1, sroll1 + 70) end end end end addEventHandler("onClientKey", root, ScrollR) addEventHandler("onClientClick", root, function (b, s) if s == "down" and b == "left" then if isEventHandlerAdded("onClientRender", root, Inv) then select = false if (isMouseInPosition(544, 376, 29, 35) and not manageEdits) then aba = 1 return end if (isMouseInPosition(536, 434, 36, 36) and not manageEdits) then aba = 2 return end if (isMouseInPosition(538, 495, 37, 26) and not manageEdits) then aba = 3 return end if (isMouseInPosition(538, 545, 36, 38) and not manageEdits) then aba = 4 return end if manageEdits then if isMouseInPosition(544, 376, 29, 35) then aba = 1 return end if isMouseInPosition(536, 434, 36, 36) then aba = 2 return end if isMouseInPosition(538, 495, 37, 26) then aba = 3 return end if isMouseInPosition(538, 545, 36, 38) then aba = 4 return end end end end if isMouseInPosition(601, 367, 227, 228) then for i,v in ipairs(slots) do if isMouseInPosition(v[1]+601,v[2]+367,v[3],v[4]) then selected = i end end elseif isMouseInPosition (829,362,52, 53) and selected then local dados = getElementData(localPlayer, "mochila") or {} usarItem(config.Itens[dados[selected].id].nome, dados[selected].id) end end) function Click2( b ) if b == "left" then for i,v in ipairs(slots) do if isMouseInPosition(v[1]+x,v[2]+y,v[3],v[4]) and selected == i then local dados = getElementData(localPlayer, "mochila"); usarItem(config.Itens[dados[selected].id].nome, dados[selected].id) itemSelect = true; end end end end addEventHandler("onClientDoubleClick", root, Click2) function openInv() if not isEventHandlerAdded("onClientRender", root, Inv) then addEventHandler("onClientRender", root, Inv) showCursor(true) selectSlot = false quantitySelect = 1 manageEdits = false select = false itemSelect = false subWindow = false aba = 1 else removeEventHandler("onClientRender", root, Inv) showCursor(false) end end addEvent("JOAO.openInv", true) addEventHandler("JOAO.openInv", root, openInv) bindKey("b", "down", openInv) addCommandHandler('item', function() GiveItem(localPlayer, 5, 1, true); end); function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == "string" and isElement( pElementAttachedTo ) and type( func ) == "function" then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == "table" and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end addCommandHandler('takeitem', function() TakeItem(localPlayer, 1, 1); end); addEvent("playSound", true) addEventHandler("playSound", resourceRoot, PlaySound) Link to comment
lima Posted October 11, 2023 Author Share Posted October 11, 2023 If you could, would you also be able to help me with this onClientDoubleclick function.. I can't find the position of the slot, and when I create a position, clicking on it doesn't give me the item in the inventory. Link to comment
Hydra Posted October 12, 2023 Share Posted October 12, 2023 You have a variable called g_peso, but it doesn't exist in your script. Also instead of dxDrawRectangle(x-4, y-4 -sroll,52, 53, i == selected and dxDrawImage(x-4, y-4 -sroll,52, 53, "assets/img/slot-effect.png") or scrollColor) Change in: dxDrawRectangle(x-4, y-4 -sroll,52, 53, tocolor(255, 255, 255, 255), false) dxDrawImage(x-4, y-4 -sroll,52, 53, "assets/img/slot-effect.png", 0, 0, 0, scrollColor, false) Furthermore, I can't help you with your script. From what I can see, it's not something you did and it's from a gamemode on the net, maybe I'm wrong but this is how I see it Link to comment
lima Posted October 12, 2023 Author Share Posted October 12, 2023 Brother, this script is mine.. I've been creating this for two weeks now.. The fact that the codes are broken doesn't mean I caught it.. I'm creating this inventory myself, I spend days and nights, late nights with my face on the computer trying to discover the right codes, reading content about the .lua language... so I came to tell you that this script I found on the internet... dxDrawRectangle(x-4, y-4 -sroll,52, 53, tocolor(255, 255, 255, 255), false) dxDrawImage(x-4, y-4 -sroll,52, 53, "assets/img/slot-effect.png", 0, 0, 0, scrollColor, false) and the function i == selected ?? Where does it fit in? pro effect slot be selected? because then it will give an error.. 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