Jump to content

button D:


KaMeR

Recommended Posts

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

Posted

But what's the problem? you have to explain more, the button doesn't appear, or it doesnt show the text in the textbox, what? =/

btw, what's the ) at the end supposed to mean?

Posted
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

Posted
ok nevermind my mistake works now

can you post the fixed code? it may help the people who get the problem that you have..

first code works fine

Posted

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?

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

...

Posted

anyone know how use "triggerServerEvent" in it?

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

Posted
  
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

Posted

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 
) 
  

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