Jump to content

[Help]Grid list


3B00DG4MER

Recommended Posts

YAW ^^

not work :'(

Can you post the code?

        addEventHandler("onClientGUIClick",GUIEditor.window[1], 
            function(b) 
                if b == "left" then 
                if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
                elseif source == GUIEditor.button[1] then 
                local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
                if ( SelectedSkin ~= -1  ) then 
                if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
                triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                else 
                exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                end 
                else 
                exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
            end 
            end 
            ) 

Link to comment
addEventHandler("onClientGUIClick",GUIEditor.window[1], 
    function(b) 
        if b == "left" then 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local selected = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                if ( selected  ) then 
                    local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], selected, 1 ) 
                    if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                        guiSetVisible(GUIEditor.window[1],false) 
                        showCursor(false) 
                        triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                    else 
                        exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                    end 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
        end 
    end 
) 

Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.
Link to comment
addEventHandler("onClientGUIClick",GUIEditor.window[1], 
    function(b) 
        if b == "left" then 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local selected = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                if ( selected  ) then 
                    local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], selected, 1 ) 
                    if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                        guiSetVisible(GUIEditor.window[1],false) 
                        showCursor(false) 
                        triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                    else 
                        exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                    end 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
        end 
    end 
) 

Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.

Not work !! :x

Link to comment

it's because the event handler is linked to the window, the source would always be the window and the event would only trigger if you click on the window.

Try this:

      addEventHandler("onClientGUIClick",guiRoot,function(b) 
            if b ~= "left" then return end 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local row,column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1],row , 1 ) 
                if row == -1 then 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                    return 
                end 
                if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                    guiSetVisible(GUIEditor.window[1],false) 
                    showCursor(false) 
                    triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                end 
            end 
        end) 

Edited by Guest
Link to comment
it's because the event handler is linked to the window, the source would always be the window and the event would only trigger if you click on the window.

Try this:

       addEventHandler("onClientGUIClick",guiRoot,function(b) 
            if b ~= "left" then return end 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
                if ( SelectedSkin ~= -1  ) then 
                    if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                        guiSetVisible(GUIEditor.window[1],false) 
                        showCursor(false) 
                        triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                    else 
                        exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                    end 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
        end) 

i tried not work :(

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...