Jump to content

onClientGUIClick button


BriGhtx3

Recommended Posts

Hey,

I have got another problem.

I've create a GUI, now when I click the button HInv_BTN_Platzieren, the function textITT should get executed. But the function gets executed whenever I click on the GUI or the gridlist...

HInv_Window = guiCreateWindow(354,252,362,272,"Inv",false) 
guiWindowSetSizable(HInv_Window,false) 
HInv_Grid = guiCreateGridList(38,69,290,157,false,HInv_Window) 
guiGridListSetSelectionMode(HInv_Grid,2) 
  
hinvName = guiGridListAddColumn(HInv_Grid,"Name",2) 
HInv_BTN_Platzieren = guiCreateButton(90,231,186,22,"Platzieren",false,HInv_Window) 
addEventHandler("onClientGUIClick",HInv_BTN_Platzieren,function() if source == HInv_BTN_Platzieren then guiSetVisible(HInv_Window,false) textITT() end end) 
  
function textITT() 
outputChatBox("TEXT") 
end 
  

Link to comment
Hey,

I have got another problem.

I've create a GUI, now when I click the button HInv_BTN_Platzieren, the function textITT should get executed. But the function gets executed whenever I click on the GUI or the gridlist...

HInv_Window = guiCreateWindow(354,252,362,272,"Inv",false) 
guiWindowSetSizable(HInv_Window,false) 
HInv_Grid = guiCreateGridList(38,69,290,157,false,HInv_Window) 
guiGridListSetSelectionMode(HInv_Grid,2) 
  
hinvName = guiGridListAddColumn(HInv_Grid,"Name",2) 
HInv_BTN_Platzieren = guiCreateButton(90,231,186,22,"Platzieren",false,HInv_Window) 
addEventHandler("onClientGUIClick",HInv_BTN_Platzieren,function() if source == HInv_BTN_Platzieren then guiSetVisible(HInv_Window,false) textITT() end end) 
  
function textITT() 
outputChatBox("TEXT") 
end 
  

and It ?

HInv_Window = guiCreateWindow(354,252,362,272,"Inv",false) 
guiWindowSetSizable(HInv_Window,false) 
HInv_Grid = guiCreateGridList(38,69,290,157,false,HInv_Window) 
guiGridListSetSelectionMode(HInv_Grid,2) 
  
hinvName = guiGridListAddColumn(HInv_Grid,"Name",2) 
HInv_BTN_Platzieren = guiCreateButton(90,231,186,22,"Platzieren",false,HInv_Window) 
  
function click() 
 if (source == HInv_BTN_Platzieren) then  
guiSetVisible(HInv_Window,false)  
outputChatBox("TEXT") 
            end  
     end 
) 
addEventHandler("onClientGUIClick", click) 

Link to comment
Guest Guest4401

But the function gets executed whenever I click on the GUI or the gridlist...

@BriGhtx3

Your code is absolutely fine. I tested it and it only executes when you click the button. Can you recheck it please?

Link to comment
kenix in the last weekend I learn about scripting introduction , introduction the gui and the addeventhandler

You need learn again!

addEventHandler("onClientGUIClick", click) 

What is it?!!

function click() 
 if (source == HInv_BTN_Platzieren) then  
guiSetVisible(HInv_Window,false)  
outputChatBox("TEXT") 
            end  
     end 
) 

And it

:/

Edited by Guest
Link to comment
  • Scripting Moderators

Try this:

addEventHandler ( "onClientGUIClick", HInv_BTN_Platzieren, 
function ( ) 
    guiSetVisible ( HInv_Window, false ) 
    textITT ( ) 
end, false ) 

Link to comment

Just use:

addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if ( source == HInv_BTN_Platzieren ) then 
            guiSetVisible ( HInv_Window, false ) 
            textITT() 
        end 
    end 
) 

lol

Link to comment

Doesn't work either.

I changed the code a bit and it doesn't work either. Could someone fix it?

HInv_Window = guiCreateWindow(354,252,362,272,"Haushaltsinventar",false) 
guiWindowSetSizable(HInv_Window,false) 
HInv_LBL_Welcome = guiCreateLabel(34,25,305,35,"Hallo. Das ist dein Haushaltsinventar.\nVon hier aus kannst du Möbel in dein Haus platzieren.",false,HInv_Window) 
guiSetFont(HInv_LBL_Welcome,"default-bold-small") 
HInv_Grid = guiCreateGridList(38,69,290,157,false,HInv_Window) 
guiGridListSetSelectionMode(HInv_Grid,2) 
  
hinvName = guiGridListAddColumn(HInv_Grid,"Name",2) 
HInv_BTN_Platzieren = guiCreateButton(90,231,186,22,"Platzieren",false,HInv_Window) 
centerWindow(HInv_Window) 
addEventHandler("onClientGUIClick",HInv_BTN_Platzieren,function() if source == HInv_BTN_Platzieren then guiSetVisible(HInv_Window,false) TextITT() end end,false) 
  

Link to comment

Try this:

HInv_Window = guiCreateWindow(354,252,362,272,"Haushaltsinventar",false) 
guiWindowSetSizable(HInv_Window,false) 
--Label 
HInv_LBL_Welcome = guiCreateLabel(34,25,305,35,"Hallo. Das ist dein Haushaltsinventar.\nVon hier aus kannst du Möbel in dein Haus platzieren.",false,HInv_Window) 
guiSetFont(HInv_LBL_Welcome,"default-bold-small") 
--Grid 
HInv_Grid = guiCreateGridList(38,69,290,157,false,HInv_Window) 
guiGridListSetSelectionMode(HInv_Grid,2) 
hinvName = guiGridListAddColumn(HInv_Grid,"Name",2) 
--Button 
HInv_BTN_Platzieren = guiCreateButton(90,231,186,22,"Platzieren",false,HInv_Window) 
centerWindow(HInv_Window) 
  
addEventHandler("onClientGUIClick",HInv_BTN_Platzieren,function() 
    if(source == HInv_BTN_Platzieren)then 
        guiSetVisible(HInv_Window,false) 
        textITT() 
    end 
end,false) 

Edited by Guest
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...