Jump to content

Do event for every element in function


Piorun

Recommended Posts

Posted

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?

Posted
for i, v in ipairs(Button) do 
      addEventHandler( "onClientGUIClick", v, zmienKolor, false ) 
end 

Posted

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?

Posted

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 :oops:

Posted

Don't worry :D. 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..

Posted

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 :)

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