Piorun Posted June 17, 2011 Share Posted June 17, 2011 Hi. Firstly - my lua code: Button = {} Button[1] = guiCreateLabel(8,0,59,20,"Postacie",false) guiLabelSetHorizontalAlign(Button[1],"center",false) Button[2] = guiCreateLabel(77,0,59,20,"Przyjaciele",false) guiLabelSetHorizontalAlign(Button[2],"center",false) Button[3] = guiCreateLabel(146,0,59,20,"Statystyki",false) guiLabelSetHorizontalAlign(Button[3],"center",false) Button[4] = guiCreateLabel(215,0,40,20,"Opcje",false) guiLabelSetHorizontalAlign(Button[4],"center",false) Button[5] = guiCreateLabel(265,0,47,20,"Pomoc",false) guiLabelSetHorizontalAlign(Button[5],"center",false) addEventHandler( "onClientGUIClick", Button, zmienKolor, false ) Ok, i have this one. I want to add this Event for every "Button" element in this function. How? Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 for i, v in ipairs(Button) do addEventHandler( "onClientGUIClick", v, zmienKolor, false ) end Link to comment
Piorun Posted June 17, 2011 Author Share Posted June 17, 2011 Ok, but when i add this i didn't see my rectangle (this is my rest of function): function controlPanel() Button = {} Button[1] = guiCreateLabel(8,0,59,20,"Postacie",false) guiLabelSetHorizontalAlign(Button[1],"center",false) Button[2] = guiCreateLabel(77,0,59,20,"Przyjaciele",false) guiLabelSetHorizontalAlign(Button[2],"center",false) Button[3] = guiCreateLabel(146,0,59,20,"Statystyki",false) guiLabelSetHorizontalAlign(Button[3],"center",false) Button[4] = guiCreateLabel(215,0,40,20,"Opcje",false) guiLabelSetHorizontalAlign(Button[4],"center",false) Button[5] = guiCreateLabel(265,0,47,20,"Pomoc",false) guiLabelSetHorizontalAlign(Button[5],"center",false) for i,v in ipairs(Button) do addEventHandler( "onClientGUIClick", v[i], zmienKolor, false ) end -- Direct X Drawing addEventHandler("onClientRender",root, function() dxDrawRectangle(0.0,0.0,1024.0,20.0,tocolor(0,0,0,191),false) end ) end why? Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 I made a mistake for i, v in ipairs(Button) do addEventHandler( "onClientGUIClick", v, zmienKolor, false ) end Sorry have been working on something for 5 hours so far Link to comment
Piorun Posted June 17, 2011 Author Share Posted June 17, 2011 Don't worry . My next problem. I create a function "zmienKolor" and it doesn't works function zmienKolor() guiLabelSetColor(v, 255, 0, 0) end after click of cors.. Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 Hmm, v i think is the botton like i gave it to you not a label Link to comment
Castillo Posted June 17, 2011 Share Posted June 17, 2011 Why do you need the function? Link to comment
Piorun Posted June 17, 2011 Author Share Posted June 17, 2011 Because i'm creating a control panel for every players, and i want to create simple menu i the top of the screen and i want just test this function Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 function zmienKolor() guiLabelSetColor(source, 255, 0, 0) end Link to comment
Piorun Posted June 17, 2011 Author Share Posted June 17, 2011 Wow, nice, works . Thanks a lot. Link to comment
Castillo Posted June 17, 2011 Share Posted June 17, 2011 Ah, my bad, I didn't know what was you trying to do . 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