Jump to content

Weapon inventory


-.Paradox.-

Recommended Posts

Posted

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) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

And what is the problem exactly?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

The gui dont want to open i can see only cursor

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Working thanks, but it show a big tab and i want only small one and thanks again. :)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Well, you must change the position of it, I added to center it just for test.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

And is working fine?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes it's working but the tab is on all the screen, still the same problem, shall i remove center?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Well, that function only centers it, it doesn't resize it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

So how can i fix it?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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