Jump to content

what have been clicked on onClientGuiClick


zixxonx

Recommended Posts

can i check what i've clicked in the?

for example i got

        GUIEditor.obrazek[1] = guiCreateStaticImage(80,80, 64, 64, "img/1.png", false, GUIEditor.scrollpane[1]) 
        GUIEditor.obrazek[2] = guiCreateStaticImage(150,80, 64, 64, "img/2.png", false, GUIEditor.scrollpane[1]) 
        GUIEditor.obrazek[3] = guiCreateStaticImage(220,80, 64, 64, "img/3.png", false, GUIEditor.scrollpane[1]) 
        GUIEditor.obrazek[4] = guiCreateStaticImage(290,80, 64, 64, "img/4.png", false, GUIEditor.scrollpane[1]) 
        GUIEditor.obrazek[5] = guiCreateStaticImage(80,150, 64, 64, "img/5.png", false, GUIEditor.scrollpane[1]) 
  
        for i = 1, #GUIEditor.obrazek do 
        addEventHandler("onClientGUIClick", GUIEditor.obrazek[i], wybieraAvatar, false) 
        outputChatBox(tostring(i)) 
        end    

then

function wybieraAvatar() 
        outputChatBox("Test: Wybrałeś awatar 1, brawoo!! ") 
end 

How can i check what player clicked? Thanks! :)

Link to comment
  • Moderators
function wybieraAvatar() 
            outputChatBox("Test: Wybrałeś awatar 1, brawoo!! " ) 
            outputChatBox("You clicked on: " .. tostring(source)) -- source is the button.(userdata) 
    end 

Link to comment

Yeah. I got:

Test: Wybrałeś awatar 1, brawoo!!

You clicked on: userdata: 00020318

Test: Wybrałeś awatar 1, brawoo!!

You clicked on: userdata: 00020314

Test: Wybrałeś awatar 1, brawoo!!

You clicked on: userdata: 00020313

Test: Wybrałeś awatar 1, brawoo!!

It's ok and i can use it like this

  
if source == "00020318" then 
-- code 
end 
  

? :) Thanks!

Link to comment

the source of that event is the element that was clicked which can be compared to any other element for example a button. Converting an element to a string like in the sample will just output it's memory address which isn't needed in your case, especially not since those values will change every time the resource or the server restarts or if the element is removed and then created again.

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