Jump to content

onClientGUIClick button


BriGhtx3

Recommended Posts

Posted

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 
  

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted
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) 

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Guest Guest4401
Posted

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?

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted
kenix in the last weekend I learn about scripting introduction , introduction the gui and the addeventhandler

Baby_Facepalm_Poster_by_Nianden.jpg

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

That's not Off-Topic.

"It's really sad when your own baby knows that you're a dumbass...." -> That's the pure true.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

I checked it again.

It still doesn't work :/

I also set getPropagated to true, but it is still the same.

I also tested it on another computer and it doesn't work there as well.

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted
I checked it again.

It still doesn't work :/

I also set getPropagated to true, but it is still the same.

I also tested it on another computer and it doesn't work there as well.

its will working.. /debugscript 3?

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

  • Moderators
Posted

Try this:

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

Posted

Just use:

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

lol

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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) 
  

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

This is the full code.

The function TextITT is:

function textITT() 
outputChatBox("TEXT") 
end 

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted (edited)

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

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

Where is centerWindow function?

Jaysds1, your code will never work :D

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

centerWindow isn't a MTASA built-in function -.-

You need put it in your code.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

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