Maurize Posted May 21, 2012 Share Posted May 21, 2012 so, i've tried to create a nice and smart animation gui... but now there are these table problems... check it yourself: local animations = { { "RIOT", "RIOT_ANGRY" }, { "RIOT", "RIOT_ANGRY_B" }, { "RIOT", "RIOT_challenge" }, { "RIOT", "RIOT_CHANT" }, { "RIOT", "RIOT_FUKU" }, { "RIOT", "RIOT_PUNCHES" }, { "RIOT", "RIOT_shout" } } bindKey( "i", "down", function() if ( guiGetVisible( guiElement1 ) == false ) then guiSetVisible( guiElement1, true ) showCursor( true ) end end ) addEventHandler( "onClientResourceStart", resourceRoot, function() for i = 1, #animations do guiElement[i] = guiGridListAddRow( guiElement2 ) guiGridListSetItemText( guiElement2, guiElement5, guiElement..""..i, animations[i][1], false, false ) guiGridListSetItemText( guiElement2, guiElement6, guiElement..""..i, animations[i][2], false, false ) end end ) addEventHandler( "onClientGUIClick", elementGroup, function() if ( source == guiElement3 ) then if ( guiGridListGetSelectedItem( guiElement2 ) == guiElement[i], guiElement5 ) and ( guiGridListGetSelectedItem( guiElement2 ) == guiElement[i], guiElement6 ) then local block = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement5 ) local animation = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement6 ) if ( block ) and ( animation ) then triggerServerEvent( "onElementAnimation", elementPlayer, block, animation ) end end elseif ( source == guiElement4 ) then guiSetVisible( guiElement1, false ) showCursor( false ) end end ) Link to comment
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 Here it toke me 20 min to fix this wtf local animations = { { "RIOT", "RIOT_ANGRY" }, { "RIOT", "RIOT_ANGRY_B" }, { "RIOT", "RIOT_challenge" }, { "RIOT", "RIOT_CHANT" }, { "RIOT", "RIOT_FUKU" }, { "RIOT", "RIOT_PUNCHES" }, { "RIOT", "RIOT_shout" } } bindKey( "i", "down", function() if ( guiGetVisible( guiElement1 ) == false ) then guiSetVisible( guiElement1, true ) showCursor( true ) end end ) addEventHandler( "onClientResourceStart", resourceRoot, function() for i = 1, #animations do guiElement[i] = guiGridListAddRow( guiElement2 ) guiGridListSetItemText( guiElement2, guiElement5, guiElement..""..i, animations[i][1], false, false ) guiGridListSetItemText( guiElement2, guiElement6, guiElement..""..i, animations[i][2], false, false ) end end ) addEventHandler( "onClientGUIClick", elementGroup, function() if ( source == guiElement3 ) then if ( guiGridListGetSelectedItem) then ( guiElement2 )(guiElement[i]) (guiElemen) ( guiGridListGetSelectedItem)( guiElement2 ) if (guiElement[i]) and (guiElement6) then local block = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement5 ) local animation = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement6 ) if ( block ) and ( animation ) then triggerServerEvent( "onElementAnimation", elementPlayer, block, animation ) elseif ( source == guiElement4 ) then guiSetVisible( guiElement1, false ) showCursor( false ) end end end end end) Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 wtf. doesnt look good? u sure that this is correct at all? guiElement = guiGridListAddRow( guiElement2 ) // attempt to index global "guiElement" a nil value Link to comment
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 yes i fixed the erros with lua script edtor but i dont know how to fix this isuue . Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 thanks! saw that:) maybe someone else? Jaysds or Castillo?:DD:D Link to comment
Anderl Posted May 21, 2012 Share Posted May 21, 2012 guiElement should be an array. http://lua-users.org/wiki/TablesTutorial Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 theFuck? it is an array? i mean means the number, which is choosen in the loop! Link to comment
Alpha Posted May 21, 2012 Share Posted May 21, 2012 It's really messed up. Not sure this solves it, but it will remove the error: local guiElement = {} local animations = { { "RIOT", "RIOT_ANGRY" }, { "RIOT", "RIOT_ANGRY_B" }, { "RIOT", "RIOT_challenge" }, { "RIOT", "RIOT_CHANT" }, { "RIOT", "RIOT_FUKU" }, { "RIOT", "RIOT_PUNCHES" }, { "RIOT", "RIOT_shout" } } bindKey( "i", "down", function() if ( guiGetVisible( guiElement1 ) == false ) then guiSetVisible( guiElement1, true ) showCursor( true ) end end ) addEventHandler( "onClientResourceStart", resourceRoot, function() for i = 1, #animations do guiElement[i] = guiGridListAddRow( guiElement2 ) guiGridListSetItemText( guiElement2, guiElement5, guiElement..""..i, animations[i][1], false, false ) guiGridListSetItemText( guiElement2, guiElement6, guiElement..""..i, animations[i][2], false, false ) end end ) addEventHandler( "onClientGUIClick", elementGroup, function() if ( source == guiElement3 ) then if ( guiGridListGetSelectedItem) then ( guiElement2 )(guiElement[i]) (guiElemen) ( guiGridListGetSelectedItem)( guiElement2 ) if (guiElement[i]) and (guiElement6) then local block = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement5 ) local animation = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement6 ) if ( block ) and ( animation ) then triggerServerEvent( "onElementAnimation", elementPlayer, block, animation ) elseif ( source == guiElement4 ) then guiSetVisible( guiElement1, false ) showCursor( false ) end end end end end) Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 noop, still errors... exactly here: guiGridListSetItemText( guiElement2, guiElement5, guiElement..""..i, animations[i][1], false, false ) Link to comment
Anderl Posted May 21, 2012 Share Posted May 21, 2012 Your code is TOTALLY fucked up, really. You should learn more about LUA. Try that: local aAnims = { { "RIOT", "RIOT_ANGRY"; }, { "RIOT", "RIOT_ANGRY_B"; }, { "RIOT", "RIOT_challenge"; }, { "RIOT", "RIOT_CHANT"; }, { "RIOT", "RIOT_FUKU"; }; } -- addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) bindKey ( "i", "down", wndShow ); -- for index, anim in pairs ( aAnims ) do aHGUI = { }; aHGUI[index] = guiGridListAddRow ( guiElement2 ); guiGridListSetItemText ( guiElement2, aHGUI[index], guiElement5, aAnims[i][1], false, false ); guiGridListSetItemText ( guiElement2, aHGUI[index], guiElement6, aAnims[i][2], false, false ); end end ) -- wndShow = function ( ) guiSetVisible ( guiElement1, not guiGetVisible ( guiElement1 ) ); showCursor ( guiGetVisible ( guiElement1 ) ); end addEventHandler ( "onClientGUIClick", elementGroup, function ( ) if ( source == guiElement3 ) then local row, col = guiGridListGetSelectedItem ( source ); if ( row and col and row ~= -1 and col ~= -1 ) then local chBlock = guiGridListGetItemText ( source, row, guiElement5 ); local chAnim = guiGridListGetItemText ( source, row, guiElement6 ); triggerServerEvent ( "onElementAnimation", localPlayer, chBlock, chAnim ); end elseif ( source == guiElement4 ) then guiSetVisible ( guiElement1, false ) showCursor ( false ); end end ) Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 YOU should learn more about LUA, too. Still same errors like before 5 posts. Only asked if someone can help me with tables, cause im Learning it. Indeed thanks. guiGridListSetItemText( guiElement2, aHGUI[index], guiElement5, aAnims[i][1], false, false ) -- index thing is nil value Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 try this: local animations = { { "RIOT", "RIOT_ANGRY" }, { "RIOT", "RIOT_ANGRY_B" }, { "RIOT", "RIOT_challenge" }, { "RIOT", "RIOT_CHANT" }, { "RIOT", "RIOT_FUKU" }, { "RIOT", "RIOT_PUNCHES" }, { "RIOT", "RIOT_shout" } } bindKey( "i", "down",function() if ( guiGetVisible( guiElement1 ) == false ) then guiSetVisible( guiElement1, true ) showCursor( true ) end end) addEventHandler( "onClientResourceStart", resourceRoot,function() for i = 1, #animations do guiElement[i] = guiGridListAddRow( guiElement2 ) guiGridListSetItemText( guiElement2, guiElement5, guiElement[i], animations[i][1], false, false ) guiGridListSetItemText( guiElement2, guiElement6, guiElement[i], animations[i][2], false, false ) end end) addEventHandler( "onClientGUIClick", guiRoot,function() if ( source == guiElement3 ) then if ( guiGridListGetSelectedItem( guiElement2 ) == guiElement[i], guiElement5 ) and ( guiGridListGetSelectedItem( guiElement2 ) == guiElement[i], guiElement6 ) then local block = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement5 ) local animation = guiGridListGetItemText( guiElement2, guiGridListGetSelectedItem( guiElement2 ), guiElement6 ) if ( block ) and ( animation ) then triggerServerEvent( "onElementAnimation", elementPlayer, block, animation ) end end elseif ( source == guiElement4 ) then guiSetVisible( guiElement1, false ) showCursor( false ) end end) Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 da fuck is wrong in this line? i mean, this is the syntax or not? if ( guiGridListGetSelectedItem( guiElement2 ) == guiElement[i], guiElement5 ) and ( guiGridListGetSelectedItem( guiElement2 ) == guiElement[i], guiElement6 ) then Link to comment
X-SHADOW Posted May 21, 2012 Share Posted May 21, 2012 for fixing this code if ( guiGridListGetSelectedItem( guiElement2 ) == guiElement, guiElement5 ) and ( guiGridListGetSelectedItem( guiElement2 ) == guiElement, guiElement6 ) then use the code i post Link to comment
Jaysds1 Posted May 21, 2012 Share Posted May 21, 2012 isn't the guiElement the name of the animation? The guiGridListGetSelectedItem returns 2 intergers, so, no that's not the right syntax Link to comment
Maurize Posted May 21, 2012 Author Share Posted May 21, 2012 @xshadow: U Serious? if ( guiGridListGetSelectedItem) then ( guiElement2 )(guiElement) (guiElemen) ( guiGridListGetSelectedItem)( guiElement2 ) if (guiElement) and (guiElement6) then @jaysds1: the point is, that i want to get the animations out of a table and the create a row for every animation. then select it from list and trigger it.. so guiElement and not guiElement Link to comment
Castillo Posted May 22, 2012 Share Posted May 22, 2012 Everything posted above makes no sense ( no offense ). local animations = { { "RIOT", "RIOT_ANGRY" }, { "RIOT", "RIOT_ANGRY_B" }, { "RIOT", "RIOT_challenge" }, { "RIOT", "RIOT_CHANT" }, { "RIOT", "RIOT_FUKU" }, { "RIOT", "RIOT_PUNCHES" }, { "RIOT", "RIOT_shout" } } bindKey ( "i", "down", function ( ) if ( guiGetVisible ( guiElement1 ) == false ) then guiSetVisible ( guiElement1, true ) showCursor ( true ) end end ) addEventHandler( "onClientResourceStart", resourceRoot, function ( ) for index, animation in ipairs ( animations ) do local row = guiGridListAddRow ( guiElement2 ) guiGridListSetItemText ( guiElement2, row, 1, tostring ( animation [ 1 ] ), false, false ) guiGridListSetItemText ( guiElement2, row, 2, tostring ( animation [ 2 ] ), false, false ) end end ) addEventHandler ( "onClientGUIClick", guiRoot, function ( ) if ( source == guiElement3 ) then local row, col = guiGridListGetSelectedItem ( guiElement2 ) if ( row and col and row ~= -1 and col ~= -1 ) then local block = guiGridListGetItemText ( guiElement2, row, 1 ) local animation = guiGridListGetItemText ( guiElement2, row, 2 ) if ( block ) and ( animation ) then triggerServerEvent ( "onElementAnimation", localPlayer, block, animation ) end end elseif ( source == guiElement4 ) then guiSetVisible ( guiElement1, false ) showCursor ( false ) end end ) Link to comment
Maurize Posted May 22, 2012 Author Share Posted May 22, 2012 Mate, your script make sense and works like a boss. THANKS YOU SO MUCH SOLIDSNAKE & THE OTHERS WHO TRIED TO HELP, TOO! Link to comment
X-SHADOW Posted May 22, 2012 Share Posted May 22, 2012 SoldSnake14 Comes and Fucked up every body Link to comment
Jaysds1 Posted May 22, 2012 Share Posted May 22, 2012 THANKS OTHERS WHO TRIED TO HELP, TOO! np SoldSnake14 Comes and up every body lol, I know... Link to comment
Castillo Posted May 22, 2012 Share Posted May 22, 2012 Mate, your script make sense and works like a boss.THANKS YOU SO MUCH SOLIDSNAKE & THE OTHERS WHO TRIED TO HELP, TOO! You're welcome. 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