undefined Posted January 29, 2014 Share Posted January 29, 2014 (edited) Hi Guys. This script previously I did with"TabPanel" . I don't like the design for the changing. Images; But I have some problems. When I click on the melee, I want to appear only melee weapons. And I made a separate post for each weapon. Their "memo" I want you to look at. ...Sry to my bad English... Edited February 1, 2014 by Guest Link to comment
Bonsai Posted January 29, 2014 Share Posted January 29, 2014 Up! You want the weapons to be sorted into their categories? Guess u have to sort them first into a table and then just add the to the Main gridlist, but only the ones that fit to the selected item. And don't forget to clear the gridlist. Link to comment
undefined Posted January 29, 2014 Author Share Posted January 29, 2014 Up! You want the weapons to be sorted into their categories? Guess u have to sort them first into a table and then just add the to the Main gridlist, but only the ones that fit to the selected item. And don't forget to clear the gridlist. 1--> Yes 2--> Im a new scripter. I'm usually modeled scripts. Can you give examples of bi so? Link to comment
Bonsai Posted January 30, 2014 Share Posted January 30, 2014 UP! Whats still the problem? When a player selects a category, you just insert all the weapons into the main gridlist. When he changes to another category, you clear the gridlist and insert the weapons of the new category. Link to comment
undefined Posted January 30, 2014 Author Share Posted January 30, 2014 UP! Whats still the problem? When a player selects a category, you just insert all the weapons into the main gridlist. When he changes to another category, you clear the gridlist and insert the weapons of the new category. I'm new to scripter do not know much. Already in the old shop 'TabPanel than I did. I'm about to work so much simpler. Could you give me an example? Link to comment
undefined Posted January 30, 2014 Author Share Posted January 30, 2014 Post your code. I sent the code with pm Link to comment
Castillo Posted January 30, 2014 Share Posted January 30, 2014 I suggest you change the table formats to something like this: local items = { [ "Melee" ] = { -- Weapon, price { 4, 500 } }, [ "Handguns" ] = { { 22, 400 }, } } Link to comment
undefined Posted January 30, 2014 Author Share Posted January 30, 2014 I suggest you change the table formats to something like this: local items = { [ "Melee" ] = { -- Weapon, price { 4, 500 } }, [ "Handguns" ] = { { 22, 400 }, } } Oh thnx. But how to clear gridlist? Link to comment
undefined Posted January 30, 2014 Author Share Posted January 30, 2014 guiGridListClear local weapons = { [ "Melee" ] = {1,0,1},{5,0,1},{6,0,1},{8,0,1}, [ "Handguns" ] = {23,300,100},{22,400,100},{24,500,100}, [ "Shotguns" ] = {25,1000,100},{26,1500,100},{27,1700,100}, [ "Sub-Machine" ] = {28,2000,100},{32,2100,100},{29,2200,100}, [ "Machine Guns" ] = {30,2500,100},{31,3000,100}, [ "Rifles" ] = {33,3500,100},{34,5500,100}, [ "Projectiles" ] = {16,15000,15},{40 and 39,500,1},{46,0,1}} Nothing has changed. Yet in all 'gridlist'. And how to use guiGridListClear ? Link to comment
Castillo Posted January 30, 2014 Share Posted January 30, 2014 As I told you over PM, that's just the first part. And is not even right, it should be like this: local weapons = { [ "Melee" ] = { {1,0,1},{5,0,1},{6,0,1},{8,0,1} }, [ "Handguns" ] = { {23,300,100},{22,400,100},{24,500,100} }, [ "Shotguns" ] = { {25,1000,100},{26,1500,100},{27,1700,100} }, [ "Sub-Machine" ] = { {28,2000,100},{32,2100,100},{29,2200,100} }, [ "Machine Guns" ] = { {30,2500,100},{31,3000,100} }, [ "Rifles" ] = { {33,3500,100},{34,5500,100} }, [ "Projectiles" ] = { {16,15000,15},{39,500,1},{46,0,1} } } Link to comment
undefined Posted January 30, 2014 Author Share Posted January 30, 2014 As I told you over PM, that's just the first part. And is not even right, it should be like this: local weapons = { [ "Melee" ] = { {1,0,1},{5,0,1},{6,0,1},{8,0,1} }, [ "Handguns" ] = { {23,300,100},{22,400,100},{24,500,100} }, [ "Shotguns" ] = { {25,1000,100},{26,1500,100},{27,1700,100} }, [ "Sub-Machine" ] = { {28,2000,100},{32,2100,100},{29,2200,100} }, [ "Machine Guns" ] = { {30,2500,100},{31,3000,100} }, [ "Rifles" ] = { {33,3500,100},{34,5500,100} }, [ "Projectiles" ] = { {16,15000,15},{39,500,1},{46,0,1} } } I'm looking at the wiki page. I tried something but I could not. Please help me bro. Link to comment
Castillo Posted January 30, 2014 Share Posted January 30, 2014 -- client side: local items = { [ "Melee" ] = { {1,0,1},{5,0,1},{6,0,1},{8,0,1} }, [ "Handguns" ] = { {23,300,100},{22,400,100},{24,500,100} }, [ "Shotguns" ] = { {25,1000,100},{26,1500,100},{27,1700,100} }, [ "Sub-Machine" ] = { {28,2000,100},{32,2100,100},{29,2200,100} }, [ "Machine Guns" ] = { {30,2500,100},{31,3000,100} }, [ "Rifles" ] = { {33,3500,100},{34,5500,100} }, [ "Projectiles" ] = { {16,15000,15},{39,500,1},{46,0,1} }, [ "Skills" ] = { {"Colt-45 Skill",250,1,69},{"Silenced-Pistol Skill",250,1,70},{"Desert-Eagle Skill",250,1,71},{"Shotgun Skill",1000,1,72},{"Sawed-off Skill",1500,1,73},{"Spaz-12 Skill",1500,1,74},{"Uzi Skill",1500,1,75},{"MP5 Skill",1500,1,76},{"AK-47 Skill",1750,1,77},{"M4 Skill",2000,1,78},{"Sniper Skill",2000,1,79} }, [ "Health" ] = { } } shopWindow = guiCreateWindow(470, 206, 449, 326,"Shop Panel",false) guiSetVisible (shopWindow, false) guiSetAlpha(shopWindow,0.65) guiWindowSetSizable(shopWindow,false) itemsGrid = guiCreateGridList(134, 25, 305, 171,false,shopWindow) guiGridListSetSelectionMode(itemsGrid,0) guiGridListAddColumn(itemsGrid,"Name",0.4) guiGridListAddColumn(itemsGrid,"Price $",0.3) guiGridListAddColumn(itemsGrid,"Amount",0.2) gridCho = guiCreateGridList(12, 25, 116, 264, false, shopWindow) gridchoColumn = guiGridListAddColumn(gridCho,"Chose",0.85) guiGridListSetSelectionMode ( gridCho, 0 ) AboutMemo = guiCreateMemo(136, 204, 303, 85, "", false, shopWindow) guiSetAlpha(itemsGrid,1) buyItem = guiCreateButton(280, 297, 100, 20, "Buy Item",false,shopWindow) closeButton = guiCreateButton(400, 297, 37, 18, "X",false, shopWindow) for cat, data in pairs ( items ) do local row = guiGridListAddRow ( gridCho ) guiGridListSetItemText ( gridCho, row, 1, tostring ( cat ), false, true ) end addEventHandler ( "onClientGUIClick", guiRoot, function ( ) if ( source == closeButton ) then guiSetVisible ( shopWindow, false ) showCursor ( false ) elseif ( source == gridCho ) then local row, col = guiGridListGetSelectedItem ( source ) if ( row and col and row ~= -1 and col ~= -1 ) then local category = guiGridListGetItemText ( source, row, 1 ) guiGridListClear ( itemsGrid ) if ( items [ category ] ) then for _, item in ipairs ( items [ category ] ) do local row = guiGridListAddRow ( itemsGrid ) local name = ( category == "Skills" and item [ 1 ] or category == "Health" and item [ 1 ] or getWeaponNameFromID ( item [ 1 ] ) ) guiGridListSetItemText ( itemsGrid, row, 1, tostring ( name ), false, false ) guiGridListSetItemText ( itemsGrid, row, 2, tostring ( item [ 2 ] ), false, false ) guiGridListSetItemText ( itemsGrid, row, 3, tostring ( item [ 3 ] ), false, false ) guiGridListSetItemData ( itemsGrid, row, 1, item [ 4 ] ) guiGridListSetItemData ( itemsGrid, row, 2, category ) end end end elseif ( source == buyItem ) then local row, col = guiGridListGetSelectedItem ( itemsGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local category = guiGridListGetItemData ( itemsGrid, row, 2 ) local name = guiGridListGetItemText ( itemsGrid, row, 1 ) local price = guiGridListGetItemText ( itemsGrid, row, 2 ) local amount = guiGridListGetItemText ( itemsGrid, row, 3 ) if ( category == "Skills" ) then local id = guiGridListGetItemData ( itemsGrid, row, 1 ) triggerServerEvent ( "skillBuy", localPlayer, name, id, tonumber ( price ) ) elseif ( category == "Health" ) then -- TODO else triggerServerEvent ( "weapBuy", localPlayer, name, price, amount ) end end end end ) function viewGUI ( ) if ( localPlayer == source ) then guiSetVisible ( shopWindow, true ) showCursor ( true ) end end addEvent ( "viewGUI", true ) addEventHandler ( "viewGUI", getRootElement(), viewGUI ) -- server side: function showGui (hitPlayer, matchingDimension) triggerClientEvent ( hitPlayer, "viewGUI", hitPlayer) end ---------------------- Area 51 addEventHandler("onMarkerHit",createMarker(209.81819152832, 1859.4178466797, 12,"cylinder",2,187,5,175,170),showGui) local blip = createBlip(209.81819152832, 1859.4178466797, 150, 6, 0, 0, 0, 0, 0, 0, 1000) ---------------------- Sillent Killers addEventHandler("onMarkerHit",createMarker(-1379.8349609375, 493.78100585938, 20.200000762939,"cylinder",2,187,5,175,170),showGui) local blip = createBlip(-1379.8349609375, 493.78100585938, 20.200000762939, 6, 0, 0, 0, 0, 0, 0, 1000) ---------------------- Ghost Town addEventHandler("onMarkerHit",createMarker(3986.9541015625, -2089.8010253906, 34.1,"cylinder",2,187,5,175,170),showGui) local blip = createBlip(3986.9541015625, -2089.8010253906, 34.1, 6, 0, 0, 0, 0, 0, 0, 1000) ---------------------- Vertigo addEventHandler("onMarkerHit",createMarker(1618.8389892578, 995.63299560547, 11.5,"cylinder",2,187,5,175,170),showGui) local blip = createBlip(1618.8389892578, 995.63299560547, 11.5, 6, 0, 0, 0, 0, 0, 0, 1000) ---------------------- Zombie Base addEventHandler("onMarkerHit",createMarker(1726.7969970703, -3491.5029296875, 20.170000076294,"cylinder",2,187,5,175,170),showGui) local blip = createBlip(1726.7969970703, -3491.5029296875, 20.170000076294, 6, 0, 0, 0, 0, 0, 0, 1000) addEvent ( "weapBuy", true ) addEventHandler ( "weapBuy", getRootElement(), function ( name, price, ammo ) local price = tonumber ( price ) if ( getPlayerMoney ( client ) >= price ) then outputChatBox ( "You bought: ".. name .." for $".. price .."!", client, 0, 255, 0 ) takePlayerMoney ( client, price ) giveWeapon ( client, getWeaponIDFromName ( name ), tonumber ( ammo ), true ) else outputChatBox ( "You don't have enough money!", client, 255, 0, 0 ) end end ) function skillBuyPlayer ( name, id, price ) if ( getPlayerMoney ( client ) >= price ) then takePlayerMoney ( client, price ) setPedStat ( client, id, 999 ) outputChatBox ( "You bought: ".. name .." for $".. price .."!", client, 0, 255, 0 ) else outputChatBox ( "You don't have enough money!", client, 255, 0, 0 ) end end addEvent ( "skillBuy", true ) addEventHandler ( "skillBuy", getRootElement(), skillBuyPlayer ) I made it for you this time, but don't expect me to do it again with anything else. Link to comment
undefined Posted January 31, 2014 Author Share Posted January 31, 2014 it's solved. Thank you. Please locked topic. 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