Jump to content

Trouble with Animation-GUI!:>


Maurize

Recommended Posts

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

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) 

:D

Link to comment

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

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

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

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

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

@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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...