BriGhtx3 Posted April 8, 2012 Share Posted April 8, 2012 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
Scripting Moderators Sarrum Posted April 8, 2012 Scripting Moderators Share Posted April 8, 2012 AddEventHandler getPropagated = false Link to comment
iFoReX Posted April 8, 2012 Share Posted April 8, 2012 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
Kenix Posted April 8, 2012 Share Posted April 8, 2012 ElMota, ... Can you learn? I said you more times learn it, but you not want .. https://wiki.multitheftauto.com/wiki/AddEventHandler viewtopic.php?f=148&t=40809 https://wiki.multitheftauto.com/wiki/Scr ... troduction https://wiki.multitheftauto.com/wiki/Int ... ng_the_GUI Link to comment
iFoReX Posted April 8, 2012 Share Posted April 8, 2012 kenix in the last weekend I learn about scripting introduction , introduction the gui and the addeventhandler Link to comment
Guest Guest4401 Posted April 8, 2012 Share Posted April 8, 2012 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 Posted April 8, 2012 Share Posted April 8, 2012 (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 April 8, 2012 by Guest Link to comment
drk Posted April 8, 2012 Share Posted April 8, 2012 kenix in the last weekend I learn about scripting introduction , introduction the gui and the addeventhandler Link to comment
iFoReX Posted April 8, 2012 Share Posted April 8, 2012 thnx for the facepalm xDD but dont do OFFTOPIC Link to comment
drk Posted April 8, 2012 Share Posted April 8, 2012 That's not Off-Topic. "It's really sad when your own baby knows that you're a dumbass...." -> That's the pure true. Link to comment
Jaysds1 Posted April 8, 2012 Share Posted April 8, 2012 Did you guyz know it's about BriGhtX3, not about ElMota... BriGhtx3, check your script, it looks fine and karthik184 said he looked at it. Link to comment
BriGhtx3 Posted April 8, 2012 Author Share Posted April 8, 2012 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. Link to comment
TwiX! Posted April 8, 2012 Share Posted April 8, 2012 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? Link to comment
Scripting Moderators Sarrum Posted April 8, 2012 Scripting Moderators Share Posted April 8, 2012 Try this: addEventHandler ( "onClientGUIClick", HInv_BTN_Platzieren, function ( ) guiSetVisible ( HInv_Window, false ) textITT ( ) end, false ) Link to comment
drk Posted April 8, 2012 Share Posted April 8, 2012 Just use: addEventHandler ( 'onClientGUIClick', root, function ( ) if ( source == HInv_BTN_Platzieren ) then guiSetVisible ( HInv_Window, false ) textITT() end end ) lol Link to comment
BriGhtx3 Posted April 8, 2012 Author Share Posted April 8, 2012 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
BriGhtx3 Posted April 8, 2012 Author Share Posted April 8, 2012 This is the full code. The function TextITT is: function textITT() outputChatBox("TEXT") end Link to comment
Jaysds1 Posted April 8, 2012 Share Posted April 8, 2012 (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 April 8, 2012 by Guest Link to comment
drk Posted April 8, 2012 Share Posted April 8, 2012 Where is centerWindow function? Jaysds1, your code will never work Link to comment
Jaysds1 Posted April 8, 2012 Share Posted April 8, 2012 Where is centerWindow function?Jaysds1, your code will never work CenterWindow Link to comment
BriGhtx3 Posted April 8, 2012 Author Share Posted April 8, 2012 centerWindow is a useful function (wiki) Jay ill test your code Link to comment
Jaysds1 Posted April 8, 2012 Share Posted April 8, 2012 centerWindow is a useful function (wiki) Jay ill test your code ok Link to comment
drk Posted April 8, 2012 Share Posted April 8, 2012 centerWindow isn't a MTASA built-in function -.- You need put it in your code. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now