zixxonx Posted May 3, 2014 Posted May 3, 2014 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!
Moderators IIYAMA Posted May 3, 2014 Moderators Posted May 3, 2014 function wybieraAvatar() outputChatBox("Test: Wybrałeś awatar 1, brawoo!! " ) outputChatBox("You clicked on: " .. tostring(source)) -- source is the button.(userdata) end
zixxonx Posted May 3, 2014 Author Posted May 3, 2014 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!
Moderators IIYAMA Posted May 3, 2014 Moderators Posted May 3, 2014 The userdata of an element always change. You should compare them with: GUIEditor.obrazek[1] etc....
Mr_Moose Posted May 3, 2014 Posted May 3, 2014 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.
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