sheenidgs Posted April 28, 2013 Share Posted April 28, 2013 Hi... I have a new problem with GUI (before case I've solved my problem) <- skip this This is my full code client.lua GUIEditor = { tab = {}, staticimage = {}, edit = {}, window = {}, tabpanel = {}, button = {}, label = {}, gridlist = {}, memo = {} } weaponShop = { } addEventHandler("onClientResourceStart", resourceRoot, function() local shopElements = getElementsByType ( "weapon" , getResourceRootElement() ) local num = 1 for k,v in ipairs(shopElements) do weaponShop[num] = { } weaponShop[num].ID = getElementData ( v, "id" ) weaponShop[num].Name = getElementData ( v, "name" ) weaponShop[num].Price = getElementData ( v, "price" ) weaponShop[num].WeaponID = getElementData ( v, "weaponid" ) weaponShop[num].Slot = getElementData ( v, "slot" ) weaponShop[num].PerClip = getElementData ( v, "perclip" ) weaponShop[num].PriceClip = getElementData ( v, "priceclip" ) local weapon = tonumber ( weaponShop[num].WeaponID ) weaponShop[num].WeaponRange = getWeaponProperty ( weapon, "pro", "weapon_range" ) weaponShop[num].TargetRange = getWeaponProperty ( weapon, "pro", "target_range" ) weaponShop[num].Damage = getWeaponProperty ( weapon, "pro", "damage" ) weaponShop[num].Accuracy = getWeaponProperty ( weapon, "pro", "accuracy" ) weaponShop[num].FiringSpeed = getWeaponProperty ( weapon, "pro", "firing_speed" ) weaponShop[num].WeaponSlot = getWeaponProperty ( weapon, "pro", "weapon_slot" ) num = num + 1 end GUIEditor.window[1] = guiCreateWindow(377, 185, 667, 313, "Ammu-Nation", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 22, 648, 281, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Weapon & Ammo", GUIEditor.tabpanel[1]) GUIEditor.gridlist[1] = guiCreateGridList(7, 7, 150, 155, false, GUIEditor.tab[1]) local column = guiGridListAddColumn(GUIEditor.gridlist[1], "Weapon", 0.9) local number = table.maxn ( weaponShop ) local iter = 1 for count = iter, number, 1 do local row = guiGridListAddRow(GUIEditor.gridlist[1]) local getname = tostring ( weaponShop[count].Name ) guiGridListSetItemText(GUIEditor.gridlist[1], row, column, "".. getname .."", false, false) end GUIEditor.staticimage[1] = guiCreateStaticImage(187, 59, 64, 64, "images/UNKNOWN.png", false, GUIEditor.tab[1]) GUIEditor.label[1] = guiCreateLabel(289, 9, 282, 15, "Weapon Name:", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(309, 24, 282, 15, "Weapon ID:", false, GUIEditor.tab[1]) GUIEditor.label[3] = guiCreateLabel(350, 39, 282, 15, "Slot:", false, GUIEditor.tab[1]) GUIEditor.label[4] = guiCreateLabel(293, 54, 282, 15, "Ammo per Clip:", false, GUIEditor.tab[1]) GUIEditor.label[5] = guiCreateLabel(289, 69, 282, 15, "Weapon Range:", false, GUIEditor.tab[1]) GUIEditor.label[6] = guiCreateLabel(299, 84, 282, 15, "Target Range:", false, GUIEditor.tab[1]) GUIEditor.label[7] = guiCreateLabel(330, 99, 282, 15, "Damage:", false, GUIEditor.tab[1]) GUIEditor.label[8] = guiCreateLabel(325, 114, 282, 15, "Accuracy:", false, GUIEditor.tab[1]) GUIEditor.label[9] = guiCreateLabel(307, 129, 282, 15, "Firing Speed:", false, GUIEditor.tab[1]) GUIEditor.label[10] = guiCreateLabel(349, 144, 282, 15, "Price: $", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(491, 215, 150, 31, "Buy", false, GUIEditor.tab[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") GUIEditor.button[2] = guiCreateButton(7, 215, 150, 31, "Armor: $250", false, GUIEditor.tab[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") GUIEditor.label[11] = guiCreateLabel(311, 159, 282, 15, "Ammo Price: $ per clip", false, GUIEditor.tab[1]) GUIEditor.label[12] = guiCreateLabel(174, 221, 172, 15, "How many clips do you want ?", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(349, 215, 60, 27, "", false, GUIEditor.tab[1]) guiEditSetMaxLength(GUIEditor.edit[1], 2) GUIEditor.label[13] = guiCreateLabel(490, 186, 148, 15, "Total: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("About", GUIEditor.tabpanel[1]) GUIEditor.memo[1] = guiCreateMemo(9, 7, 633, 244, "Dibuat oleh: Rachmad Setiawan\nPenggunaan:\n\n- Klik senjata yang ingin dibeli.\n- Masukkan jumlah klip peluru yang ingin dibeli\n- Klik buy untuk membeli\n\nNB:\n* Pastikan jumlah uang mencukupi\n* Klik armor jika ingin membeli armor\n* Anda harus membayar senjatanya kalau sebelumnya tidak mempunyai senjata yang Anda ingin beli", false, GUIEditor.tab[2]) guiMemoSetReadOnly(GUIEditor.memo[1], true) end ) function updateWeaponShop ( row ) local num = row + 1 guiStaticImageLoadImage ( GUIEditor.staticimage[1], "images/" .. tostring ( weaponShop[num].ID ) .. ".png" ) guiSetText ( GUIEditor.label[1], "Weapon Name: " .. tostring ( weaponShop[num].WeaponName ) .. "" ) guiSetText ( GUIEditor.label[2], "Weapon ID: " .. tostring ( weaponShop[num].WeaponID ) .. "" ) guiSetText ( GUIEditor.label[3], "Slot: " .. tostring ( weaponShop[num].Slot ) .. "" ) guiSetText ( GUIEditor.label[4], "Ammo per Clip: " .. tostring ( weaponShop[num].PerClip ) .. "" ) guiSetText ( GUIEditor.label[5], "Weapon Range: " .. tostring ( weaponShop[num].WeaponRange ) .. "" ) guiSetText ( GUIEditor.label[6], "Target Range: " .. tostring ( weaponShop[num].TargetRange ) .. "" ) guiSetText ( GUIEditor.label[7], "Damage: " .. tostring ( weaponShop[num].Damage ) .. "" ) guiSetText ( GUIEditor.label[8], "Accuracy: " .. tostring ( weaponShop[num].Accuracy ) .. "" ) guiSetText ( GUIEditor.label[9], "Firing Speed: " .. tostring ( weaponShop[num].FiringSpeed ) .. "" ) guiSetText ( GUIEditor.label[10], "Price: $" .. tostring ( weaponShop[num].Price ) .. "" ) guiSetText ( GUIEditor.label[11], "Ammo Price: $" .. tostring ( weaponShop[num].PriceClip ) .. " per clip" ) if tonumber ( guiGetText ( GUIEditor.edit[1] ) ) > 0 then local input = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) local getslot = tonumber ( weaponShop[num].WeaponSlot ) if getPedTotalAmmo ( localPlayer, getslot ) > 0 then if getPedWeapon ( localPlayer, getslot) == weaponShop[num].WeaponID then return guiSetText ( GUIEditor.label[13], "Total: $" .. ( tonumber ( weaponShop[num].PriceClip ) * input ) .. "" ) end end guiSetText ( GUIEditor.label[13], "Total: $" .. ( weaponShop[num].Price + ( tonumber ( weaponShop[num].PriceClip ) * input ) ) .. "" ) else guiSetText ( GUIEditor.label[13], "Total: $" ) end end addEventHandler("onClientGUIClick", root, function () if source == GUIEditor.gridlist[1] then local row,column = guiGridListGetSelectedItem ( source ) updateWeaponShop ( row ) end end ) addEventHandler("onClientGUIChanged", root, function () if source == GUIEditor.edit[1] then updateWeaponShop ( row ) end end ) addCommandHandler ( "Control Weapon Panel", function () guiGridListSetSelectedItem ( GUIEditor.gridlist[1], 0, 0 ) guiSetVisible ( GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) guiSetInputMode ( "no_binds_when_editing" ) guiSetText ( GUIEditor.edit[1], "" ) end ) bindKey ( "n", "down", "Control Weapon Panel" ) And this is my error from clientscript.log [2013-04-28 23:17:17] WARNING: weaponshop\client.lua:88: Bad argument @ 'guiStaticImageLoadImage' [Expected gui-element at argument 1, got nil] Link to comment
Fabio(GNR) Posted April 28, 2013 Share Posted April 28, 2013 GUIEditor.staticimage[1] = guiCreateStaticImage(187, 59, 64, 64, "images/UNKNOWN.png", false, GUIEditor.tab[1]) my guess is that that fails, make sure the image exists and is noted in meta.xml Link to comment
Tete omar Posted April 28, 2013 Share Posted April 28, 2013 I think you need to recheck your image formation, because sometimes i get this problem. Link to comment
sheenidgs Posted April 28, 2013 Author Share Posted April 28, 2013 GUIEditor.staticimage[1] = guiCreateStaticImage(187, 59, 64, 64, "images/UNKNOWN.png", false, GUIEditor.tab[1]) my guess is that that fails, make sure the image exists and is noted in meta.xml I think you need to recheck your image formation, because sometimes i get this problem. Oh man... It's my fault. You're right about the meta hehe.... Thanks for help me 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