Jump to content

button D:


KaMeR

Recommended Posts

button = guiCreateButton( 0.1, 0.2, 0.15, 0.06, "B TEST", true, WindowForm )     
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Button Pressed" ) 
        end 
         end 
) 

i tryed too>

button = guiCreateButton( 0.1, 0.2, 0.15, 0.06, "B TEST", true, WindowForm )     
  
function test () 
        outputChatBox ( "Button Pressed" ) 
end 
addEventHandler ( "onClientGUIClick", button, test ) 
) 

and wont work what is the problem?? (this and this doesnt work)

Link to comment
button = guiCreateButton( 0.1, 0.2, 0.15, 0.06, "B TEST", true, WindowForm )     
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Button Pressed" ) 
        end 
         end 
) 

i tryed too>

button = guiCreateButton( 0.1, 0.2, 0.15, 0.06, "B TEST", true, WindowForm )     
  
function test () 
        outputChatBox ( "Button Pressed" ) 
end 
addEventHandler ( "onClientGUIClick", button, test ) 
) 

and wont work what is the problem?? (this and this doesnt work)

Search around. People have had exactly the same problem as you and fixed it.

Cloudy

Link to comment

But how can you make like more buttons in 1 .lua file because like:

  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm )     
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
        end 
         end 
) 
  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm )     
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
        end 
         end 
) 
  
etc... 
  

That doesnt work at mine then it only displays 1 button.

Can someone tell me this?

Link to comment
But how can you make like more buttons in 1 .lua file because like:

  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm )     
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
        end 
         end 
) 
  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm )     
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
        end 
         end 
) 
  
etc... 
  

That doesnt work at mine then it only displays 1 button.

Can someone tell me this?

  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm ) 
button1 = guiCreateButton( 0.1, 0.3, 0.10, 0.03, "Admin!", true, WindowForm )         
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
            end 
         end 
) 
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button1) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
            end 
         end 
) 
  
etc... 
  

...

Link to comment

anyone know how use "triggerServerEvent" in it?

addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Button Pressed" ) 
        end 
         end 
) 

Link to comment
  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm ) 
button1 = guiCreateButton( 0.1, 0.3, 0.10, 0.03, "Admin!", true, WindowForm )         
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
            end 
         end 
) 
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button1) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
            end 
         end 
) 
  
etc... 
  

...

That code is inefficient, having two functions triggered when it could be done in one.

  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm ) 
button1 = guiCreateButton( 0.1, 0.3, 0.10, 0.03, "Admin!", true, WindowForm )         
  
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == button) then 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
            else if (source == button1) then 
                outputChatBox ( "Admin! I Need You!, Help Me!! (1)" ) 
            end 
         end 
) 
  

Much better ^_^

Cloudy

Link to comment

Even better:

  
button = guiCreateButton( 0.1, 0.2, 0.10, 0.03, "Admin!", true, WindowForm ) 
button1 = guiCreateButton( 0.1, 0.3, 0.10, 0.03, "Admin!", true, WindowForm )         
  
addEventHandler ( "onClientGUIClick", button, 
        function (button, state, x, y) 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
         end 
) 
  
addEventHandler ( "onClientGUIClick", button1, 
        function (button, state, x, y) 
                outputChatBox ( "Admin! I Need You!, Help Me!!" ) 
         end 
) 
  

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