Jump to content

Weapon inventory


-.Paradox.-

Recommended Posts

Hello, i was searching in forum about a weapon inventory, and i found this, but i don't know why it doesnt work, here is the code thanks.

  
local player = getLocalPlayer() 
tab = guiCreateTabPanel(429, 151, 430, 404, true) 
tab_inventory = guiCreateTab("Weapon:", tab) 
inventory_gridlist = guiCreateGridList (0.03, 0.03, 0.46, 0.94, true, tab_inventory) 
weapSlots = guiGridListAddColumn(inventory_gridlist, "slots", 0.9) 
  
function weapItemInInventory ( ) 
    if ( weapSlots ) then 
        for slot = 1, 12 do 
            local weapon = getPedWeapon ( localPlayer, slot ) 
            if ( weapon > 0 ) then 
                local row = guiGridListAddRow ( inventory_gridlist ) 
                guiGridListSetItemText ( inventory_gridlist, row, weapSlots, getWeaponNameFromID ( weapon ), false, false ) 
            end 
        end 
    end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), weapItemInInventory ) 
  
setTimer ( function ( ) 
    guiGridListClear ( inventory_gridlist ) 
    weapItemInInventory ( ) 
end, 5000, 0 ) 
  
function enableInv() 
    if guiGetVisible(tab) == false then 
        guiSetVisible(tab, true) 
        showCursor(true) 
    else 
        guiSetVisible(tab, false) 
        showCursor(false) 
    end 
end 
bindKey("B","down", enableInv) 

Link to comment

Looks like it's a position problem, since I've centered it using a function and the tab panel shown up.

local sx, sy = guiGetScreenSize ( ) 
  
function centerGUI ( guiElement ) 
    local width, height = guiGetSize ( guiElement, false ) 
    local x, y = ( sx / 2 - width / 2 ), ( sy / 2 - height / 2 ) 
    guiSetPosition ( guiElement, x, y, false ) 
end 
  
tab = guiCreateTabPanel(429, 151, 430, 404, true) 
guiSetVisible ( tab, false ) 
centerGUI ( tab ) 
tab_inventory = guiCreateTab("Weapon:", tab) 
inventory_gridlist = guiCreateGridList (0.03, 0.03, 0.46, 0.94, true, tab_inventory) 
weapSlots = guiGridListAddColumn(inventory_gridlist, "slots", 0.9) 
   
function weapItemInInventory ( ) 
    if ( weapSlots ) then 
        for slot = 1, 12 do 
            local weapon = getPedWeapon ( localPlayer, slot ) 
            if ( weapon > 0 ) then 
                local row = guiGridListAddRow ( inventory_gridlist ) 
                guiGridListSetItemText ( inventory_gridlist, row, weapSlots, getWeaponNameFromID ( weapon ), false, false ) 
            end 
        end 
    end 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), weapItemInInventory ) 
  
setTimer ( function ( ) 
    guiGridListClear ( inventory_gridlist ) 
    weapItemInInventory ( ) 
end, 5000, 0 ) 
  
function enableInv ( ) 
    local state = ( not guiGetVisible ( tab ) ) 
    guiSetVisible(tab, state) 
    showCursor ( state ) 
end 
bindKey ( "B", "down", enableInv ) 

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...