Jump to content

Avatars (Bug..)


proracer

Recommended Posts

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:

avatarbug.jpg

It shows 2 pictures because I clicked another one, how I can fix that?

Link to comment
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 by Guest
Link to comment

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

Link to comment

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

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

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