iPrestege Posted March 27, 2013 Share Posted March 27, 2013 local Buttons = { Button[1],Button[2],Button[3],Button[4],Button[5] } addEventHandler("onClientMouseEnter",guiRoot, function ( ) for _,k in ipairs ( Buttons ) do if ( source == k ) then playSoundFrontEnd(3); end end end ); Hi guys i have problem with this table ._. will no error's and not work i try to string the buttons but not work to ._. what do you think the problem? Link to comment
DNL291 Posted March 27, 2013 Share Posted March 27, 2013 You can try this: addEventHandler("onClientMouseEnter",guiRoot, function ( ) for i=1, 5 do if ( source == Button[i] ) then playSoundFrontEnd(3); if not i == 5 then break end end end end ); Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 You can try this: addEventHandler("onClientMouseEnter",guiRoot, function ( ) for i=1, 5 do if ( source == Button[i] ) then playSoundFrontEnd(3); if not i == 5 then break end end end end ); This also does not work ._. Link to comment
DNL291 Posted March 27, 2013 Share Posted March 27, 2013 The table: 'Button' is ok? Make sure it has no problems in your code. Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 The table: 'Button' is ok? Make sure it has no problems in your code. Yes no problem in my code ._. : Button = {} ._. and the button work's fine ._. Link to comment
codeluaeveryday Posted March 27, 2013 Share Posted March 27, 2013 Enjoy. local Buttons = { [Button[1]] = true, [Button[2]] = true, [Button[3]] = true, [Button[4]] = true, [Button[5]] = true } addEventHandler("onClientMouseEnter",guiRoot, function ( ) if Buttons[source] then playSoundFrontEnd(3) end end ) Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 Enjoy. local Buttons = { [Button[1]] = true, [Button[2]] = true, [Button[3]] = true, [Button[4]] = true, [Button[5]] = true } addEventHandler("onClientMouseEnter",guiRoot, function ( ) if Buttons[source] then playSoundFrontEnd(3) end end ) not work too ._. Link to comment
codeluaeveryday Posted March 27, 2013 Share Posted March 27, 2013 I swear it should work, change guiRoot to getRootElement(). Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 I swear it should work, change guiRoot to getRootElement(). not work ._. error = table index is nil -_-" Link to comment
codeluaeveryday Posted March 27, 2013 Share Posted March 27, 2013 I've tested it, the 'onClientMouseEnter' isn't starting... Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 I've tested it, the 'onClientMouseEnter' isn't starting... So? Link to comment
codeluaeveryday Posted March 27, 2013 Share Posted March 27, 2013 So I think it's an MTA bug. Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 So I think it's an MTA bug. No!That's not true >!< when i do it like that : addEventHandler("onClientMouseEnter",Button, function ( ) playSoundFrontEnd(3); end,false); Work's fine ! Link to comment
codeluaeveryday Posted March 27, 2013 Share Posted March 27, 2013 Woops lol, I was working with my other server, no wonder, I'll fix it asap. Link to comment
codeluaeveryday Posted March 27, 2013 Share Posted March 27, 2013 local Buttons = {[Button[1]] = true, [Button[2]] = true, [Button[3]] = true, [Button[4]] = true, [Button[5]] = true } addEventHandler("onClientMouseEnter",guiRoot, function ( ) if Buttons[source] then playSoundFrontEnd(3) end end ) EDITTED ^^ My code i sent you ^^ is working. Make sure that the buttons are created before the Buttons table, also make sure that there is a GUI parent element. Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 local Buttons = {[Button[1]] = true, [Button[2]] = true, [Button[3]] = true, [Button[4]] = true, [Button[5]] = true } addEventHandler("onClientMouseEnter",guiRoot, function ( ) if Buttons[source] then playSoundFrontEnd(3) end end ) EDITTED ^^ My code i sent you ^^ is working. Make sure that the buttons are created before the Buttons table, also make sure that there is a GUI parent element. Still the same error ! Link to comment
Moderators IIYAMA Posted March 27, 2013 Moderators Share Posted March 27, 2013 Your table is a little bit strange? is "Button" also a table? local Buttons = { Button[1],Button[2],Button[3],Button[4],Button[5] } for i=1, 5,1 do Buttons[i]= Button[i] end Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 Your table is a little bit strange? is "Button" also a table? local Buttons = { Button[1],Button[2],Button[3],Button[4],Button[5] } for i=1, 5,1 do Buttons[i]= Button[i] end ._. Yes the buttons table. Link to comment
Tete omar Posted March 27, 2013 Share Posted March 27, 2013 Can you show us the code of buttons? Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 Ok,See now what's the problem with this fuck function? GameSystem.button = {} GameSystem.button[1] = guiCreateButton(14, 355, 147, 27, "......", false, GameSystem.window[1]) GameSystem.button[2] = guiCreateButton(233, 357, 147, 27, ".....", false, GameSystem.window[1]) addEventHandler("onClientMouseEnter",root, function ( ) if ( source == GameSystem.button[1] or source == GameSystem.button[2] ) then playSoundFrontEnd(4) end end ) i changed the "Variables" and does not work too . Link to comment
Moderators IIYAMA Posted March 27, 2013 Moderators Share Posted March 27, 2013 GameSystem.button = {}>for i=1, 5,1 do Buttons= Button end lol Link to comment
Tete omar Posted March 27, 2013 Share Posted March 27, 2013 Ok,See now what's the problem with this function? GameSystem.button = {} GameSystem.button[1] = guiCreateButton(14, 355, 147, 27, "......", false, GameSystem.window[1]) GameSystem.button[2] = guiCreateButton(233, 357, 147, 27, ".....", false, GameSystem.window[1]) addEventHandler("onClientMouseEnter",root, function ( ) if ( source == GameSystem.button[1] or source == GameSystem.button[2] ) then playSoundFrontEnd(4) end end ) i changed the "Variables" and does not work too . Try this; local GameSystem.button = { guiCreateButton(14, 355, 147, 27, "......", false, GameSystem.window[1]), guiCreateButton(233, 357, 147, 27, ".....", false, GameSystem.window[1]) } addEventHandler("onClientMouseEnter", guiRoot, function() for i = 1, #GameSystem.button do if(source == GameSystem.button[i])then playSoundFrontEnd(4) break end end end ) Link to comment
iPrestege Posted March 27, 2013 Author Share Posted March 27, 2013 Ok,See now what's the problem with this function? GameSystem.button = {} GameSystem.button[1] = guiCreateButton(14, 355, 147, 27, "......", false, GameSystem.window[1]) GameSystem.button[2] = guiCreateButton(233, 357, 147, 27, ".....", false, GameSystem.window[1]) addEventHandler("onClientMouseEnter",root, function ( ) if ( source == GameSystem.button[1] or source == GameSystem.button[2] ) then playSoundFrontEnd(4) end end ) i changed the "Variables" and does not work too . Try this; local GameSystem.button = { guiCreateButton(14, 355, 147, 27, "......", false, GameSystem.window[1]), guiCreateButton(233, 357, 147, 27, ".....", false, GameSystem.window[1]) } addEventHandler("onClientMouseEnter", guiRoot, function() for i = 1, #GameSystem.button do if(source == GameSystem.button[i])then playSoundFrontEnd(4) break end end end ) Thank's,Tete work's . 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