proracer Posted March 27, 2011 Share Posted March 27, 2011 Hello everyone, I wanted to make like avatar selection but when someone clicks multiple items it draws images over it, do you guys have any idea how to fix? I have tried multiple times with setElementData, inserting data into tables and checking if he clicked before and destroyElement or guiSetVisible to false but none of them works. Code: GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} -- GUI Interface GUIEditor_Window[1] = guiCreateWindow(334,298,565,406,"XG Avatar | - Made by Pr0RaC3R - |",false) GUIEditor_Grid[1] = guiCreateGridList(9,25,253,372,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) column1 = guiGridListAddColumn(GUIEditor_Grid[1],"Avatar Category",0.5) column2 = guiGridListAddColumn(GUIEditor_Grid[1],"Select avatar",0.5) for i = 1, 10 do row = guiGridListAddRow(GUIEditor_Grid[1]) end guiGridListSetItemText ( GUIEditor_Grid[1], row, column1, 'Retro', false, false ) GUIEditor_Button[1] = guiCreateButton(273,359,132,36,"Save as default avatar",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(422,359,125,36,"Remove my avatar",false,GUIEditor_Window[1]) guiSetVisible ( GUIEditor_Window[1], false ) function drawAvatarPanel ( ) bindKey ( 'F7', 'down', showAvatarPanel ) end addEventHandler ( 'onClientResourceStart', resourceRoot, drawAvatarPanel ) function showAvatarPanel ( ) isVisible = guiGetVisible ( GUIEditor_Window[1] ) if (isVisible) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end if (not isVisible) then guiSetVisible ( GUIEditor_Window[1], true ) showCursor ( true ) end end function onGridListClickShowColumn2Items ( button ) if (button) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Retro' then guiGridListSetItemText ( GUIEditor_Grid[1], 1, 2, 'Address', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 2, 2, 'Ads', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 3, 2, 'Calendar', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 4, 2, 'Comment', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 5, 2, 'Home', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 6, 2, 'Mail', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 7, 2, 'News', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 8, 2, 'RSS', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 9, 2, 'Search', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 10, 2, 'Sign', false, false ) end end addEventHandler ( 'onClientGUIClick', root, onGridListClickShowColumn2Items ) function onGridListClickShowImage ( button ) if (button) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Address' then Picture1 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/address_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Ads' then Picture2 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/ads_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Calendar' then Picture3 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/calendar_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Comment' then Picture4 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/comment_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Home' then Picture5 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/home_128.png', false, GUIEditor_Window[1] ) end end addEventHandler ( 'onClientGUIClick', root, onGridListClickShowImage ) Take a look at last function it's most important. Picture of bug: It shows 2 pictures because I clicked another one, how I can fix that? Link to comment
Castillo Posted March 27, 2011 Share Posted March 27, 2011 (edited) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} -- GUI Interface GUIEditor_Window[1] = guiCreateWindow(334,298,565,406,"XG Avatar | - Made by Pr0RaC3R - |",false) GUIEditor_Grid[1] = guiCreateGridList(9,25,253,372,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) column1 = guiGridListAddColumn(GUIEditor_Grid[1],"Avatar Category",0.5) column2 = guiGridListAddColumn(GUIEditor_Grid[1],"Select avatar",0.5) for i = 1, 10 do row = guiGridListAddRow(GUIEditor_Grid[1]) end guiGridListSetItemText ( GUIEditor_Grid[1], row, column1, 'Retro', false, false ) GUIEditor_Button[1] = guiCreateButton(273,359,132,36,"Save as default avatar",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(422,359,125,36,"Remove my avatar",false,GUIEditor_Window[1]) guiSetVisible ( GUIEditor_Window[1], false ) function drawAvatarPanel ( ) bindKey ( 'F7', 'down', showAvatarPanel ) end addEventHandler ( 'onClientResourceStart', resourceRoot, drawAvatarPanel ) function showAvatarPanel ( ) isVisible = guiGetVisible ( GUIEditor_Window[1] ) if (isVisible) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end if (not isVisible) then guiSetVisible ( GUIEditor_Window[1], true ) showCursor ( true ) end end function onGridListClickShowColumn2Items ( button ) if (button) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Retro' then guiGridListSetItemText ( GUIEditor_Grid[1], 1, 2, 'Address', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 2, 2, 'Ads', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 3, 2, 'Calendar', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 4, 2, 'Comment', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 5, 2, 'Home', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 6, 2, 'Mail', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 7, 2, 'News', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 8, 2, 'RSS', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 9, 2, 'Search', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 10, 2, 'Sign', false, false ) end end addEventHandler ( 'onClientGUIClick', root, onGridListClickShowColumn2Items ) function onGridListClickShowImage ( button ) if (button) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Address' then check() Picture1 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/address_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Ads' then check() Picture2 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/ads_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Calendar' then check() Picture3 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/calendar_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Comment' then check() Picture4 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/comment_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Home' then check() Picture5 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/home_128.png', false, GUIEditor_Window[1] ) end end addEventHandler ( 'onClientGUIClick', root, onGridListClickShowImage ) function check() if isElement(Picture1) then destroyElement(Picture1) end if isElement(Picture2) then destroyElement(Picture2) end if isElement(Picture3) then destroyElement(Picture3) end if isElement(Picture4) then destroyElement(Picture4) end if isElement(Picture5) then destroyElement(Picture5) end end Try if that works. Edited March 28, 2011 by Guest Link to comment
proracer Posted March 27, 2011 Author Share Posted March 27, 2011 No, it's still the same .. Link to comment
Castillo Posted March 27, 2011 Share Posted March 27, 2011 ok, that wasn't tested, could you explain your bug? because the image you inserted in your post isn't working. Edit: Copy my code again, i have made some changes. Link to comment
proracer Posted March 28, 2011 Author Share Posted March 28, 2011 Wow, thx!! It works. Link to comment
proracer Posted March 30, 2011 Author Share Posted March 30, 2011 Sorry for double post, I worked hard on this but I still can't figure out this: So .. when player clicks button it draws avatar above his head.But when player clicks button again with different avatar it draws an image over it, how can I fix that? Because I have 100+ avatars .. Link to comment
Castillo Posted March 30, 2011 Share Posted March 30, 2011 Hmmmmm, so, you want to click on an avatar from your gridlist and then draw it on player's head? if so, make a global variable like: avatar = nil and then change it when you click, like avatar = "myAvatar.png" and then you just draw it using "avatar" variable. Link to comment
ProDMRac3r Posted March 30, 2011 Share Posted March 30, 2011 Thxxxx How I Can Get The Meta.xml Codes ??? Link to comment
Martyz Posted March 31, 2011 Share Posted March 31, 2011 You just must remove last image element when you are selecting another one.. Link to comment
Moderators Citizen Posted March 31, 2011 Moderators Share Posted March 31, 2011 Thxxxx How I Can Get The Meta.xml Codes ??? Lol this part of the forum is not for sharing scripts !! Steal scripts in this part of the forum is forbidden ! Link to comment
Timic Posted March 31, 2011 Share Posted March 31, 2011 Thxxxx How I Can Get The Meta.xml Codes ??? Lol this part of the forum is not for sharing scripts !! Steal scripts in this part of the forum is forbidden ! You can take the code from forum if you have problems with same script. Link to comment
Moderators Citizen Posted March 31, 2011 Moderators Share Posted March 31, 2011 Yeah but here is the Proracer's script so he can't have the same Link to comment
Timic Posted April 1, 2011 Share Posted April 1, 2011 Well, if proracer gives 'rights' to ProDMRac3r, he can have and change it but he can't change credits Link to comment
ProDMRac3r Posted April 1, 2011 Share Posted April 1, 2011 I Mean Im Always Make .lua Only I Can't Find meta.xml likes this GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} -- GUI Interface GUIEditor_Window[1] = guiCreateWindow(334,298,565,406,"XG Avatar | - Made by Pr0RaC3R - |",false) GUIEditor_Grid[1] = guiCreateGridList(9,25,253,372,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) column1 = guiGridListAddColumn(GUIEditor_Grid[1],"Avatar Category",0.5) column2 = guiGridListAddColumn(GUIEditor_Grid[1],"Select avatar",0.5) for i = 1, 10 do row = guiGridListAddRow(GUIEditor_Grid[1]) end guiGridListSetItemText ( GUIEditor_Grid[1], row, column1, 'Retro', false, false ) GUIEditor_Button[1] = guiCreateButton(273,359,132,36,"Save as default avatar",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(422,359,125,36,"Remove my avatar",false,GUIEditor_Window[1]) guiSetVisible ( GUIEditor_Window[1], false ) function drawAvatarPanel ( ) bindKey ( 'F7', 'down', showAvatarPanel ) end addEventHandler ( 'onClientResourceStart', resourceRoot, drawAvatarPanel ) function showAvatarPanel ( ) isVisible = guiGetVisible ( GUIEditor_Window[1] ) if (isVisible) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end if (not isVisible) then guiSetVisible ( GUIEditor_Window[1], true ) showCursor ( true ) end end function onGridListClickShowColumn2Items ( button ) if (button) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Retro' then guiGridListSetItemText ( GUIEditor_Grid[1], 1, 2, 'Address', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 2, 2, 'Ads', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 3, 2, 'Calendar', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 4, 2, 'Comment', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 5, 2, 'Home', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 6, 2, 'Mail', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 7, 2, 'News', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 8, 2, 'RSS', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 9, 2, 'Search', false, false ) guiGridListSetItemText ( GUIEditor_Grid[1], 10, 2, 'Sign', false, false ) end end addEventHandler ( 'onClientGUIClick', root, onGridListClickShowColumn2Items ) function onGridListClickShowImage ( button ) if (button) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Address' then check() Picture1 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/address_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Ads' then check() Picture2 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/ads_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Calendar' then check() Picture3 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/calendar_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Comment' then check() Picture4 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/comment_128.png', false, GUIEditor_Window[1] ) elseif ( button ) == 'left' and (guiGridListGetItemText(GUIEditor_Grid[1],guiGridListGetSelectedItem(GUIEditor_Grid[1]))) == 'Home' then check() Picture5 = guiCreateStaticImage ( 357, 130, 128, 128, 'retro/home_128.png', false, GUIEditor_Window[1] ) end end addEventHandler ( 'onClientGUIClick', root, onGridListClickShowImage ) function check() if isElement(Picture1) then destroyElement(Picture1) end if isElement(Picture2) then destroyElement(Picture2) end if isElement(Picture3) then destroyElement(Picture3) end if isElement(Picture4) then destroyElement(Picture4) end if isElement(Picture5) then destroyElement(Picture5) end end Where Is The Meta.xml Codes Link to comment
Castillo Posted April 1, 2011 Share Posted April 1, 2011 You can't script, that's obiously, everyone who can script well knows how to make a meta.xml. what you are asking is to use an script which you didn't made. 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