iPanda Posted August 3, 2013 Share Posted August 3, 2013 wind = guiCreateWindow(X, Y, W, H, "", true) tab = guiCreateTabPanel(X, Y, W, H, true, wind) tab_inventory = guiCreateTab("Weapon", tab) inventory_gridlist = guiCreateGridList(X, Y, W, H, true, tab_inventory) guiGridListAddColumn(inventory_gridlist, "Weap:", 0.9) guiGridListAddRow(inventory_gridlist) guiGridListSetItemText(inventory_gridlist, 0, 1, "SLOTS!!!", false, false) "SLOTS!!!" - slots can be any weapon. That is, if a player has, say, a weapon M4, it is displayed it in the slot, and if it does not have these weapons, respectively, then it is not displayed in the slots. How to make this function? Two screenshot, which shows when the player has arms M4 or when it had not. Link to comment
iPanda Posted August 3, 2013 Author Share Posted August 3, 2013 Here, I wrote this code. But it does not work: local player = getLocalPlayer() kpk = guiCreateStaticImage(X, Y,W,H, "images/kpk.png", true) tab = guiCreateTabPanel(X, Y,W,H, true, kpk) tab_inventory = guiCreateTab("Weap:", tab) function weapItemInInventory ( ) local inventory_gridlist = guiCreateGridList (0.03, 0.03, 0.46, 0.94, true, tab_inventory) local weapSlots = guiGridListAddColumn(inventory_gridlist, "Оружие", 0.9) if ( weapSlots ) then for id, playeritem in ipairs(getElementModel(player,356)) do local row = guiGridListAddRow ( inventory_gridlist ) guiGridListSetItemText ( inventory_gridlist, row, weapSlots, getWeaponNameFromID ( playeritem ), false, false ) end end end addEventHandler ( "onClientResourceStart", getResourceRootElement(), weapItemInInventory ) Here, he writes debug: Also, I know that the error in this line. Can you help me fix it, because I understand that this is not right, but I do not know how to solve this problem correctly! for id, playeritem in ipairs(getElementModel(player,356)) do Link to comment
iMr.3a[Z]eF Posted August 3, 2013 Share Posted August 3, 2013 At line 56 replace this for id, playeritem in ipairs(getElementModel(player,356)) do with this. for id, playeritem in ipairs(getElementModel(player)) do Link to comment
Castillo Posted August 3, 2013 Share Posted August 3, 2013 getElementModel returns a number, not a table. Link to comment
iPanda Posted August 3, 2013 Author Share Posted August 3, 2013 getElementModel returns a number, not a table. What am I then use? Link to comment
Castillo Posted August 3, 2013 Share Posted August 3, 2013 What are you trying to do? Link to comment
xXMADEXx Posted August 3, 2013 Share Posted August 3, 2013 for id, playeritem in ipairs(getElementModel(player,356)) do You can use: for playeritem=1,46 do And it will return an id for all the weapons Link to comment
iPanda Posted August 4, 2013 Author Share Posted August 4, 2013 for id, playeritem in ipairs(getElementModel(player,356)) do You can use: for playeritem=1,46 do And it will return an id for all the weapons Thank you, your code works perfectly! But there is one konvuz, your code shows everything arms, even if the player does not have them. I need a code that will show only the weapons have a player at the moment. Link to comment
Castillo Posted August 4, 2013 Share Posted August 4, 2013 local player = getLocalPlayer() kpk = guiCreateStaticImage(X, Y,W,H, "images/kpk.png", true) tab = guiCreateTabPanel(X, Y,W,H, true, kpk) tab_inventory = guiCreateTab("Weap:", tab) function weapItemInInventory ( ) local inventory_gridlist = guiCreateGridList (0.03, 0.03, 0.46, 0.94, true, tab_inventory) local weapSlots = guiGridListAddColumn(inventory_gridlist, "??????", 0.9) 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 ) Link to comment
iPanda Posted August 4, 2013 Author Share Posted August 4, 2013 local player = getLocalPlayer() kpk = guiCreateStaticImage(X, Y,W,H, "images/kpk.png", true) tab = guiCreateTabPanel(X, Y,W,H, true, kpk) tab_inventory = guiCreateTab("Weap:", tab) function weapItemInInventory ( ) local inventory_gridlist = guiCreateGridList (0.03, 0.03, 0.46, 0.94, true, tab_inventory) local weapSlots = guiGridListAddColumn(inventory_gridlist, "??????", 0.9) 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 ) Thank you very much. But there is a small flaw. When my player gets a new weapon, it does not appear in my dashboard. Add onClientRender, or something otherwise? Link to comment
xXMADEXx Posted August 4, 2013 Share Posted August 4, 2013 Try this: local player = getLocalPlayer() kpk = guiCreateStaticImage(X, Y,W,H, "images/kpk.png", true) tab = guiCreateTabPanel(X, Y,W,H, true, kpk) tab_inventory = guiCreateTab("Weap:", tab) inventory_gridlist = guiCreateGridList (0.03, 0.03, 0.46, 0.94, true, tab_inventory) weapSlots = guiGridListAddColumn(inventory_gridlist, "??????", 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 ) 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