FSXTim Posted June 4, 2012 Share Posted June 4, 2012 Hello, if the player press the button 'sodButton1' and the text of the label is '1', the outputChatBox has to say 'Test', but it doesn't, although the text of the label is '1'. sod1 = guiCreateLabel(0.2200,0.1500,0.0455,0.0485,"1",true,sudoku_Window) function checkSod (state) if state == "left" then if source == sodButton1 then if guiGetText(sod1) == "1" then local player = getLocalPlayer() outputChatBox("Test", player) end end end end addEventHandler("onClientGUIClick", getRootElement(), checkSod) Greets Link to comment
FSXTim Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) No errors in the debugscript. This doesn't work: sod1 = guiCreateLabel(0.2200,0.1500,0.0455,0.0485,"1",true,sudoku_Window) function checkSod (state) if state == "left" then if source == sodButton1 then if guiGetText(sod1) == "1" then local player = getLocalPlayer() outputChatBox("Test", player) end end end end addEventHandler("onClientGUIClick", getRootElement(), checkSod) But this works: function checkSod (state) if state == "left" then if source == sodButton1 then sod1 = guiCreateLabel(0.2200,0.1500,0.0455,0.0485,"1",true,sudoku_Window) if guiGetText(sod1) == "1" then local player = getLocalPlayer() outputChatBox("Test", player) end end end end addEventHandler("onClientGUIClick", getRootElement(), checkSod) But I need to make it working with the first way. Greets Edited June 4, 2012 by Guest Link to comment
Castillo Posted June 4, 2012 Share Posted June 4, 2012 First argument of: onClientGUIClick is the mouse button used, not the state. function checkSod ( button, state ) if ( state == "left" ) then if ( source == sodButton1 ) then if ( guiGetText ( sod1 ) == "1" ) then outputChatBox ( "Test" ) -- This function has no visibleTo argument in the client side. end end end end addEventHandler ( "onClientGUIClick", guiRoot, checkSod ) Link to comment
FSXTim Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) function checkSod ( button, state ) if (state == "left") then if (source == sodButton1) then if (guiGetText(sod1 ) == "1") then outputChatBox ("Test") end end end end addEventHandler ("onClientGUIClick", getRootElement(), checkSod) Now the chatbox doesn't say anything although the text in the label is '1'! Greets Edited June 4, 2012 by Guest Link to comment
Castillo Posted June 4, 2012 Share Posted June 4, 2012 state: the state of the mouse button, will be down if the mouse button was pushed, or up if it was released. Please note currently only the up state is supported. Link to comment
FSXTim Posted June 4, 2012 Author Share Posted June 4, 2012 And what do I exactly have to do now? Greets Link to comment
Castillo Posted June 4, 2012 Share Posted June 4, 2012 function checkSod ( button, state ) if ( source == sodButton1 ) then if ( guiGetText ( sod1 ) == "1" ) then outputChatBox ( "Test" ) end end end addEventHandler ( "onClientGUIClick", guiRoot, checkSod ) If that doesn't work, then post your entire script. Link to comment
FSXTim Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) This also doesn't work. The script: x,y = guiGetScreenSize() sudoku_Window = guiCreateWindow(x/10.0 - 110,y/2.5 - 165,220,330,"",false) sodButton1 = guiCreateButton(0.0909,0.7182,0.2409,0.0515,"Prüfen",true,sudoku_Window) guiSetFont(sodButton1,"default-bold-small") sod1 = guiCreateLabel(0.2200,0.1500,0.0455,0.0485,"1",true,sudoku_Window) function checkSod ( button, state ) if ( source == sodButton1 ) then if ( guiGetText ( sod1 ) == "1" ) then outputChatBox ( "Test" ) end end end addEventHandler ( "onClientGUIClick", guiRoot, checkSod ) Greets Edited June 4, 2012 by Guest Link to comment
Castillo Posted June 4, 2012 Share Posted June 4, 2012 Where is sodButton1? if that's the entire script, it has missing button? Link to comment
FSXTim Posted June 4, 2012 Author Share Posted June 4, 2012 Sorry, I forgot it. I edited my last post. #Edit: I found a solution: function checkSod (state) if state == "left" then if source == sodButton1 then if guiGetText(sod1) == "1" then outputChatBox("Test") end end end end addEventHandler("onClientGUIClick", getRootElement(), checkSod) Thanks at all! Greets 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