Jump to content

Can anyone help me get this bug out of my inventory? When do I activate the tab


lima

Recommended Posts

local rx, ry = 229, 225
local render = dxCreateRenderTarget(rx,ry,true)
local sx, sy = guiGetScreenSize();

local color = tocolor(255, 255, 255, 255)


local cx,cy = 600, 363
local rx,ry = 234, 225

-----------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------
local font = dxCreateFont("assets/fonts/regular.ttf", 8)
------------------------------------------------------------------------------------------

local selected = nil;
local slots = {}
Itens = {}
select = 0
itemSelect = false
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


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()
    local pesoAtual = math.floor((getElementData(localPlayer, "pesoInv") or 0))
    local pesoMax = (getElementData(localPlayer, "pesoMax") or 30)

    dxDrawImage(499, 254, 418, 436, "assets/img/base.png");

    dxDrawImageSection(558, 560, (307/pesoMax*pesoAtual), 74, 0, 0, (307/pesoMax*pesoAtual), 78, "assets/img/pesoBar.png")

if isMouseInPosition(735, 300, 135, 92) then 
   dxDrawImage(735, 300, 135, 92, "assets/img/button_effect.png") 
else  
   dxDrawImage(735, 300, 135, 92, "assets/img/button.png") 
end

if isMouseInPosition(548, 368, 25, 30)  or aba == 1 then 
    dxDrawImage(548, 368, 25, 30, "assets/img/privado.png",0, 0, 0, tocolor(0,191,255,255))
else
    dxDrawImage(548, 368, 25, 30, "assets/img/privado.png",0, 0, 0, tocolor(255,255,255,255))    
end

if isMouseInPosition(545, 420, 32, 25) or aba == 2 then
   dxDrawImage(545, 420, 32, 25, "assets/img/ilegal.png",0, 0, 0, tocolor(0,191,255,255));
else
   dxDrawImage(545, 420, 32, 23, "assets/img/ilegal.png",0, 0, 0, tocolor(255,255,255,255))
end
    
if isMouseInPosition(545, 465, 30, 30) or aba == 3 then
    dxDrawImage(545, 465, 30, 30, "assets/img/tools.png",0, 0, 0, tocolor(0,191,255,255))
else
    dxDrawImage(545, 465, 30, 30, "assets/img/tools.png",0, 0, 0, tocolor(255,255,255,255))
end

dxDrawText("DROPAR",1469, 674, 138, 22, nil, 1, "Default", 'center', 'center')
dxDrawText(pesoAtual.."/"..pesoMax.."", 805, 516, 820, 692, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
dxDrawText("Quantidade", 448, 514, 820, 692, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)

    

    --dxDrawRectangle(600, 363, 229, 225, tocolor(24, 30, 40,135))

    
     --dxDrawImage(876, 254, 424, 436, "assets/img/base1.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))
            

local x,y = 5,5
slots = {}
      
    dxSetRenderTarget(render, true);


    for i, v in ipairs(Itens) do
        iprint(Itens)
           if aba == tonumber(v[6]) then
             if (selected ~= tonumber(v[5])) then

            if i == selected then
                dxDrawImage(x-4, y-4 ,52, 53, "assets/img/slot-effect.png") else dxDrawRectangle(x-4, y-4 ,52, 53, color) end
               
                table.insert(slots, {x-4, y-4, 52, 53})

                dxDrawImage(x-2, y+4, 48, 45,"assets/itens/"..v[1]..".png")

                --dxDrawText("x"..formatNumber(v[3]),x*2 +22,y*2 +32, 52, 53, tocolor(255, 255, 255, 127), 1.00, font, "center", "center", false, false, false, false, false)
                

                x = x + 52 + 5;
                if x >= 321 then
                x = 5;
                y = y + 53 + 4;

                end
               
            end
   -- iprint(slots)

           
        dxSetRenderTarget();

        dxDrawImage( cx,cy,rx,ry, render);

        --dxDrawImage( 980, 363, 231, 225, render2);
        end
     end
  end 
end 
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function hotBar()
    if not getElementData(localPlayer, "BloqHud") then
        dxDrawImage(506, 790, 430, 125, "assets/img/base2.png")
        for i, v in ipairs(slots) do
            if (i <= 6 and getKeyState(i)) then
                dxDrawImage(v[1], v[2], v[3], v[4], "assets/slot-effect.png")
            end
            if v.item then
                dxDrawImage(v[1]+3, v[2]+50, v[3], v[4], "assets/itens/"..(v.item)..".png")
            end
        end
    end
end
addEventHandler("onClientRender", root, hotBar)
-------------------------------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------------------------------------------------------

addEventHandler("onClientClick", root,
function (b, s)
           if s == "down" and b == "left" then
            
            if isEventHandlerAdded("onClientRender", root, Inv) then
            selected = false
           
            if (isMouseInPosition(548, 368, 25, 30) and not page) then
                aba = 1
                dxDrawText("DROPAR",1469, 674, 138, 22, nil, 1, "Default", 'center', 'center')
                return
            end

            if (isMouseInPosition(545, 420, 32, 25) and not page) then
                aba = 2
                return
            end
  
            if (isMouseInPosition(545, 465, 30, 30) and not page) then
                aba = 3
                return
            end

            if isMouseInPosition(cx,cy,rx,ry) then
             for i,v in ipairs(slots) do
                if isMouseInPosition(v[1]+cx, v[2]+cy, v[3], v[4]) and aba and select ~= 0 and not page then 
                    selected = i
                    playSound("assets/sfx/release.mp3")
                    return
                  end
              end

            if isMouseInPosition(735, 300, 135, 92) then
                        if Itens[selected].id >= tonumber(item) and takeItem (player, item, quantia) then

                           triggerServerEvent("droparItem", localPlayer, localPlayer, Itens[selected][1], qntUse, Itens[selected][6], Itens[selected])
                              selected = i
                              playSound("assets/sfx/release.mp3")
                             return
            
                        end
                     end
                  end
               end
            end
    end)

---------------------------------------------------------------------------------------------------------------------------------------------------------------
function Click2( b )
           if b == "left" then 
            if isMouseInPosition(cx,cy,rx,ry) then
                for i, v in ipairs(Itens) do
                    if isMouseInPosition(v[1]+cx, v[2]+cy, v[3], v[4]) and select ~= 0 then
                        triggerServerEvent("useItem", player, config['Itens'][item[selected].id].nome,  item[selected].id)
                        select = v[5]
                        selected = i
                        return
                    end
                end
            end
        end
    end
addEventHandler("onClientDoubleClick", root, Click2)
---------------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------
addEvent("inserirItem", true)
addEventHandler("inserirItem", root,
function(tabela)
    Itens = {}
    for i, v in ipairs(tabela) do
       -- iprint(tabela)
        Itens = {v.itemID, v.nameItem, v.qnt,tonumber(v.slots), v.dataItem,v.category}
    end
end)


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)

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

 

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...