iPrestege Posted March 27, 2013 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?
DNL291 Posted March 27, 2013 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 );
iPrestege Posted March 27, 2013 Author 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 ._.
DNL291 Posted March 27, 2013 Posted March 27, 2013 The table: 'Button' is ok? Make sure it has no problems in your code.
iPrestege Posted March 27, 2013 Author 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 ._.
codeluaeveryday Posted March 27, 2013 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 )
iPrestege Posted March 27, 2013 Author 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 ._.
codeluaeveryday Posted March 27, 2013 Posted March 27, 2013 I swear it should work, change guiRoot to getRootElement().
iPrestege Posted March 27, 2013 Author Posted March 27, 2013 I swear it should work, change guiRoot to getRootElement(). not work ._. error = table index is nil -_-"
codeluaeveryday Posted March 27, 2013 Posted March 27, 2013 I've tested it, the 'onClientMouseEnter' isn't starting...
iPrestege Posted March 27, 2013 Author Posted March 27, 2013 I've tested it, the 'onClientMouseEnter' isn't starting... So?
iPrestege Posted March 27, 2013 Author 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 !
codeluaeveryday Posted March 27, 2013 Posted March 27, 2013 Woops lol, I was working with my other server, no wonder, I'll fix it asap.
codeluaeveryday Posted March 27, 2013 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.
iPrestege Posted March 27, 2013 Author 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 !
Moderators IIYAMA Posted March 27, 2013 Moderators 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
iPrestege Posted March 27, 2013 Author 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.
iPrestege Posted March 27, 2013 Author 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 .
Moderators IIYAMA Posted March 27, 2013 Moderators Posted March 27, 2013 GameSystem.button = {}>for i=1, 5,1 do Buttons= Button end lol
Tete omar Posted March 27, 2013 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 )
iPrestege Posted March 27, 2013 Author 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 .
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